coliver     2003/12/14 10:23:54

  Modified:    src/documentation/xdocs/userdocs/flow jxtemplate.xml
                        tutor.xml
  Log:
  Improving documentation
  
  Revision  Changes    Path
  1.25      +63 -15    
cocoon-2.1/src/documentation/xdocs/userdocs/flow/jxtemplate.xml
  
  Index: jxtemplate.xml
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/flow/jxtemplate.xml,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- jxtemplate.xml    11 Dec 2003 06:07:49 -0000      1.24
  +++ jxtemplate.xml    14 Dec 2003 18:23:54 -0000      1.25
  @@ -98,6 +98,27 @@
   </dl>
   </s1>
   
  +<s1 title ="Parameters">
  +<s2 title="lenient-xpath">
  +<p>
  +By default XPath evaluation throws an exception if the supplied XPath does 
not map to an existing property. This constraint can be relaxed by setting the 
parameter <code>lenient-xpath</code> to <code>true</code>. In the lenient mode 
evaluation simply returns null if the path maps to nothing.
  +</p>
  +<p>
  +Example:
  +</p>
  +<p><source>
  +<![CDATA[
  +    <map:match pattern="*.jx">
  +      <map:generate type="jx" src="documents/{1}.jx">
  +           <map:parameter name="lenient-xpath" value="true"/>
  +      </map:generate>
  +      <map:serialize type="xhtml"/>
  +    </map:match>
  +]]>
  +</source>
  +</p>
  +</s2>
  +</s1>
   <s1 title ="Tags">
   <p>The JXTemplate Generator tags are defined in the namespace</p>
   <source>
  @@ -229,8 +250,31 @@
   <code>1</code> = second item, ...). If unspecified it defaults to the last 
item in the list. Every <code>step</code> items are
   processed (defaults to <code>1</code> if <code>step</code> is absent). 
Either <code>items</code> or both <code>begin</code> and <code>end</code> must 
be present.</p>
   <p>
  -If the <code>varStatus</code> attribute is present a variable will be 
created to hold information about the current loop status. The variable named 
by the <code>varStatus</code> attribute will hold a reference to an object with 
the following properties:
  -</p>
  +
  +<p>An alternate form of <code>forEach</code> is supported for convenience 
when using XPath (since you can specify the selection criteria for the 
collection using XPath itself):</p>
  +<source>
  +&lt;jx:forEach select="XPathExpression"&gt;
  +  body
  +&lt;/jx:forEach&gt;
  +</source>
  +<p>When using XPath expressions within <code>forEach</code> the current 
element is the context node and can be referenced with: 
  +<code>#{.}</code></p>
  +<p>Jexl Example:</p>
  +<source>
  +&lt;jx:forEach var="item" items="${cart.cartItems}" 
  +               begin="${start}" end="${count-start}" step="1"&gt;
  +   &lt;td&gt;${item.productId}&lt;/td&gt;
  +&lt;/jx:forEach&gt;
  +</source>
  + <p/>
  +<p>JXPath Example:</p>
  +<source>
  +&lt;jx:forEach select="#{cart/cartItems[position() &amp;lt;= $count]}}&gt;
  +   &lt;td&gt;#{./productId}&lt;/td&gt;
  +&lt;/jx:forEach&gt;
  +</source>
  + <p/>
  +If the <code>varStatus</code> attribute is present a variable will be 
created to hold information about the current loop status. The variable named 
by the <code>varStatus</code> attribute will hold a reference to an object with 
the following properties:</p>
       <table>
        <tr>
          <td>
  @@ -305,28 +349,32 @@
          </td>
        </tr>
       </table>
  -<p>An alternate form of <code>forEach</code> is supported for convenience 
when using XPath (since you can specify the selection criteria for the 
collection using XPath itself):</p>
  -<source>
  -&lt;jx:forEach select="XPathExpression"&gt;
  -  body
  -&lt;/jx:forEach&gt;
  -</source>
  -<p>When using XPath expressions within <code>forEach</code> the current 
element is the context node and can be referenced with: 
  -<code>#{.}</code></p>
   <p>Jexl Example:</p>
   <source>
  -&lt;jx:forEach var="item" items="${cart.cartItems} begin="${start}" 
end="${count-start}" step="1""&gt;
  -   &lt;td&gt;${item.productId}&lt;/td&gt;
  +&lt;jx:forEach items="${items}" varStatus="status"&gt;
  +    index=${status.index},
  +    count=${status.count},
  +    current=${status.current},
  +    first=${status.first},
  +    last=${status.last},
  +    begin=${status.begin},
  +    end=${status.end}
   &lt;/jx:forEach&gt;
   </source>
    <p/>
   <p>JXPath Example:</p>
   <source>
  -&lt;jx:forEach select="#{cart/cartItems[position() &amp;lt;= $count]}}&gt;
  -   &lt;td&gt;#{./productId}&lt;/td&gt;
  +&lt;jx:forEach items="#{items}" varStatus="status"&gt;
  +    index=#{$status.index},
  +    count=#{$status.count},
  +    current=#{$status.current},
  +    first=#{$status.first},
  +    last=#{$status.last},
  +    begin=#{$status.begin},
  +    end=#{$status.end}
   &lt;/jx:forEach&gt;
   </source>
  - <p/>
  +<p/>
   </s2>
   <s2 title="formatNumber">
   <p>
  
  
  
  1.9       +15 -15    
