|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] ANSWERS to "What's wrong with XQuery" questionBrett Zamir brettz9 at yahoo.comMon Jul 26 18:53:48 PDT 2010
On 7/26/2010 5:18 PM, James Fuller wrote: > Thx to Martin for the succinct overview of issues with XML<->JSON, > > I guess I am more leaning towards coming up with 'something different' > ... maybe look at what serializing/dumping e4x internal representation > is as I am assuming its a normal js object. > > I think if we get a serialization that maps directly onto a js object > then we are done, e.g. we just need a representation that is > consumable by javascript ... and I think e4x maybe the hook here. E4X is only an extension to JavaScript, so it is only currently supported in Mozilla, and V8 (Chrome) is open to including it if a third party implements it: http://code.google.com/p/v8/issues/detail?id=235 E4X is treated as a fundamental type rather than as a regular object, with its own accessors which are JS object-like (and more powerful if filters are used, making it more XPath like). For example, var friends= <myData><friends> <name type="imaginary">Snuffaluffagus</name> <name type="real">Goober</name> <name type="imaginary">Tooth Fairy</name> </friends></myData>; var realFriends= friends..name.(@type== 'real').toString(); // Goober You can also reshape data. If we just change the equality check to an assignment: var realFriends= friends..name.(@type= 'real').toString(); // Goober ...we get as the results an "XMLList" (and the original element altered in place): <name type="real">Snuffaluffagus</name> <name type="real">Goober</name> <name type="real">Tooth Fairy</name> To simulate some XQuery-like features, you might see https://developer.mozilla.org/en/E4X_for_templating , but E4X does not have a lot of built-in means of reshaping the XML other than as above or creating element names, attribute names, or attribute values and element content dynamically. As far as serializing to more portable objects, there is a built-in method, "toXMLString()" for serializing the whole E4X object which represents the XML into a string (toString() will serialize the XML or return the text contents if the referenced element is only containing text). (Strings can in turn be converted to DOM objects or whatever.) But there is no regular JSON traversal serialization. Wonder if someone will make an E4X database that can also be XQueried... :) Brett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://x-query.com/pipermail/talk/attachments/20100726/78695ed0/attachment.htm
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








