home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / jpath.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  4.5 KB  |  126 lines

  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "document-v10.dtd">
  18. <document>
  19.   <header>
  20.    <title>Advanced Control Flow</title> 
  21.    <authors>
  22.     <person name="Christopher Oliver" email="coliver@apache.org"/>
  23.     <person name="Ovidiu Predescu" email="ovidiu@apache.org"/>
  24.    </authors>
  25.   </header>
  26.   <body>
  27.    <s1 title="JPath Logic Sheet">
  28.     <p>
  29.      The JPath Logic Sheet is an <link href="../xsp/index.html">XSP</link> logic sheet that allows
  30.      you to access data from a Cocoon Flowscript in an XSP page and inject it into a Cocoon
  31.      pipeline. It provides a set of tags (similar to the those defined by
  32.      <link href="http://www.w3.org/TR/xslt">XSLT</link>) that allow you to iterate over Java
  33.      collections (and Java or JavaScript arrays) and to test for the presence of optional or
  34.      alternate bean properties. It is based on
  35.      <link href="http://jakarta.apache.org/commons/jxpath">Apache JXPath</link>.
  36.     </p>
  37.    </s1>
  38.    <s1 title ="Tags">
  39.     <p>The JPath tags are defined in the namespace</p>
  40.     <source>http://apache.org/xsp/jpath/1.0</source>
  41.     <s2 title ="if">
  42.      <p>The <code>if</code> tag allows the conditional execution of its body according to value of its <code>test</code> attribute:</p>
  43.      <source>
  44. <if test="XPathExpression">
  45.   body
  46. </if>
  47.      </source>
  48.      <p>Example:</p>
  49.      <source>
  50. <jpath:if test="cart/numberOfItems = 0">
  51.   Your cart is empty
  52. </jpath:if>
  53.      </source>
  54.     </s2>
  55.     <s2 title ="choose">
  56.      <p>The <code>choose</code> tag performs conditional block execution by its embedded
  57.         <code>when</code> sub tags. It renders the body of the first <code>when</code> tag whose
  58.         <code>test</code> condition evaluates to true. If none of the <code>test</code> conditions
  59.         of its nested <code>when</code> tags evaluate to <code>true</code>, then the body of its
  60.         <code>otherwise</code> tag is evaluated, if present:</p>
  61.      <source>
  62. <choose>
  63.   <when test="XPathExpression">
  64.     body
  65.   </when>+
  66.   <otherwise>
  67.     body
  68.   </otherwise>?
  69. </choose>
  70.      </source>
  71.      <p>Example:</p>
  72.      <source>
  73. <choose>
  74.   <when test="not(user/loggedIn)">
  75.      You're not logged in
  76.   </when>
  77.   <otherwise>
  78.      You're already logged in
  79.   </otherwise>
  80. </choose>
  81.      </source>
  82.     </s2>
  83.     <s2 title="value-of">
  84.      <p>The <code>value-of</code> tag evaluates an expression and outputs the result of the evaluation:</p>
  85.      <source>
  86. <value-of select="XPathExpression"/>
  87.      </source>
  88.      <p>Example:</p>
  89.      <source>
  90. <value-of select="cart/numberOfItems">
  91.      </source>
  92.     </s2>
  93.     <s2 title="for-each">
  94.      <p>The <code>for-each</code> tag allows you to iterate over a collection of objects:</p>
  95.      <source>
  96. <for-each select="XPathExpression">
  97.   body
  98. </for-each>
  99.      </source>
  100.      <p>When using XPath expressions within <code>for-each</code> the current element is the
  101.         context node and can be referenced with XPath dot operator:</p>
  102.      <source>.</source>
  103.      <p>Example:</p>
  104.      <source>
  105. <for-each select="cart/cartItems[position() <= $count]">
  106.    <td><value-of select="./productId"></td>
  107. </for-each>
  108.      </source>
  109.     </s2>
  110.     <s2 title="continuation">
  111.      <p>The <code>continuation</code> tag returns the id of the current web continuation of your
  112.         Flowscript. You can refer to previous continuations by supplying the optional
  113.         <code>level</code> attribute. Zero is the current level, <code>-1</code> refers to the
  114.         previous continuation, and so on.</p>
  115.      <source>
  116. <continuation [level="Number"]/>
  117.      </source>
  118.      <p>Example:</p>
  119.      <source>
  120. <xsp:attribute name="action"><xsp:expr><jpath:continuation/>+".form"</xsp:expr></xsp:attribute>
  121.      </source>
  122.     </s2>
  123.    </s1>
  124.   </body>
  125. </document>
  126.