Author: crossley
Date: Sun Feb 13 22:13:35 2005
New Revision: 153723
URL: http://svn.apache.org/viewcvs?view=rev&rev=153723
Log:
Add some documentation for " JX Template Transformer".
Submitted by: Torsten Schlabach
Issue: 33526 "JXTranformer missing in documentation"
Added:
cocoon/trunk/src/documentation/xdocs/userdocs/transformers/jx-template-transformer.xml
(with props)
Modified:
cocoon/trunk/src/documentation/xdocs/userdocs/transformers/book.xml
cocoon/trunk/src/documentation/xdocs/userdocs/transformers/transformers.xml
Modified: cocoon/trunk/src/documentation/xdocs/userdocs/transformers/book.xml
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/documentation/xdocs/userdocs/transformers/book.xml?view=diff&r1=153722&r2=153723
==============================================================================
--- cocoon/trunk/src/documentation/xdocs/userdocs/transformers/book.xml
(original)
+++ cocoon/trunk/src/documentation/xdocs/userdocs/transformers/book.xml Sun Feb
13 22:13:35 2005
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!--
- Copyright 1999-2004 The Apache Software Foundation
+ Copyright 1999-2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@
<menu-item label="EncodeURL Transformer"
href="encodeurl-transformer.html"/>
<menu-item label="SourceWriting Transformer"
href="sourcewriting-transformer.html"/>
<menu-item label="Augment Transformer" href="augment-transformer.html"/>
+ <menu-item label="JX Template Transformer"
href="jx-template-transformer.html"/>
</menu>
<menu label="Optional">
<menu-item label="LDAP Transformer" href="ldap-transformer.html"/>
Added:
cocoon/trunk/src/documentation/xdocs/userdocs/transformers/jx-template-transformer.xml
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/documentation/xdocs/userdocs/transformers/jx-template-transformer.xml?view=auto&rev=153723
==============================================================================
---
cocoon/trunk/src/documentation/xdocs/userdocs/transformers/jx-template-transformer.xml
(added)
+++
cocoon/trunk/src/documentation/xdocs/userdocs/transformers/jx-template-transformer.xml
Sun Feb 13 22:13:35 2005
@@ -0,0 +1,269 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 1999-2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN"
"document-v10.dtd">
+<document>
+ <!-- This document will be enhanced by information taken from the javadoc -->
+ <header>
+ <title>Description of the JX transformer</title>
+ <version>current</version>
+ <type>Reference</type>
+ <authors>
+ <person email="[email protected]" name="The Cocoon Community"/>
+ </authors>
+ </header>
+ <body>
+ <s1 title="JX Transformer">
+ <p>
+ (<em>JX</em> for <link
href="http://jakarta.apache.org/commons/jxpath">Apache <em>JX</em>Path</link>
+ and <link href="http://jakarta.apache.org/commons/jexl">Apache
<em>J</em>e<em>x</em>l</link>).
+ </p>
+ <p>
+ Uses the namespace
<code>http://apache.org/cocoon/templates/jx/1.0</code>.
+ </p>
+ <p>
+ Provides a generic page template with embedded JSTL and XPath
+ expression substitution to access data sent by Cocoon Flowscripts.
+ </p>
+ <p>
+ The embedded expression language allows a page author to access an
+ object using a simplified syntax such as
+ </p>
+<source>
+ <site signOn="${accountForm.signOn}">
+</source>
+ <p>
+ Embedded JSTL expressions are contained in <code>${}</code>.
+ </p>
+ <p>
+ Embedded XPath expressions are contained in <code>#{}</code>.
+ </p>
+ <p>
+ Note that since this transformer uses
+ <link href="http://jakarta.apache.org/commons/jxpath">Apache
JXPath</link>
+ and <link href="http://jakarta.apache.org/commons/jexl">Apache
Jexl</link>, the
+ referenced objects may be Java Beans, DOM, JDOM, or JavaScript objects
from
+ a Flowscript. In addition the following implicit objects are available
as
+ both XPath and JSTL variables:
+ </p>
+ <table>
+ <tr>
+ <td><code>request</code>
(<code>org.apache.cocoon.environment.Request</code>)</td>
+ <td>The Cocoon current request</td>
+ </tr>
+ <tr>
+ <td><code>session</code>
(<code>org.apache.cocoon.environment.Session</code>)</td>
+ <td>The Cocoon session associated with the current request</td>
+ </tr>
+ <tr>
+ <td><code>context</code>
(<code>org.apache.cocoon.environment.Context</code>)</td>
+ <td>The Cocoon context associated with the current request</td>
+ </tr>
+ <tr>
+ <td><code>parameters</code>
(<code>org.apache.avalon.framework.parameters.Parameters</code>)</td>
+ <td>A map of parameters passed to the transformer in the
pipeline</td>
+ </tr>
+ </table>
+ <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}">
+</source>
+
+ <p>You can also reach previous continuations by using the
+ <code>getContinuation()</code> function:</p>
+
+<source>
+ <form action="${continuation.getContinuation(1).id}" >
+</source>
+ <p>The <code>template</code> tag defines a new template:</p>
+<source>
+ <template>
+ body
+ </template>
+</source>
+
+ <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"]/>
+</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>
+ <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>
+</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>The <code>if</code> tag allows the conditional execution of its body
+ according to value of a <code>test</code> attribute:</p>
+
+<source>
+ <if test="Expression">
+ body
+ </if>
+</source>
+ <p>The <code>choose</code> tag performs conditional block execution by the
+ embedded <code>when</code> sub tags. It renders the body of the first
+ <code>when</code> tag whose <code>test</code> condition evaluates to true.
+ If none of the <code>test</code> conditions of nested <code>when</code> tags
+ evaluate to <code>true</code>, then the body of an <code>otherwise</code>
+ tag is evaluated, if present:</p>
+<source>
+ <choose>
+ <when test="Expression">
+ body
+ </when>
+ <otherwise>
+ body
+ </otherwise>
+ </choose>
+</source>
+ <p>The <code>out</code> tag evaluates an expression and outputs
+ the result of the evaluation:</p>
+<source>
+ <out value="Expression"/>
+</source>
+ <p>The <code>forEach</code> tag allows you to iterate over a collection
+ of objects:</p>
+<source>
+ <forEach [var="Name"] [items="Expression"]
+ [begin="Number"] [end="Number"] [step="Number"]>
+ body
+ </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, ...).
+ If unspecified it defaults to <code>0</code>. The <code>end</code>
+ attribute specifies the item to end with (<code>0</code> = first item,
+ <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>
+ The <code>formatNumber</code> tag is used to display numeric data, including
+ currencies and percentages, in a locale-specific manner. The
+ <code>formatNumber</code> action 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"
+ [type="Type"] [pattern="Expression"]
+ [currencyCode="Expression"] [currencySymbol="Expression"]
+ [maxIntegerDigits="Expression"] [minIntegerDigits="Expression"]
+ [maxFractionDigits="Expression"] [minFractionDigits="Expression"]
+ [groupingUsed="Expression"]
+ [var="Name"] [locale="Expression"]>
+</source>
+
+ <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"]>
+</source>
+
+ <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"]/>
+ body
+ </macro>
+</source>
+
+ <p>For example:</p>
+
+<source>
+ <c:macro name="d">
+ <tr><td></td></tr>
+ </c: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/>
+</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}">
+ <tr><td bgcolor="${color}">${item}</td></tr>
+ </c:forEach>
+ </c: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"];</source>
+ <p><code> sendPage(uri, {greatlakes: greatlakes});</code>
+ </p>
+ <p>and a template like this:</p>
+
+<source>
+ <tablerows list="${greatlakes}" color="blue"/>
+ </table>
+</source>
+
+ <p>When the <code>tablerows</code> tag is used in this situation the
+ following output would be generated:
+ </p>
+<source>
+ <table>
+ <tr><td bgcolor="blue">Superior</td></tr>
+ <tr><td bgcolor="blue">Michigan</td></tr>
+ <tr><td bgcolor="blue">Huron</td></tr>
+ <tr><td bgcolor="blue">Erie</td></tr>
+ <tr><td bgcolor="blue">Ontario</td></tr>
+ </table>
+</source>
+ </s1>
+ </body>
+</document>
Propchange:
cocoon/trunk/src/documentation/xdocs/userdocs/transformers/jx-template-transformer.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
cocoon/trunk/src/documentation/xdocs/userdocs/transformers/transformers.xml
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/documentation/xdocs/userdocs/transformers/transformers.xml?view=diff&r1=153722&r2=153723
==============================================================================
--- cocoon/trunk/src/documentation/xdocs/userdocs/transformers/transformers.xml
(original)
+++ cocoon/trunk/src/documentation/xdocs/userdocs/transformers/transformers.xml
Sun Feb 13 22:13:35 2005
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright 1999-2004 The Apache Software Foundation
+ Copyright 1999-2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -57,6 +57,7 @@
<li><link href="encodeurl-transformer.html">EncodeURL Transformer</link></li>
<li><link href="sourcewriting-transformer.html">SourceWriting
Transformer</link></li>
<li><link href="augment-transformer.html">Augment Transformer</link></li>
+ <li><link href="jx-template-transformer.html">JX Template
Transformer</link></li>
<li><link href="ldap-transformer.html">LDAP Transformer</link>
(optional)</li>
<li><link href="lexer-transformer.html">Lexical Transformer</link>
(optional)</li>
<li><link href="parser-transformer.html">Parser Transformer</link>
(optional)</li>