cziegeler    2004/05/27 01:23:59

  Modified:    src/java/org/apache/cocoon/generation
                        MP3DirectoryGenerator.java JXTemplateGenerator.java
               src/documentation/xdocs/userdocs/generators
                        linkstatus-generator.xml
  Added:       src/documentation/xdocs/userdocs/generators
                        mp3directory-generator.xml jx-generator.xml
  Log:
  Finished documenting core generators
  
  Revision  Changes    Path
  1.6       +1 -18     
cocoon-2.1/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java
  
  Index: MP3DirectoryGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MP3DirectoryGenerator.java        26 May 2004 14:11:33 -0000      1.5
  +++ MP3DirectoryGenerator.java        27 May 2004 08:23:58 -0000      1.6
  @@ -32,23 +32,6 @@
    * @cocoon.sitemap.component.documentation.caching
    *               Uses the last modification date of the directory and the 
contained files
    * 
  - * <p>
  - * Following extra attributes added to valid MP3 files:
  - * <blockquote>
  - *   <dl>
  - *   <dt> frequency
  - *   <dd> the frequency of the MP3 file in KHz (most common: 44.1)
  - *   <dt> bitrate
  - *   <dd> the bitrate of the MP3 file in Kbit, from 8 to 448.
  - *   <dt> mode
  - *   <dd> the mode of the MP3 file, one of the following: Stereo, Joint 
stereo,
  - *        Dual channel, Single channel.
  - *   <dt> variable-rate (optional)
  - *   <dd> value is "yes" if VBR header is detected
  - *   <dt> title, artitst, album, year, comment, track, genre (all optional)
  - *   <dd> values obtained from MP3 ID3 tag
  - *   </dl>
  - * </blockquote>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a>
    * @version CVS $Id$
  
  
  
  1.44      +1 -230    
cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
  
  Index: JXTemplateGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- JXTemplateGenerator.java  26 May 2004 14:11:33 -0000      1.43
  +++ JXTemplateGenerator.java  27 May 2004 08:23:58 -0000      1.44
  @@ -109,235 +109,6 @@
    * @cocoon.sitemap.component.pooling.max  16
    * @cocoon.sitemap.component.pooling.grow  2
    * 
  - * <p>(<em>JX</em> for <a 
href="http://jakarta.apache.org/commons/jxpath";>Apache <em>JX</em>Path</a>
  - * and <a href="http://jakarta.apache.org/commons/jexl";>Apache 
<em>J</em>e<em>x</em>l</a>).</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>
  - * The embedded expression language allows a page author to access an
  - * object using a simplified syntax such as
  - *
  - *  <p><pre>
  - *  &lt;site signOn="${accountForm.signOn}"&gt;
  - *  </pre></p>
  - *
  - * <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 generator uses
  - * <a href="http://jakarta.apache.org/commons/jxpath";>Apache JXPath</a>
  - * and <a href="http://jakarta.apache.org/commons/jexl";>Apache Jexl</a>, 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>
  - * <p>
  - * <dl>
  - * <dt><code>request</code> 
(<code>org.apache.cocoon.environment.Request</code>)</dt>
  - * <dd>The Cocoon current request</dd>
  - *
  - * <dt><code>session</code> 
(<code>org.apache.cocoon.environment.Session</code>)</dt>
  - * <dd>The Cocoon session associated with the current request</dd>
  - *
  - * <dt><code>context</code> 
(<code>org.apache.cocoon.environment.Context</code>)</dt>
  - * <dd>The Cocoon context associated with the current request</dd>
  - *
  - * <dt><code>parameters</code> 
