XML/XSLT in Mozilla | January 17th, 2006
I had just clicked the “save and preview” button and lost my entire post … anyhow I will give it another shot but it will surely not be anywhere as lucid given my rising urge to kill
Given that we have been developing AJaX solutions for some time now based on Internet Explorer it is becoming a wee bit annoying that we have to cater so much to the Firefox/Mozilla using crowd simply because they are the most vocal and influential! Luckily most of our customers still use Internet Explorer. Nonetheless we are doing our best and hope to have a cross browser architecture for our AJaX components very soon. In so doing, I have been having a fun time figuring our XPath and XSLT in Mozilla so that it emulates Internet Explorer (I will likely just end up using sarissa in the end though). Having gone through most of this process, I finally understand why the majority of Mozilla developers hate XML/XSLT and love JSON! It also helps that MSDN has such great documentation I guess as well :S
Most of this work has been in an effort to create a small library that I call J4X - JSON for XML - which essentially dynamically creates a JavaScript object representing the XML behind it. This liberates developers from having to use XML interfaces to access their objects and insteads makes it just like JSON. So you get the best of both worlds - easy programatic access and XML based message formatting! In that respect it is more or less a stop-gap technology until E4X becomes more widely supported.
July 16th, 2007 at 9:29 am
Did you do an article that follows up on your J4X library? It sounds like a very interesting idea. What rules will you use to convert XML elements, attributes, PCData, etc. to what JSON object types? Will you be using JavaScript or XSLT to do the transformation? Will there be a reverse process, X4J?
July 18th, 2007 at 1:24 am
Hey Billy,
I do have some code that works for me but I think that the xml2json code from Stefan Goessner is a really good general solution. Check it out here: http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html
On most XML documents it is very fast as well!
I really have to get more code up on my blog
Cheers,
Dave