[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

E4X(ECMAScript for XML)

  • From: L2L 2L <emanuelallen@hotmail.com>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Tue, 22 Jul 2014 11:04:48 -0400

E4X(ECMAScript for XML)
Revive E4X as EXQO(ECMA-Script's XML Query Object) with SAX added on as methods for the xml object.

With an added method call xPath();

Xml file to be use:
<note> 
  <date>2002-08-01</date>    
  <to>Tove</to>
  <from>Jani</from> 
  <heading>Reminder</heading> 
  <body>Don't forget me this weekend!</body> 
</note>

Example:
//E4X spec.
var xmlDoc=new XML();
xmlDoc.load("note.xml");
document.write(xmlDoc.body);
//please look at the bottom for a corresponding to this.
//output body text value

Example:
//with added xPath() method
var xmlDoc=new XML();
xmlDoc.load("note.xml");
document.write(
xmlDoc.xPath("//body");
//relative path expression
);

Example:
var xmlDoc=new XML();
xmlDoc.load("note.xml");
document.write(
xmlDoc.xPath("/note/body");
//absolute path expression
);

This will gain attention to the ease of navigating the dom. Also the other goal is to point to xQuery as a server scripting alternative to popular server side scripting such as php.

//thoughts on the E4X spec.
//the e4x spec of the look at this make it to where the root element is the container for the object return.
I feel, this should lean more to JSON type syntax:

var xmlDoc = {
note:[
  {date:"2002-08-01"},    
  {to:"Tove"},
  {from:"Jani"},
  {heading:"Reminder"}, 
  {body:"Don't forget me this weekend!"}
]}

document.write(
xmlDoc.note[4].body);

So let's say we do the same for the spec to make it more... Easy to compose a new spec with.

The dom or really htmlelementobject API and documentobject API both have methods for manipulating the xml/html.

It stand to reason to mimic those feature via JSON.

As so:

var xmlDoc=new XML();
xmlDoc.load("note.xml");
document.write(xmlDoc.note[4].body);

And again with the xPath(/*expression*/); //method

var xmlDoc=new XML();
xmlDoc.load("note.xml");
document.write(
xmlDoc.xPath("/note/body")
);

For the first spec, I say to use only xPath 1.0

With attribute, I say to use the xPath(/*expression*/); method to retrieve that via string:

<date attr="value">
  2002-08-01
</date>

xmlDoc.xPath("/note/@attr");
//xPath 1.0 spec
);

to make the spec easier to adopt.

Making this appliance to "use strict";

I say to make a new statement declaration: 
"use EXQO"; or "use ESXQO";

Use JSON syntax when it comes to the EMCAScript environment.

Use xPath(/*expression*/); for all non EMCAScript environment expression, and syntax.

Note that this version may receive further editing in the future.

Thank you for reading. 

E-S4L

E-S4L


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.