(<code>org.apache.avalon.framework.parameters.Parameters</code>)</dt>
  - * <dd>A map of parameters passed to the generator in the pipeline</dd>
  - * </dl>
  - * </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><pre>
  - *    &lt;form action="${continuation.id}"&gt;
  - * </pre></p>
  - *
  - * <p>You can also reach previous continuations by using the
  - * <code>getContinuation()</code> function:</p>
  - *
  - * <p><pre>
  - *     &lt;form action="${continuation.getContinuation(1).id}" >
  - * </pre></p>
  - *
  - * <p>
  - * <p>The <code>template</code> tag defines a new template:</p><pre>
  - *    &lt;template&gt;
  - *        body
  - *    &lt;/template&gt;
  - * </pre></p>
  - *
  - * <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><pre>
  - *    &lt;import uri="URI" [context="Expression"]/&gt;
  - * </pre></p><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>
  - *
  - * <pre>
  - *    &lt;set var="Name" [value="Value"]&gt;
  - *        [body]
  - *    &lt;/set&gt;
  - * </pre></p>
  - *
  - * <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>
  - *
  - * <p><pre>
  - *   &lt;if test="Expression"&gt;
  - *       body
  - *   &lt;/if&gt;
  - * </pre></p>
  - *
  - * <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>
  - *
  - * <p><pre>
  - *  &lt;choose&gt;
  - *    &lt;when test="Expression"&gt;
  - *       body
  - *    &lt;/when&gt;
  - *    &lt;otherwise&gt;
  - *       body
  - *    &lt;/otherwise&gt;
  - *  &lt;/choose&gt;
  - * </pre></p>
  - *
  - * <p>The <code>out</code> tag evaluates an expression and outputs
  - * the result of the evaluation:</p>
  - *
  - * <p><pre>
  - * &lt;out value="Expression"/&gt;
  - * </pre></p>
  - *
  - * <p>The <code>forEach</code> tag allows you to iterate over a collection
  - * of objects:<p>
  - *
  - * <p><pre>
  - *   &lt;forEach [var="Name"] [items="Expression"]
  -                 [begin="Number"] [end="Number"] [step="Number"]&gt;
  - *     body
  - *  &lt;/forEach&gt;
  - * </pre></p>
  - *
  - * <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>
  - * <p>
  - * &lt;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"]&gt;
  - * </p>
  - *
  - * <p>The <code>formatDate</code> tag provides facilities to format Date 
values:</p>
  - * <p>
  - * &lt;formatDate value="Expression" [dateStyle="Style"]
  - *   [timeStyle="Style"] [pattern="Expression"] [type="Type"] [var="Name"]
  - *   [locale="Expression"]&gt;
  - * </p>
  - *
  - * <p>The <code>macro</code> tag allows you define a new custom tag.</p>
  - *
  - * <p><pre>
  - * &lt;macro name="Name" [targetNamespace="Namespace"]&gt;
  - *   &lt;parameter name="Name" [optional="Boolean"] [default="Value"]/&gt;*
  - *   body
  - * &lt/macro&gt;
  - * </pre></p>
  - *
  - *<p>For example:</p>
  - *
  - *<p><pre>
  - * &lt;c:macro name="d"&gt;
  - *   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  - * &lt;/c:macro&gt;
  - * </pre></p>
  - *
  - * <p>The tag being defined in this example is <code>&lt;d&gt;</code> and it
  - * can be used like any other tag:</p>
  - *
  - * <p><pre>
  - *   &lt;d/&gt;
  - * </pre></p>
  - *
  - * <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>
  - *
  - * <p><pre>
  - * &lt;c:macro name="tablerows"&gt;
  - *   &lt;c:parameter name="list"/&gt;
  - *   &lt;c:parameter name="color"/&gt;
  - *   &lt;c:forEach var="item" items="${list}"&gt;
  - *     &lt;tr&gt;&lt;td bgcolor="${color}"&gt;${item}&lt;/td&gt;&lt;/tr&gt;
  - *   &lt;/c:forEach&gt;
  - * &lt;/c:macro&gt;
  - * </pre></p>
  - *
  - * <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>
  - * <code>var greatlakes = ["Superior", "Michigan", "Huron", "Erie", 
"Ontario"];</code>
  - * </p><p><code> sendPage(uri, {greatlakes: greatlakes});</code>
  - * </p><p>and a template like this:</p>
  - *
  - * <p><pre>
  - * &lt;table&gt;
  - *    &lt;tablerows list="${greatlakes}" color="blue"/&gt;
  - * &lt;/table&gt;
  - * </pre></p>
  - *
  - * <p>When the <code>tablerows</code> tag is used in this situation the
  - * following output would be generated:
  - * </p>
  - *<p><pre>
  - * &lt;table&gt;
  - *   &lt;tr&gt;&lt;td bgcolor="blue"&gt;Superior&lt;/td&gt;&lt;/tr&gt;
  - *   &lt;tr&gt;&lt;td bgcolor="blue"&gt;Michigan&lt;/td&gt;&lt;/tr&gt;
  - *   &lt;tr&gt;&lt;td bgcolor="blue"&gt;Huron&lt;/td&gt;&lt;/tr&gt;
  - *   &lt;tr&gt;&lt;td bgcolor="blue"&gt;Erie&lt;/td&gt;&lt;/tr&gt;
  - *   &lt;tr&gt;&lt;td bgcolor="blue"&gt;Ontario&lt;/td&gt;&lt;/tr&gt;
  - * &lt;/table&gt;
  - * </pre></p>
    *
    * @version CVS $Id$
    */
  
  
  
  1.7       +1 -6      
