sylvain 2003/09/09 11:58:29
Modified: src/documentation/xdocs/userdocs/advanced/flow
jxtemplate.xml
Log:
Add namespace prefixes for jxtemplate tags
Revision Changes Path
1.5 +74 -74
cocoon-2.1/src/documentation/xdocs/userdocs/advanced/flow/jxtemplate.xml
Index: jxtemplate.xml
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/advanced/flow/jxtemplate.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- jxtemplate.xml 2 Sep 2003 13:53:10 -0000 1.4
+++ jxtemplate.xml 9 Sep 2003 18:58:29 -0000 1.5
@@ -31,7 +31,7 @@
Having an embedded expression language allows a page author to access an
object using a simple syntax such as
</p>
<source>
- <site signOn="${accountForm.signOn}">
+<site signOn="${accountForm.signOn}">
</source>
<p>Embedded Jexl expressions are contained in <code>${}</code>.</p>
<p>Embedded JXPath expressions are contained in <code>#{}</code>.</p>
@@ -57,27 +57,27 @@
<p>
Jexl Example:</p>
<source>
- The content type of the current request is ${request.contentType}
+The content type of the current request is ${request.contentType}
</source>
<p>
JXPath Example:</p>
<source>
- The content type of the current request is #{$request/contentType}
+The content type of the current request is #{$request/contentType}
</source>
<p>
The current Web Continuation from the Flowscript
is also available as a variable named <code>continuation</code>. You would
typically access its <code>id</code>:</p>
<source>
- <form action="${continuation.id}">
+<form action="${continuation.id}">
</source>
<p>You can also reach previous continuations by using the
<code>getParent()</code> function:</p>
<source>
- <form action="${continuation.getParent().id}" >
+<form action="${continuation.getParent().id}" >
</source>
<p>or using an XPath expression:</p>
<source>
- <form action="#{getParent($continuation)/id}" >
+<form action="#{getParent($continuation)/id}" >
</source>
</s1>
<s1 title ="Tags">
@@ -87,30 +87,30 @@
</source>
<s2 title ="template">
<p>The <code>template</code> tag defines a new template:</p><source>
- <t:template xmlns:t="http://apache.org/cocoon/templates/jx/1.0">
- body
- </t:template>
+<jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+ body
+</jx:template>
</source>
<p/>
</s2>
<s2 title ="import"/>
<p>The <code>import</code> tag allows you to include another template within
the current template. The content of the imported template is compiled and will
be executed in place of the <code>import</code> tag:</p><source>
- <import uri="URI" [context="Expression"]/>
+<jx:import uri="URI" [context="Expression"]/>
</source><p>The Cocoon source resolver is used to resolve <code>uri</code>.
If <code>context</code> is present, then its value is used as the context for
evaluating the imported template, otherwise the current context is used.</p>
<s2 title ="set">
<p>The <code>set</code> tag creates a local alias of an object. The
<code>var</code> attribute specifies the name of a variable to assign the
object to. The <code>value</code> attribute specifies the object (defaults to
<code>body</code> if not present):</p><source>
- <set var="Name" [value="Value"]>
- [body]
- </set>
+<jx:set var="Name" [value="Value"]>
+ [body]
+</jx:set>
</source><p>If used within a <code>macro</code> definition (see below)
variables created by <code>set</code> are only visible within the body of the
<code>macro</code>.</p>
<p>Jexl Example:</p>
<source>
-<set var="greeting" value="Hello ${user}"/>
+<jx:set var="greeting" value="Hello ${user}"/>
The value of greeting is ${greeting}
</source>
<p>JXPath Example:</p>
<source>
-<set var="greeting" value="Hello #{user}"/>
+<jx:set var="greeting" value="Hello #{user}"/>
The value of greeting is #{$greeting}
</source>
<p/>
@@ -119,22 +119,22 @@
<p>The <code>if</code> tag allows the conditional execution of its body
according to value of its <code>test</code> attribute:</p>
<source>
- <if test="Expression">
- body
- </if>
+<jx:if test="Expression">
+ body
+</jx:if>
</source>
<p>Jexl Example:</p>
<source>
-<if test="${cart.numberOfItems == 0}">
+<jx:if test="${cart.numberOfItems == 0}">
Your cart is empty
-</if>
+</jx:if>
</source>
<p/>
<p>JXPath Example:</p>
<source>
-<if test="#{cart/numberOfItems = 0}">
+<jx:if test="#{cart/numberOfItems = 0}">
Your cart is empty
-</if>
+</jx:if>
</source>
<p/>
</s2>
@@ -146,37 +146,37 @@
evaluate to <code>true</code>, then the body of its <code>otherwise</code>
tag is evaluated, if present:</p>
<source>
- <choose>
- <when test="Expression">
- body
- </when>+
- <otherwise>
- body
- </otherwise>?
- </choose>
+<jx:choose>
+ <jx:when test="Expression">
+ body
+ </jx:when>+
+ <jx:otherwise>
+ body
+ </jx:otherwise>?
+</jx:choose>
</source>
<p>Jexl Example:</p>
<source>
-<choose>
- <when test="${!user.loggedIn}">
- <set var="label" value="Log in">
- </when>
- <otherwise>
- <set var="label" value="Log out">
- </otherwise>
-</choose>
+<jx:choose>
+ <jx:when test="${!user.loggedIn}">
+ <jx:set var="label" value="Log in">
+ </jx:when>
+ <jx:otherwise>
+ <jx:set var="label" value="Log out">
+ </jx:otherwise>
+</jx:choose>
</source>
<p/>
<p>JXPath Example:</p>
<source>
-<choose>
- <when test="#{not(user/loggedIn)}">
- <set var="label" value="Log in">
- </when>
- <otherwise>
- <set var="label" value="Log out">
- </otherwise>
-</choose>
+<jx:choose>
+ <jx:when test="#{not(user/loggedIn)}">
+ <jx:set var="label" value="Log in">
+ </jx:when>
+ <jx:otherwise>
+ <jx:set var="label" value="Log out">
+ </jx:otherwise>
+</jx:choose>
</source>
<p/>
</s2>
@@ -184,15 +184,15 @@
<p>The <code>out</code> tag evaluates an expression and outputs
the result of the evaluation:</p>
<source>
-<out value="Expression"/>
+<jx:out value="Expression"/>
</source>
<p>Jexl Example:</p>
<source>
-<out value="${cart.numberOfItems}">
+<jx:out value="${cart.numberOfItems}">
</source>
<p>JXPath Example:</p>
<source>
-<out value="#{cart/numberOfItems}">
+<jx:out value="#{cart/numberOfItems}">
</source>
<p/>
</s2>
@@ -200,9 +200,9 @@
<p>The <code>forEach</code> tag allows you to iterate over a collection
of objects:</p>
<source>
- <forEach [var="Name"] [items="Expression"] [begin="NumExpr"]
[end="NumExpr"] [step="NumExpr"]>
- body
- </forEach>
+<jx:forEach [var="Name"] [items="Expression"] [begin="NumExpr"]
[end="NumExpr"] [step="NumExpr"]>
+ body
+</jx:forEach>
</source>
<p>The <code>items</code> attribute specifies the list of items to iterate
over. The <code>var</code> attribute specifies the name of a variable to hold
the current item. The <code>begin</code> attribute specifies the element to
start with
(<code>0</code> = first item, <code>1</code> = second item, ...).
@@ -212,24 +212,24 @@
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>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>
-<forEach select="XPathExpression">
+<jx:forEach select="XPathExpression">
body
-</forEach>
+</jx:forEach>
</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>
-<forEach var="item" items="${cart.cartItems} begin="${start}"
end="${count-start}" step="1"">
+<jx:forEach var="item" items="${cart.cartItems} begin="${start}"
end="${count-start}" step="1"">
<td>${item.productId}</td>
-</forEach>
+</jx:forEach>
</source>
<p/>
<p>JXPath Example:</p>
<source>
-<forEach select="#{cart/cartItems[position() &lt;= $count]}}>
+<jx:forEach select="#{cart/cartItems[position() &lt;= $count]}}>
<td>#{./productId}</td>
-</forEach>
+</jx:forEach>
</source>
<p/>
</s2>
@@ -238,7 +238,7 @@
The <code>formatNumber</code> tag is used to display numeric data, including
currencies and percentages, in a locale-specific manner. It determines from the
locale, for example, whether to use a period or a comma for delimiting the
integer and decimal portions of a number. Here is its syntax:
</p>
<source>
-<formatNumber value="Expression"
+<jx:formatNumber value="Expression"
[type="Type"] [pattern="Expression"]
[currencyCode="Expression"] [currencySymbol="Expression"]
[maxIntegerDigits="Expression"] [minIntegerDigits="Expression"]
@@ -269,9 +269,9 @@
<s2 title="formatDate">
<p>The <code>formatDate</code> tag provides facilities to format Date
values:</p>
<source>
-<formatDate value="Expression" [dateStyle="Style"]
- [timeStyle="Style"] [pattern="Expression"] [type="Type"] [var="Name"]
- [locale="Expression"]>
+<jx:formatDate value="Expression" [dateStyle="Style"]
+ [timeStyle="Style"] [pattern="Expression"] [type="Type"] [var="Name"]
+ [locale="Expression"]>
</source>
<p>
Only the value attribute is required. Its value should be an instance of the
<code>java.util.Date</code> class, specifying the date and/or time data to be
formatted and displayed.</p>
@@ -292,29 +292,29 @@
</s2>
<s2 title="macro">
<p>The <code>macro</code> tag allows you define a new custom tag.</p><source>
-<macro name="Name" [targetNamespace="Namespace"]>
- <parameter name="Name" [optional="Boolean"] [default="Value"]/>*
+<jx:macro name="Name" [targetNamespace="Namespace"]>
+ <jx:parameter name="Name" [optional="Boolean"] [default="Value"]/>*
body
-</macro>
+</jx:macro>
</source>
<p> For example:</p><source>
-<c:macro name="d">
+<jx:macro name="d">
<tr><td></td></tr>
-</c:macro>
+</jx:macro>
</source>
<p>The tag being defined in this example is <code><d></code> and it
can be used like any other tag:</p><source>
- <d/>
+<d/>
</source>
<p>However, when this tag is used it will be replaced with a row containing
a single empty data cell.</p>
<p> When such a tag is used, the attributes and content of the tag become
available as variables in the body of the <code>macro</code>'s definition, for
example:</p><source>
-<c:macro name="tablerows">
- <c:parameter name="list"/>
- <c:parameter name="color"/>
- <c:forEach var="item" items="${list}">
+<jx:macro name="tablerows">
+ <jx:parameter name="list"/>
+ <jx:parameter name="color"/>
+ <jx:forEach var="item" items="${list}">
<tr><td bgcolor="${color}">${item}</td></tr>
- </c:forEach>
-</c:macro>
+ </jx:forEach>
+</jx:macro>
</source>
<p>The <code>parameter</code> tags in the macro definition define formal
parameters, which are replaced with the actual attribute values of the tag when
it is used. The content of the tag is also available as a special variable
<code>${content}</code>.</p><p>Assuming you had this code in your
flowscript:</p>
<source>var greatlakes = ["Superior", "Michigan", "Huron", "Erie",
"Ontario"];