cocoon-2.1/src/documentation/xdocs/userdocs/flow/tutor.xml
  
  Index: tutor.xml
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/flow/tutor.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- tutor.xml 13 Oct 2003 21:20:31 -0000      1.8
  +++ tutor.xml 14 Dec 2003 18:23:54 -0000      1.9
  @@ -26,8 +26,8 @@
     <map:generators default="file">
       <!-- in this example we use JXTemplateGenerator to insert
            Flow variables in page content -->
  -    <map:generator label="content,data" logger="sitemap.generator.jxt"
  -                   name="jxt" 
src="org.apache.cocoon.generation.JXTemplateGenerator"/>
  +    <map:generator label="content,data" logger="sitemap.generator.jx"
  +                   name="jx" 
src="org.apache.cocoon.generation.JXTemplateGenerator"/>
     </map:generators>
     <map:flow-interpreters default="JavaScript"/>
     <map:transformers default="xslt"/>
  @@ -65,8 +65,8 @@
       </map:match>
   
       <!-- use JXtemplate to generate page content -->
  -    <map:match pattern="*.jxt">
  -      <map:generate type="jxt" src="documents/{1}.jxt"/>
  +    <map:match pattern="*.jx">
  +      <map:generate type="jx" src="documents/{1}.jx"/>
         <map:serialize type="xhtml"/>
       </map:match>
   
  @@ -103,7 +103,7 @@
         <p>Inside the new subdirectory, create two more directories,
           <code>documents/</code> and <code>flow/</code>.</p>
         <p>Inside <code>documents/</code>, you will store the "views" -- pages 
to
  -        send to the player. Create the file <code>guess.jxt</code>, which 
will
  +        send to the player. Create the file <code>guess.jx</code>, which will
           be the page the player will enter their guess:</p>
         <source><![CDATA[
   <?xml version="1.0"?>
  @@ -115,7 +115,7 @@
     <h1>Guess the Number Between 1 and 10</h1>
     <h2>${hint}</h2>
     <h3>You've guessed ${guesses} times.</h3>
  -  <form method="post" action="${continuation.id}.kont">
  +  <form method="post" action="${cocoon.continuation.id}.kont">
       <input type="text" name="guess"/>
       <input type="submit"/>
     </form>
  @@ -124,7 +124,7 @@
   ]]></source>
         <p>
           You'll also need a page to display when the person chooses the 
correct
  -        number. Name it <code>success.jxt</code> (Again in 
<code>documents/</code>):
  +        number. Name it <code>success.jx</code> (Again in 
<code>documents/</code>):
         </p>
         <source><![CDATA[
   <?xml version="1.0"?>
  @@ -182,7 +182,7 @@
       }
     }
   
  -  cocoon.sendPage("success.jxt", {"random" : random, "guess" : guess,
  +  cocoon.sendPage("success.jx", {"random" : random, "guess" : guess,
                                     "guesses" : guesses} );
   }
   ]]></source>
  @@ -210,7 +210,7 @@
   cocoon.sendPageAndWait("guess.jxt", { "random" : random, "hint" : hint, 
"guesses" : guesses} );
   </source>
         <p>
  -        The Flow layer sends the contents of the URI "guess.jxt" which is 
matched
  +        The Flow layer sends the contents of the URI "guess.jx" which is 
matched
           in the sitemap (see above). We also pass an inline Javascript object,
           containing three key/value pairs, one named "random" which contains 
the
           value of the variable random as initialized above, and so on for 
hint and
  @@ -219,7 +219,7 @@
         </p>
         <p>We could also do the following:</p>
         <source>
  -cocoon.sendPageAndWait("guess.jxt", { "foo" : random } );
  +cocoon.sendPageAndWait("guess.jx", { "foo" : random } );
   </source>
         <p>
           In this case, the value of random would be able to be substituted in 
our
  @@ -236,8 +236,8 @@
         </p>
         <p>
           Picking back up in the script execution, the client is sent through
  -        the pipeline matching "guess.jxt". Referring back to the sitemap, we
  -        match *.jxt, and run the file through the JXTemplateGenerator, which
  +        the pipeline matching "guess.jx". Referring back to the sitemap, we
  +        match *.jx, and run the file through the JXTemplateGenerator, which
           substitutes the keynames for the values sent from the
           <link href="api.html#sendPageAndWait">cocoon.sendPageAndWait()</link>
           function.
  @@ -247,10 +247,10 @@
           player submits the guess:
         </p>
         <source><![CDATA[
  -<form method="post" action="${continuation.id}.kont">
  +<form method="post" action="${cocoon.continuation.id}.kont">
   ]]></source>
         <p>
  -        Here, ${continuation.id} is resolved to a unique identifier which 
points
  +        Here, ${cocoon.continuation.id} is resolved to a unique identifier 
which points
           to the current continuation. One can think of this somewhat of a 
session ID.
         </p>
         <p>
  @@ -288,7 +288,7 @@
         </p>
         <p>
           If the guess was correct, we break out of the main loop and send the
  -        player to a different view, this time to "success.jxt", and we give 
the
  +        player to a different view, this time to "success.jx", and we give 
the
           template not only their number and the random number (pointless, yes,
           because they were the same), but also the number of guesses to tell 
the
           player how good or bad at guessing numbers they are.
  
  
  

Reply via email to