cocoon-2.1/src/documentation/xdocs/userdocs/generators/linkstatus-generator.xml
  
  Index: linkstatus-generator.xml
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/generators/linkstatus-generator.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- linkstatus-generator.xml  26 May 2004 14:11:34 -0000      1.6
  +++ linkstatus-generator.xml  27 May 2004 08:23:58 -0000      1.7
  @@ -30,7 +30,7 @@
    <body>
     <s1 title="LinkStatus Generator">
      <p>
  -    The LinkStatus Generator emits a list of links that are reachable. 
Please note that it is available only in Cocoon 2.1.
  +    The LinkStatus Generator emits a list of links that are reachable. 
      </p>
      <p>
       The LinkStatusGenerator has serveral configuration options.
  @@ -74,11 +74,6 @@
        <dt>accept</dt>
        <dd>Not currently used</dd>
      </dl>
  -   <ul>
  -    <li>Name : linkStatus</li>
  -    <li>Class: org.apache.cocoon.generation.LinkStatusGenerator</li>
  -    <li>Cacheable: no.</li>
  -   </ul>
      <p>
       A simple example might help to use the LinkStatusGenerator effectivly:
      </p>
  
  
  
  1.1                  
cocoon-2.1/src/documentation/xdocs/userdocs/generators/mp3directory-generator.xml
  
  Index: mp3directory-generator.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!--
    Copyright 1999-2004 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 mp3directory generator</title>
      <version>current</version>
      <type>Reference</type>
      <authors>
        <person email="[email protected]" name="The Cocoon Community"/>
      </authors>
    </header>
    <body>
      <s1 title="MP3DirectoryGenerator">
   <p>
    Following extra attributes added to valid MP3 files:</p>
   <ul>
   <li><em>frequency</em> : the frequency of the MP3 file in KHz (most common: 
44.1)</li>
   <li><em>bitrate</em> : the bitrate of the MP3 file in Kbit, from 8 to 
448.</li>
   <li><em>mode</em> : the mode of the MP3 file, one of the following: Stereo, 
            Joint stereo, Dual channel, Single channel.</li>
   <li><em>variable-rate</em> (optional) : value is "yes" if VBR header is 
detected.</li>
   <li><em>title, artitst, album, year, comment, track, genre</em> (all 
optional) : 
         values obtained from MP3 ID3 tag.</li>
     </ul>
      </s1>
    </body>
  </document>
  
  
  
  1.1                  
