[mashup-dev] svn commit r15614 - trunk/mashup/java/xdocs

svn at wso2.org svn at wso2.org
Mon Apr 7 18:14:03 PDT 2008


Author: jonathan
Date: Mon Apr  7 18:13:58 2008
New Revision: 15614

Log:

Augmented with @["class"] trick and improved for each .. in.

Modified:
   trunk/mashup/java/xdocs/e4xquickstart.html

Modified: trunk/mashup/java/xdocs/e4xquickstart.html
==============================================================================
--- trunk/mashup/java/xdocs/e4xquickstart.html	(original)
+++ trunk/mashup/java/xdocs/e4xquickstart.html	Mon Apr  7 18:13:58 2008
@@ -181,16 +181,19 @@
     <class>History 101</class>
     <abstract>Introduction to World History</abstract>
     <public can-register="yes"/>
+    <div class="description">How we got to where we are.</div>
 &lt;/transcript&gt;;</pre>
     <p>The following expressions are invalid E4X because of reserved words or invalid
         name characters.</p>
-                <pre class="Code">var c = transcript.class;
+                <pre class="Code" style="color:red">var c = transcript.class;
 var a = transcript.abstract;
-var r = transcript.public. at can-register;</pre>
+var r = transcript.public. at can-register;
+var description = transcript.div.(@class == 'description');</pre>
     <p>Instead use the following synonymous syntax:</p>
                 <pre class="Code">var c = transcript[&quot;class&quot;];
 var a = transcript[&quot;abstract&quot;];
-var r = transcript[&quot;public&quot;].attribute(&quot;can-register&quot;);</pre>
+var r = transcript[&quot;public&quot;].attribute(&quot;can-register&quot;);
+var description = transcript.div.(@[&quot;class&quot;] == 'description');</pre>
     <p>For your reference, here is a list of reserved words in Javascript and E4X:</p>
                 <pre>abstract    boolean    break       byte        case         catch
 char        class      const       continue    debugger     default
@@ -835,16 +838,17 @@
 
 <h2 id="iteration">Iteration</h2>
 
-<p>The for operator is extended to more easily traverse the properties of an object
-    (especially children of an XML object, or items in an XMLList).</p>
-            <pre class="Code">var firstCustomerDate = new Date();
-for (var customer in c.customer) {
+<p>The "for each" operator is extended to more easily traverse the properties of an object
+    (especially children of an XML object, or items in an XMLList).  This is more convenient
+    than the normal Javascript "for .. in" which sets the iterator variable to an index rather
+    than directly returning the node.</p>
+<pre class="Code">var firstCustomerDate = new Date();
+for each (var customer in c.customer) {
     var since = new Date(customer.since);
     if (since &lt; firstCustomerDate) {
         firstCustomerDate = since;
     }
 }</pre>
-<p>(N.B. Is there any difference between for..in and for each..in?)</p>
 
 <p><br clear="all"/></p>
 



More information about the Mashup-dev mailing list