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 / script-generator.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  8.3 KB  |  264 lines

  1. <?xml version="1.0"?>
  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. <!--
  19.   <![CDATA[ CVS Version: $Id: script-generator.xml,v 1.8 2004/05/08 08:57:57 crossley Exp $ 
  20.   ]]>
  21. --><document>
  22.   <header>
  23.     <title>ScriptGenerator in Cocoon</title>
  24.     <version>0.9</version>
  25.     <type>Technical document</type>
  26.     <authors>
  27.       <person email="huber@apache.org" name="Bernhard Huber" />
  28.     </authors>
  29.     <abstract>This document describes the <code>ScriptGenerator</code> of
  30.     Cocoon.</abstract>
  31.   </header>
  32.   <body>
  33.     <s1 title="ScriptGenerator">
  34.       <table>
  35.         <tr>
  36.           <td>NAME</td>
  37.           <td>script</td>
  38.         </tr>
  39.         <tr>
  40.           <td>WHAT</td>
  41.           <td>The <code>ScriptGenerator</code> component is used to generate
  42.           XML by invoking a script.</td>
  43.         </tr>
  44.         <tr>
  45.           <td>TYPE</td>
  46.           <td>Generator, Sitemap Component</td>
  47.         </tr>
  48.         <tr>
  49.           <td>BLOCK</td>
  50.           <td>bsf</td>
  51.         </tr>
  52.         <tr>
  53.           <td>CLASS</td>
  54.           <td>org.apache.cocoon.generation.ScriptGenerator</td>
  55.         </tr>
  56.         <tr>
  57.           <td>SINCE</td>
  58.           <td>Cocoon 2.1</td>
  59.         </tr>
  60.         <tr>
  61.           <td>CACHEABLE</td>
  62.           <td>no</td>
  63.         </tr>
  64.       </table>
  65.     </s1>
  66.     <s1 title="Description">
  67.       <p>The ScriptGenerator executes arbitrary scripts using the BSF
  68.       framework and additional interpreter (Rhino, Jython, etc.) as a Cocoon
  69.       Generator.</p>
  70.     </s1>
  71.     <s1 title="Usage">
  72.       <p>The ScriptGenerator is used primarily for prototyping a Cocoon
  73.       generator. Moreover if the generator's XML output is low and the
  74.       logic processing is high.</p>
  75.       <s2 title="Sitemap pipeline examples">
  76.         <p>The following sample uses the ScriptGenerator for generating XML
  77.         content for URIs matching the pattern <code>*.js</code>. The output of
  78.         the script invoked by ScriptGenerator is serialized by the default
  79.         serializer.</p>
  80.         <source>
  81. <map:match pattern="*.js">
  82.   <map:generate type="script" src="{0}" >
  83.   </map:generate>
  84.   <map:serialize/>
  85. </map:match>
  86.         </source>
  87.       </s2>
  88.       <s2 title="Sitemap component configuration example">
  89.         <p>The following sample declares the ScriptGenerator in the
  90.         sitemap's component section. The ScriptGenerator can be used in
  91.         the sitemap's section using <code>type</code> value <code>script</code>.
  92.         In this sample no extra script language is declared.</p>
  93.         <source>
  94. <map:generators...
  95.   <map:generator name="script" 
  96.     src="org.apache.cocoon.generation.ScriptGenerator"
  97.     logger="sitemap.generation.scriptgenerator" 
  98.   />
  99.     <!-- optional generator configuration -->
  100.     ...
  101. </map:generators>
  102. ...
  103. </source>
  104.       </s2>
  105.       <s2 title="Configuration">
  106.         <p>The ScriptGenerator allows registering additional script languages.</p>
  107.         <p>List the newly registered language inside the <code>add-language</code>
  108.         element, each language is defined in <code>language</code> element, by
  109.         specifying the name of the language using the <code>name</code>
  110.         attribute, and the language BSF adaptor using the attribute
  111.         <code>src</code>.</p>
  112.         <p>Each registered language should be mapped to at least one
  113.         extension, as the language detection of ScriptGenerator is based on
  114.         the script's extension.</p>
  115.         <p>The following sample register an new language foobar, the BSF
  116.         adaptor class is <code>foo.bar.ScriptLanguage</code>, and it is
  117.         associated with the extensions <code>foo</code>, and <code>bar</code>.</p>
  118.         <source><add-language>
  119.   <language name="foobar" src="foo.bar.ScriptLanguage">
  120.     <extension>foo</extension>
  121.     <extension>bar</extension>
  122.   </language>
  123.   ...
  124. </add-language>
  125. </source>
  126.         <p>The next table lists the default mapping of BSF:</p>
  127.         <table>
  128.           <tr>
  129.             <th>Extension</th>
  130.             <th>Script language</th>
  131.           </tr>
  132.           <tr>
  133.             <td>javascript</td>
  134.             <td>js</td>
  135.           </tr>
  136.           <tr>
  137.             <td>jacl</td>
  138.             <td>jacl</td>
  139.           </tr>
  140.           <tr>
  141.             <td>netrexx</td>
  142.             <td>nrx</td>
  143.           </tr>
  144.           <tr>
  145.             <td>java</td>
  146.             <td>java</td>
  147.           </tr>
  148.           <tr>
  149.             <td>javaclass</td>
  150.             <td>class</td>
  151.           </tr>
  152.           <tr>
  153.             <td>bml</td>
  154.             <td>bml</td>
  155.           </tr>
  156.           <tr>
  157.             <td>vbscript</td>
  158.             <td>vbs</td>
  159.           </tr>
  160.           <tr>
  161.             <td>jscript</td>
  162.             <td>jss</td>
  163.           </tr>
  164.           <tr>
  165.             <td>jscript</td>
  166.             <td>jss</td>
  167.           </tr>
  168.           <tr>
  169.             <td>perlscript</td>
  170.             <td>pls</td>
  171.           </tr>
  172.           <tr>
  173.             <td>perl</td>
  174.             <td>pl</td>
  175.           </tr>
  176.           <tr>
  177.             <td>jpython</td>
  178.             <td>py</td>
  179.           </tr>
  180.           <tr>
  181.             <td>lotusscript</td>
  182.             <td>lss</td>
  183.           </tr>
  184.           <tr>
  185.             <td>xslt</td>
  186.             <td>xslt</td>
  187.           </tr>
  188.           <tr>
  189.             <td>pnuts</td>
  190.             <td>pnut</td>
  191.           </tr>
  192.           <tr>
  193.             <td>beanbasic</td>
  194.             <td>bb</td>
  195.           </tr>
  196.         </table>
  197.         <p></p>
  198.       </s2>
  199.       <s2 title="Setup">
  200.         <p>ScriptGenerator registers following objects before invoking the
  201.         script:</p>
  202.         <table>
  203.           <tr>
  204.             <th>Name</th>
  205.             <th>Object Typ</th>
  206.             <th>Comment</th>
  207.           </tr>
  208.           <tr>
  209.             <td>resolver</td>
  210.             <td>Resolver</td>
  211.             <td>Cocoon's resolver</td>
  212.           </tr>
  213.           <tr>
  214.             <td>source</td>
  215.             <td>Source</td>
  216.             <td>src attribute of this ScriptGenerator</td>
  217.           </tr>
  218.           <tr>
  219.             <td>objectModel</td>
  220.             <td>Map</td>
  221.             <td>Cocoon's objectModel</td>
  222.           </tr>
  223.           <tr>
  224.             <td>parameters</td>
  225.             <td>Parameters</td>
  226.             <td>paramters of this ScriptGenerator</td>
  227.           </tr>
  228.           <tr>
  229.             <td>output</td>
  230.             <td>StringBuffer</td>
  231.             <td>XML content, forwarded into Cocoon's XML pipeline</td>
  232.           </tr>
  233.           <tr>
  234.             <td>logger</td>
  235.             <td>Logger</td>
  236.             <td>logger of this ScriptGenerator</td>
  237.           </tr>
  238.         </table>
  239.         <p>The script shall write XML content into the StringBuffer object
  240.         <code>output.</code> The content of <code>output</code> is parsed by
  241.         the ScriptGenerator and forwarded into the sitemap pipeline.</p>
  242.       </s2>
  243.       <s2 title="Effect on Object Model and Sitemap Parameters">
  244.         <p>none</p>
  245.       </s2>
  246.     </s1>
  247.     <s1 title="Bugs/Caveats">
  248.       <p>ScriptGenerator expects the script to write the XML content into the
  249.       passed object <code>output</code>.</p>
  250.       <p>Be aware to provide script language implementation, beside BSF
  251.       implementation.</p>
  252.     </s1>
  253.     <s1 title="History">
  254.       <p>07-24-03: initial creation</p>
  255.     </s1>
  256.     <s1 title="See also">
  257.       <p><!-- Links to related components pages. -->A general documentation
  258.       about generators is available at <link href="../concepts/sitemap.html">generators</link>.</p>
  259.       <p>Further Documentation about BSF is available <link
  260.       href="http://www-124.ibm.com/developerworks/projects/bsf">here</link>.</p>
  261.     </s1>
  262.   </body>
  263. </document>
  264.