Subj : Re: Embedding E4X support with SpiderMonkey To : netscape.public.mozilla.jseng From : Peter Wilson Date : Wed May 04 2005 08:27 pm Brendan Eich wrote: > Peter Wilson wrote: > >> For example: >> > new XML('') >> > claims an XML syntax error, possibly down to the XML namespace being >> > unsupported. >> >> Answered part of this myself : JS_SetOptions(..., JSOPTION_XML) which >> seems to get the basic XML engine working. > > > > Yes, that's required for backward compatibility. JS handles the > > > > trick I perpetrated in 1995 to get inline scripts wedged into HTML > without showing in older browsers than Netscape 2 (beta, at that time). > > >> For further clarification - my existing DOM/Xpath without having to >> rebuild another shadow of the tree. (Note - my XML parser etc is >> written in C++ and integrated as a set of native classes that shadow >> parts of that tree on demand). Having to serialise that back to text - >> then have the SpiderMonkey engine re-parse it into a tree isn't going to >> be efficient, especially in a server-side application. > > > > See https://bugzilla.mozilla.org/show_bug.cgi?id=270553. I have a patch > I've been neglecting on account of higher priority work, that adds an > API to Gecko's DOM. It implements the rest of ECMA-357 -- new > XML(document), .domNode/.domNodeList, etc. You could use it for the > same purpose with your DOM impl, but I'm sure it will need some revamping. > > How about I get the patch into that bug and get the DOM hookup working > with Gecko, then you try that E4X/DOM API out with your DOM code? Sounds like a great starting point. Will the API cover the XPath selection as well? I effectively have analogues of XML (XmlGeneric and a set of sub-classes) and XMLList (XmlNodeSet) in my code - node effectively has node.xpath and node.select to query the tree. It takes an entire XPath expression and creates an XmlNodeSet. If anyone is interested: http://www.whitebeam.org/library/guide/TechNotes/xmlproc.rhtm http://www.whitebeam.org/library/guide/TechNotes/xpath.rhtm I only create JS instances of XML elements when referenced by JS code so I don't have to duplicate the entire tree in JS if the script is only going to change one node. I guess ideally an API that passes over the XPath query and accepts a node-set back would be good. It's a pity the E4X doesn't use standard XPath syntax - it may have been better to have a '.select' method and stick with the syntax than invent something new. If you let me know when you've got the patch ready I'll take a look and work out how to proceed. As always, thanks very much Brenden Pete > > /be .