Sylvain Wallez wrote:
Daniel Fagerstrom wrote:
I took a look at the Rhino download page http://www.mozilla.org/rhino/download.html and found to my suprise that Rhino 1.6R1 (the version that we use in the trunk) includes ECMAScript for XML (E4X). That makes XML a native data type in JS and let you do XPath like things within the JS syntax, see http://lxr.mozilla.org/mozilla/source/js/rhino/examples/E4X/e4x_example.js for examples.
Quite cool IMO!
I would say more: that kicks ass big time! The soap example is particularily impressive.
:)
I have looked a little bit more on it. It doesn't seem to work with the Rhino jar in the SVN. Rhino recognize the E4X syntax but it cannot find the XML class that is needed. The xbean.jar must be present during compilation AFAICS, probably our version is compiled without it. Maybe Reinhard know?
The implementation of E4X is based on XMLBeans, http://xmlbeans.apache.org/. After having browsed the Rhino source http://lxr.mozilla.org/mozilla/source/js/rhino/, I get the impression that objects in the XML (whithin Rhino) class both can be constructed on and return its internal o.a.xmlbeans.XmlObject. If this is true have a lot of flexiblity.
XmlObject is the base interface in XMLBeans, it has methods so that an XML object can be serialized to SAX and constructed from SAX. It can also create a DOM or be initiated from a DOM. In the next version of XMLBeans there will tighter intgration with DOM, an XmlBean will implement the DOM interface as well, and no copying will be needed anymore.
For those who don't know about XMLBeans. It is a XMLSchema driven XML-Java binding package. It uses XMLSchema to compile to Java classes that makes it possible to access the XML tree in a bean style way, and with full access to the XML Infoset. The XMLBeans provides access to the XML leafs as ordinary Java data types, (int, long, Date etc). It also have validation at subtree level.
IIRC Daisy use XMLBeans, so maybe some of the Outerthought guys can tell more.
Also, this could easily be turned into an "E4XGenerator" as yet another templating language.
Yes, if I'm right about the XmlBean access, it should be fairly easy to do.
/Daniel
