I’ve looked at little at the Bean IT XML stuff and installed it on an instance of MySQL.
I’ve been successful getting some SQL code similar to the examples you provide working, but there are a lot of methods that I’m not sure how to use. Especially how to combine these different methods into a SQL select.
It’s always nice to hear if someone like a project, so thanks.
I haven’t got much more example code than given on the website unfortunately. The tests I’ve written are quite dry and wont give you any idea of the use of the library. But I can at least give you an examples and a short explanation.
With a processing instruction you may specify how a certain xml file should be handled. Adding an xml-stylesheet pi to your xml will trigger a browser to use XSLT with the specified xsl file to convert the XML before displaying.
All functions starting with a ‘c’, like bnxml_celement and bnxml_cforest, will put the content in a CDATA section instead of converting the data to XML.
mysql> SELECT bnxml_element('message', "This story is < Lord of the Rings");
+---------------------------------------------------------------+
| bnxml_element('message', "This story is < Lord of the Rings") |
+---------------------------------------------------------------+
| This story is < Lord of the Rings |
+---------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT bnxml_celement('message', "This story is < Lord of the Rings");
+------------------------------------------------------------------+
| bnxml_celement('message', "This story is & lt; Lord of the Rings") |
+------------------------------------------------------------------+
| <!--[CDATA[This story is < Lord of the Rings]]--> |
+------------------------------------------------------------------+
1 row in set (0.00 sec)
There are several functions to bind things together, but the can be broken down in 2 groups;
- bnxml_concat will simply stick the xml together, almost in the same way that concat() does.
- bnxml_agg sticks xml of multiple rows together, just like a group_concat().
I've had some downloads, but no real questions, bug reports or other prove that someone besides me was actually using the lib. But I just might write a small tutorial / story about it on my blog next week.
Arnold,
I’ve looked at little at the Bean IT XML stuff and installed it on an instance of MySQL.
I’ve been successful getting some SQL code similar to the examples you provide working, but there are a lot of methods that I’m not sure how to use. Especially how to combine these different methods into a SQL select.
Like:
bnxml_textdecl()
bnxml_pi()
bnxml_celement()
…
Have you got any more examples or some test cases you used when you developed it?
It looks cool.
Thanks
Hi George,
It’s always nice to hear if someone like a project, so thanks.
I haven’t got much more example code than given on the website unfortunately. The tests I’ve written are quite dry and wont give you any idea of the use of the library. But I can at least give you an examples and a short explanation.
First of all, have you read the API documentation. I might not be enough info, but at least you not what you’ve got. http://libmysqlbnxml.sourceforge.net/docs.php
The text declaration is always the first line of an XML document.
mysql> SELECT bnxml_textdecl('1.0', 'iso-8859-1'); +----------------------------------------------+ | bnxml_textdecl('1.0', 'iso-8859-1') | +----------------------------------------------+ | <?xml version="1.0" encoding="ISO-8859-1"?> | +----------------------------------------------+ 1 row in set (0.00 sec)With a processing instruction you may specify how a certain xml file should be handled. Adding an xml-stylesheet pi to your xml will trigger a browser to use XSLT with the specified xsl file to convert the XML before displaying.
mysql> SELECT bnxml_pi('xml-stylesheet', 'href="classic.xsl" mce_href="classic.xsl" '); +--------------------------------------------------+ | bnxml_pi('xml-stylesheet', 'href="classic.xsl" mce_href="classic.xsl" ') | +--------------------------------------------------+ | <?xml-stylesheet xhref="classic.xsl" mce_href="classic.xsl" ?> | +--------------------------------------------------+ 1 row in set (0.00 sec)All functions starting with a ‘c’, like bnxml_celement and bnxml_cforest, will put the content in a CDATA section instead of converting the data to XML.
mysql> SELECT bnxml_element('message', "This story is < Lord of the Rings"); +---------------------------------------------------------------+ | bnxml_element('message', "This story is < Lord of the Rings") | +---------------------------------------------------------------+ | This story is < Lord of the Rings | +---------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT bnxml_celement('message', "This story is < Lord of the Rings"); +------------------------------------------------------------------+ | bnxml_celement('message', "This story is & lt; Lord of the Rings") | +------------------------------------------------------------------+ | <!--[CDATA[This story is < Lord of the Rings]]--> | +------------------------------------------------------------------+ 1 row in set (0.00 sec)There are several functions to bind things together, but the can be broken down in 2 groups;
- bnxml_concat will simply stick the xml together, almost in the same way that concat() does.
- bnxml_agg sticks xml of multiple rows together, just like a group_concat().
I've had some downloads, but no real questions, bug reports or other prove that someone besides me was actually using the lib. But I just might write a small tutorial / story about it on my blog next week.
Great. What you’ve written helps a lot.
A tutorial would be great.
It looks like you’re involved creating something to handle the reverse process too, of loading XML data into the DB.
Thanks
I love the sxc photo for the banner
awesome pic