cocoon-2.1/src/documentation/xdocs/userdocs/generators/jx-generator.xml
  
  Index: jx-generator.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!--
    Copyright 1999-2004 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 generator</title>
      <version>current</version>
      <type>Reference</type>
      <authors>
        <person email="[email protected]" name="The Cocoon Community"/>
      </authors>
    </header>
    <body>
      <s1 title="JX Generator">
        <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>
     &lt;site signOn="${accountForm.signOn}"&gt;
  </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 generator 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 generator 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>      
       &lt;form action="${continuation.id}"&gt;
  </source>      
  
    <p>You can also reach previous continuations by using the
    <code>getContinuation()</code> function:</p>
   
  <source>      
        &lt;form action="${continuation.getContinuation(1).id}" >
  </source>      
   <p>The <code>template</code> tag defines a new template:</p>
  <source>      
       &lt;template&gt;
          body
       &lt;/template&gt;
  </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>
      &lt;import uri="URI" [context="Expression"]/&gt;
  </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>      
       &lt;set var="Name" [value="Value"]&gt;
           [body]
       &lt;/set&gt;
  </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>      
      &lt;if test="Expression"&gt;
          body
      &lt;/if&gt;
  </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>      
     &lt;choose&gt;
       &lt;when test="Expression"&gt;
          body
       &lt;/when&gt;
       &lt;otherwise&gt;
          body
       &lt;/otherwise&gt;
     &lt;/choose&gt;
  </source>      
    <p>The <code>out</code> tag evaluates an expression and outputs
    the result of the evaluation:</p>
  <source>      
    &lt;out value="Expression"/&gt;
  </source>      
    <p>The <code>forEach</code> tag allows you to iterate over a collection
    of objects:</p>
  <source>      
      &lt;forEach [var="Name"] [items="Expression"]
                   [begin="Number"] [end="Number"] [step="Number"]&gt;
        body
     &lt;/forEach&gt;
  </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>      
    &lt;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"]&gt;
  </source>      
   
    <p>The <code>formatDate</code> tag provides facilities to format Date 
values:</p>
  <source>      
    &lt;formatDate value="Expression" [dateStyle="Style"]
      [timeStyle="Style"] [pattern="Expression"] [type="Type"] [var="Name"]
      [locale="Expression"]&gt;
  </source>      
   
    <p>The <code>macro</code> tag allows you define a new custom tag.</p>
   
  <source>      
    &lt;macro name="Name" [targetNamespace="Namespace"]&gt;
      &lt;parameter name="Name" [optional="Boolean"] [default="Value"]/&gt;
      body
    &lt;/macro&gt;
  </source>      
   
   <p>For example:</p>
   
  <source>      
    &lt;c:macro name="d"&gt;
      &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;/c:macro&gt;
  </source>      
   
    <p>The tag being defined in this example is <code>&lt;d&gt;</code> and it
    can be used like any other tag:</p>
   
  <source>      
      &lt;d/&gt;
  </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>      
    &lt;c:macro name="tablerows"&gt;
      &lt;c:parameter name="list"/&gt;
      &lt;c:parameter name="color"/&gt;
      &lt;c:forEach var="item" items="${list}"&gt;
        &lt;tr&gt;&lt;td bgcolor="${color}"&gt;${item}&lt;/td&gt;&lt;/tr&gt;
      &lt;/c:forEach&gt;
    &lt;/c:macro&gt;
  </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>      
       &lt;tablerows list="${greatlakes}" color="blue"/&gt;
    &lt;/table&gt;
  </source>      
   
    <p>When the <code>tablerows</code> tag is used in this situation the
    following output would be generated:
    </p>
  <source>      
    &lt;table&gt;
      &lt;tr&gt;&lt;td bgcolor="blue"&gt;Superior&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td bgcolor="blue"&gt;Michigan&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td bgcolor="blue"&gt;Huron&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td bgcolor="blue"&gt;Erie&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td bgcolor="blue"&gt;Ontario&lt;/td&gt;&lt;/tr&gt;
    &lt;/table&gt;
  </source>
      </s1>
    </body>
  </document>
  
  
  

Reply via email to