You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@apache.org on 2002/08/15 15:43:20 UTC

cvs commit: xml-cocoon2/src/webapp/samples/chaperon/stylesheets java2html.xsl mathexp2html.xsl parsefragment.xsl rgrm2grm.xsl wiki2html.xsl

stephan     2002/08/15 06:43:20

  Modified:    lib      jars.xml
               src/documentation/xdocs/howto book.xml index.xml
               src/documentation/xdocs/userdocs/generators book.xml
                        generators.xml
               src/documentation/xdocs/userdocs/transformers book.xml
                        transformers.xml
               src/webapp/samples samples.xml
  Added:       legal    LICENSE.chaperon
               lib/optional chaperon-1.3-dev.jar
               src/documentation/xdocs/howto/chaperon book.xml
                        howto-chaperon-grm.xml howto-chaperon-intro.xml
                        howto-chaperon-txtgrm.xml
               src/documentation/xdocs/userdocs/generators
                        textparser-generator.xml
               src/documentation/xdocs/userdocs/transformers
                        textparser-transformer.xml
               src/java/org/apache/cocoon/generation
                        TextParserGenerator.java
               src/java/org/apache/cocoon/transformation
                        TextFragmentParserTransformer.java
               src/webapp/samples/chaperon sitemap.xmap
               src/webapp/samples/chaperon/grammars java.rgrm mathexp.grm
                        rgrm.grm wiki.grm wiki.rgrm
               src/webapp/samples/chaperon/misc index.html java.css
                        matex.xsp mathexp.xsp samples.xml test1.java
                        test2.java wiki.xsp
               src/webapp/samples/chaperon/stylesheets java2html.xsl
                        mathexp2html.xsl parsefragment.xsl rgrm2grm.xsl
                        wiki2html.xsl
  Removed:     src/scratchpad/lib LICENSE.chaperon chaperon-1.3-dev.jar
               src/scratchpad/webapp/samples/chaperon sitemap.xmap
               src/scratchpad/webapp/samples/chaperon/grammars java.rgrm
                        mathexp.grm rgrm.grm wiki.grm wiki.rgrm
               src/scratchpad/webapp/samples/chaperon/misc index.html
                        java.css matex.xsp mathexp.xsp test2.java wiki.xsp
               src/scratchpad/webapp/samples/chaperon/stylesheets
                        java2html.xsl mathexp2html.xsl parsefragment.xsl
                        rgrm2grm.xsl wiki2html.xsl
  Log:
  Moved the chaperon components from scratchpad into the stable tree(was long enough there)
  Also added docs and howto.
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/legal/LICENSE.chaperon
  
  Index: LICENSE.chaperon
  ===================================================================
  /*
   * Chaperon. Apache-Style Software License
   *
   *
   * Copyright (c) 2002 Chaperon. All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by 
   *        Chaperon (http://www.sourceforge.net/projects/chaperon/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The name "Chaperon" must not be used to endorse 
   *    or promote products derived from this software without prior written 
   *    permission.  For written permission, please contact 
   *    stephan@vern.chem.tu-berlin.de.
   *
   * 5. Products derived from this software may not be called "Chaperon",
   *    nor may "Chaperon" appear in their name, without prior written
   *    permission of stephan@vern.chem.tu-berlin.de.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE CHAPERON PROJECT OR ITS CONTRIBUTORS 
   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
   * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   */
  
  
  
  1.29      +9 -0      xml-cocoon2/lib/jars.xml
  
  Index: jars.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/lib/jars.xml,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- jars.xml	4 Aug 2002 01:50:25 -0000	1.28
  +++ jars.xml	15 Aug 2002 13:43:18 -0000	1.29
  @@ -315,5 +315,14 @@
   	<lib>optional/spark.jar</lib>
   	<homepage>http://www.tivano.de/software/spark/</homepage>
    </file>
  + <file>
  +  <title>Chaperon Text Parser</title>
  +  <description>chaperon is parser which could parse text files, and convert those
  +        to XML files.
  +  </description>
  +  <used-by>TextParserGenerator and TextFragmentParserTransformer</used-by>
  +  <lib>optional/chaperon-1.3-dev.jar</lib>
  +  <homepage>http://chaperon.sourceforge.net</homepage>
  + </file>
   </jars>
   
  
  
  
  1.1                  xml-cocoon2/lib/optional/chaperon-1.3-dev.jar
  
  	<<Binary file>>
  
  
  1.9       +1 -0      xml-cocoon2/src/documentation/xdocs/howto/book.xml
  
  Index: book.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/howto/book.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- book.xml	3 Jul 2002 20:28:33 -0000	1.8
  +++ book.xml	15 Aug 2002 13:43:18 -0000	1.9
  @@ -17,6 +17,7 @@
       <menu-item label="XMLForm" href="xmlform-wizard/howto-xmlform-wizard.html"/>
       <menu-item label="Paginator" href="howto-paginator-transformer.html"/>
       <menu-item label="HTML-PDF" href="howto-html-pdf-publishing.html"/>
  +    <menu-item label="Chaperon" href="chaperon/howto-chaperon-intro.html"/>
     </menu>
   
     <menu label="Documentation">
  
  
  
  1.10      +1 -0      xml-cocoon2/src/documentation/xdocs/howto/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/howto/index.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- index.xml	3 Jul 2002 20:28:33 -0000	1.9
  +++ index.xml	15 Aug 2002 13:43:18 -0000	1.10
  @@ -24,6 +24,7 @@
   <li><link href="xmlform-wizard/howto-xmlform-wizard.html">XMLForm Wizard</link></li>
   <li><link href="howto-paginator-transformer.html">Paginator Transformer</link></li>
   <li><link href="howto-html-pdf-publishing.html">HTML-PDF Publishing</link></li>
  +<li><link href="chaperon/howto-chaperon-intro.html">Chaperon Text Parser</link></li>
   	</ul>
    </s2>
   
  
  
  
  1.1                  xml-cocoon2/src/documentation/xdocs/howto/chaperon/book.xml
  
  Index: book.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE book PUBLIC "-//APACHE//DTD Cocoon Documentation Book V1.0//EN" "../../dtd/book-cocoon-v10.dtd">
  
  <book software="Apache Cocoon" 
        title="Apache Cocoon Chaperon HowTo" 
        copyright="1999-2002 The Apache Software Foundation"
        xmlns:xlink="http://www.w3.org/1999/xlink">
  
    <menu label="Navigation">
      <menu-item label="Main" href="../../index.html"/>
    </menu>
    
    <menu label="How-Tos">
      <menu-item label="Index" href="../index.html"/>
    </menu>
    
    <menu label="Chaperon Parser">
      <menu-item label="Introduction" href="howto-chaperon-intro.html"/>
      <menu-item label="XML grammar format" href="howto-chaperon-grm.html"/>
      <menu-item label="Text grammar format" href="howto-chaperon-txtgrm.html"/>
    </menu>
  
  </book>
  
  
  
  
  
  
  1.1                  xml-cocoon2/src/documentation/xdocs/howto/chaperon/howto-chaperon-grm.xml
  
  Index: howto-chaperon-grm.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "../../dtd/document-v10.dtd">
  
  <document>
   <header>
    <title>Chaperon - XML grammar format</title>
    <authors>
     <person id="SMS" name="Stephan Michels" email="stephan@apache.org"/>
    </authors>
   </header>
    
   <body>
  
    <s1 title="XML Grammar Format">
  
     <s2 title="Structure">
      <p>The root structure consists of four parts. One part to declare all needed tokens, and
         also one part to declare all tokens, which could be neglected, e.g whitespaces.</p>
  
      <p>In another part the grammar declares the productions, which are used to generate greater
         aggregations of the tokens.</p>
  
      <p>And as last part, the grammar must specified, which symbol should be the start symbol,
         which is similar to the root element of the generated XML document.</p>
  
      <source><![CDATA[
  <grammar uri="[Namespace of the generating XML documents]">
   <tokens>
    [token definitions]
   </tokens>
  
   <ignorabletokens>
    [token definition, which could be ignored]
   </ignorabletokens>
  
   <productions>
    [definitions of the productions]
   </productions>
  
   <ssymbol ntsymbol="[Name of start symbol]"/>
  </grammar>
  ]]></source>
     </s2>
  
     <s2 title="Lexical tokens">
      <p>Every token has an entry in the tokens section. Each token is mapped to a
         terminal symbol. By terminal we mean that this symbol can not be broken 
         down into smaller structures.</p>
     
      <source><![CDATA[
  <tokens>
   <token tsymbol="Name of the symbol">
    [definition of the token]
   </token>
  </tokens>
  ]]></source>
  
      <p>For the definition of tokens Chaperon uses a structure similar to Regex. It contains alternations,
         concatenations, characters classes, etc.</p>
  
      <p>Every element can contain the attributes "minOccurs" and "maxOccurs"</p>
  
      <s3 title="Alternations">
       <p>Alternation means that one of the contained elements must match.</p>
  
       <source><![CDATA[
  <token tsymbol="Name of the symbol">
   <alt>
    [element 1]
    [element 2]
    [element 3]
   </alt>
  </token>
  ]]></source>
  
      </s3>
  
      <s3 title="Concatenations">
       <p>Concatenation means that all elements in a sequence must match.</p>
  
       <source><![CDATA[
  <token tsymbol="Name of the symbol">
   <concat>
    [element 1]
    [element 2]
    [element 3]
   </concat>
  </token>
  ]]></source>
  
      </s3>
  
      <s3 title="Character classes">
       <p>A character class compares a character to the characters 
          which this class contains. There are two options for
          a character class. Either a character class or a negated character class.
          The negated character class implies that the character should not match to any
          of the characters in the class.</p>
  
       <source><![CDATA[
  <token tsymbol="Name of the symbol">
   <cc>
    [Characters, which should match]
   </cc>
  
   <ncc>
    [Characters, which shouldn't match]
   </ncc>
  </token>
  ]]></source>
  
       <p>The character class can contain two elements:</p>
  
       <ul>
        <li>Character sets</li>
        <li>Character intervals</li>
       </ul>
  
       <source><![CDATA[
  <token tsymbol="Name of the symbol">
   <cc>
    <cs content="abcd"/>
    <ci min="e" max="z"/>
   </cc>
  </token
  ]]></source>
  
      </s3>
  
      <s3 title="Strings">
       <p>The string must match to every character in a sequence.</p>
  
       <source><![CDATA[
  <token tsymbol="Name of the symbol">
   <string content="Sequence of characters"/>
  </token>
  ]]></source>
  
      </s3>
  
      <s3 title="Universal character">
       <p>This character matches all characters except carriage return and line feed</p>
  
       <source><![CDATA[
  <token tsymbol="Name of the symbol">
   <dot/>
  </token>
  ]]></source>
  
      </s3>
  
      <s3 title="Begin of line">
       <p>This symbol matches the beginning of a line</p>
  
       <source><![CDATA[
  <token tsymbol="Name of the symbol">
   <bol/>
  </token>
  ]]></source>
  
      </s3>
  
      <s3 title="End of line">
       <p>This symbol matches the end of a line</p>
  
       <source><![CDATA[
  <token tsymbol="Name of the symbol">
   <eol/>
  </token>
  ]]></source>
  
      </s3>
  
     </s2>
  
     <s2 title="Productions">
      <p>A Production arranges tokens in a structure. It is defined by a sequence of symbols</p>
  
      <source><![CDATA[
  <productions>
   <production ntsymbol="Name of of the production">
    <ntsymbol name="symbol1"/><tsymbol name="symbol2"/><ntsymbol name="symbol3"/>
   </production>
  </productions>
  ]]></source>
   
      <p>"tsymbol" refers to a terminal symbol of name specified by the name attribute. 
         Similarly "ntsymbol" refers to a nonterminal symbol.</p>
  
      <p>Here is an example which reads a line of words.</p>
  
      <source><![CDATA[
  <production ntsymbol="line">
   <ntsymbol name="line"/><tsymbol name="WORD"/>
  </production>
  
  <production ntsymbol="line">
   <tsymbol name="word"/>
  </production>
  ]]></source>
  
      <p>A production has two more attributes.</p>
  
      <s3 title="Precedence">
  
       <p>The first attribute is "prec". It
          is used to define precedences. This means that the production gets the same
          priority as a terminal symbol.</p> 
  
       <source><![CDATA[
  <production ntsymbol="line" prec="WORD">
   <ntsymbol name="line"/><tsymbol name="WORD"/>
  </production>
  ]]></source>
  
      </s3>
  
      <p>The second attribute is "reducetype". This attribute is used by the tree builder.</p>
  
      <s3 title="Reduce type : NORMAL">
  
       <source><![CDATA[
  <production ntsymbol="line" reducetype="normal">
   <ntsymbol name="line"/><tsymbol name="WORD"/>
  </production>
  ]]></source>
  
       <p>This example will produce the following XML document.</p>
  
       <source><![CDATA[
  <line>
   <line>
    <line>
     <line>
      <WORD>This</WORD>
     </line>
     <WORD>is</WORD>
    </line>
    <WORD>an</WORD>
   </line>
   <WORD>example</WORD>
  </line>
  ]]></source>
  
      </s3>
  
      <s3 title="Reduce type : APPEND">
  
       <source><![CDATA[
  <production ntsymbol="line" reducetype="append">
   <ntsymbol name="line"/><tsymbol name="WORD"/>
  </production>
  ]]></source>
  
       <p>"append" means that a production will be resolved, if the parent has the same name.</p>
  
       <source><![CDATA[
  <line>
   <WORD>This</WORD>
   <WORD>is</WORD>
   <WORD>an</WORD>
   <WORD>example</WORD>
  </line>
  ]]></source>
  
      </s3>
  
      <s3 title="Reduce type : RESOLVE">
  
       <source><![CDATA[
  <production ntsymbol="line" reducetype="resolve">
   <ntsymbol name="line"/><tsymbol name="WORD"/>
  </production>
  ]]></source>
  
       <p>"resolve" means that a production will resolved.</p>
  
       <source><![CDATA[
  <WORD>This</WORD>
  <WORD>is</WORD>
  <WORD>an</WORD>
  <WORD>example</WORD>
  ]]></source>
  
      </s3>
  
      <s3 title="Reduce type : NEGLECT">
  
       <p>And finally "neglect" means that a production will not appear in the generated XML document.</p>
  
      </s3>
  
     </s2>
  
    </s1>
  
   </body>
  </document>
  
  
  
  1.1                  xml-cocoon2/src/documentation/xdocs/howto/chaperon/howto-chaperon-intro.xml
  
  Index: howto-chaperon-intro.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "../../dtd/document-v10.dtd">
  
  <document>
   <header>
    <title>Chaperon How-To</title>
    <authors>
     <person id="SMS" name="Stephan Michels" email="stephan@apache.org"/>
    </authors>
   </header>
    
   <body>
  
    <s1 title="Introduction">
  
     <p>Chaperon is a project, that helps to convert structured text to XML. It includes a
        strong LALR(1) parser to parse the text, and a tree builder, which creates an
        XML document.</p>
  
     <s2 title="What is structured text?">
      <p>Examples of structured text are TeX files, java files, config files, etc.</p>
     </s2>
  
     <s2 title="Function">
      <p>The Chaperon Parser consists of the following two components:</p>
  
      <ul>
       <li>a parser table generator, and</li>
       <li>a parser</li>
      </ul>
  
      <p>The parser table generator generates a parser table from a grammar, like a compiler
         which generates byte code to improve the execution speed of parsing. The parser table generator
         does similar things. It makes the parsing process as fast as possible</p>
  
      <p>The parser uses the parser table to parse text and then generate an XML document from it.</p>
   
      <p>The generation of the parser table do the generator/transformer once as a first step, and
         stores the parser table into the persistent store.</p>
  
      <p>If the grammar has change the parser creates new parser table.</p>
  
     </s2>
  
     <s2 title="Grammar">
      <p>The parser can used similar as XML Parser. But instead of an XML parser the
         chaperon parser need a grammar file. This grammar file is also specified 
         in XML.</p>
   
      <p>The XML grammar is not really so handy, so the Chaperon project also provides a grammar for a
         text grammar similar to yacc/bison, and a stylesheet for converting this text grammar format to
         the XML grammar format.</p>
   
      <p>So it is easier to write a grammar in this text format rather than directly in the XML format.</p>
  
      <p>The grammar format, the XML and the text format, consists of two parts. The first part contains 
         the token definitions and special instruction declarations. The other part contains the productions.</p>
  
      <p>The token declarations were needed to build a lexer, which feeds the parser which tokens. The
         parser arrange the tokens greater aggregations, which help of the production definitions.</p>
     </s2>
  
    </s1>
  
   </body>
  </document>
  
  
  
  1.1                  xml-cocoon2/src/documentation/xdocs/howto/chaperon/howto-chaperon-txtgrm.xml
  
  Index: howto-chaperon-txtgrm.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "../../dtd/document-v10.dtd">
  
  <document>
   <header>
    <title>Chaperon - Text grammar format</title>
    <authors>
     <person id="SMS" name="Stephan Michels" email="stephan@apache.org"/>
    </authors>
   </header>
    
   <body>
  
    <s1 title="Text Grammar Format">
  
     <s2 title="Structure">
      <p>The text grammar consists of two parts. The first part contains the token definitions and special 
         instruction declarations. The other part contains the productions.</p>
  
      <source><![CDATA[
  [tokens] 
  [special instructions]
  
  %start "Symbol of the production" ;
  
  %%
  [productions]
  ]]></source>
     
      <p>The declaration "%start" declares the root production for the result document.</p>
  
     </s2>
  
     <s2 title="Lexical tokens">
      <p>The tokens are similar to the tokens of the XML grammar. For token definition
         the text grammar makes use of regular expressions</p>
     
      <source><![CDATA[
  %token WORD [A-Za-z][a-z]* ;
  ]]></source>
  
      <s3 title="Alternations">
       <p>Alternation means that one of the contained elements must match.</p>
  
       <source><![CDATA[
  %token CHAR [A-Za-z] | [0-9] ;
  ]]></source>
  
      </s3>
  
      <s3 title="Concatenations">
       <p>Concatenation means that all elements in a sequence must match.</p>
  
       <source><![CDATA[
  %token IDENTIFIER [A-Za-z] [A-Za-z0-9_]* ;
  ]]></source>
  
      </s3>
  
      <s3 title="Character classes">
       <p>A character class compares a character to the characters 
          which this class contains. There are two options for
          a character class. Either a character class or a negated character class.
          The negated character class implies that the character should not match.</p>
  
       <source><![CDATA[
  %token PUNCTUATION [\.,\;\?!] ;
  %token NOTNUMBER [^0-9] ;
  ]]></source>
  
      </s3>
  
      <s3 title="Universal character">
       <p>This character matches all characters except carriage return and line feed</p>
  
       <source><![CDATA[
  %token COMMENT // .* ;
  ]]></source>
  
      </s3>
  
      <s3 title="Begin of line">
       <p>This symbol matches the beginning of a line</p>
  
       <source><![CDATA[
  %token NOTE ^ \[ [0-9]+ \] ;
  ]]></source>
  
      </s3>
  
      <s3 title="End of line">
       <p>This symbol matches the end of a line</p>
  
       <source><![CDATA[
  %token BREAK \\ \\ $ ;
  ]]></source>
  
      </s3>
  
      <s3 title="Abbreviations">
       <p>If an regular expression is often used, you can use an abbreviation for it</p>
  
       <source><![CDATA[
  %ab NUMBER [0-9] ;
  %token FLOAT <NUMBER>+ \. <NUMBER>+ ;
  %token INT <NUMBER>+ ;
  ]]></source>
  
      </s3>
  
      <s3 title="Comments and Whitespaces">
       <p>These are two special tokens which can appear in any position in 
          the parsed text. The parser will read the tokens and then disgard them.</p>
   
       <source><![CDATA[
  %ignore whitespace [\n\r\ ];
  %ignore comment // .* ;
  ]]></source>
  
      </s3>
  
     </s2>
  
     <s2 title="Productions">
      <p>The productions are similarly handled to the productions in the XML grammar.
         More than one definition can be declared through an alternation</p>
  
      <source><![CDATA[
  [Symbol of the production] : [Symbol1] [Symbol2] [..]
                             | [Symbol1] [..]
                             ;
  ]]></source>
  
      <p>To set the precedence for the production use "%prec"</p>
  
      <source><![CDATA[
  example : WORD float %prec PLUS
          | WORD
          ;
  ]]></source>
  
      <p>And for the reduce type use "%reducetype</p>
  
      <source><![CDATA[
  list : list line %reducetype APPEND
       | line      %reducetype APPEND
       ;
  ]]></source>
  
     </s2>
  
    </s1>
  
   </body>
  </document>
  
  
  
  1.3       +1 -0      xml-cocoon2/src/documentation/xdocs/userdocs/generators/book.xml
  
  Index: book.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/userdocs/generators/book.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- book.xml	30 Jun 2002 16:40:42 -0000	1.2
  +++ book.xml	15 Aug 2002 13:43:18 -0000	1.3
  @@ -32,6 +32,7 @@
       <menu-item label="Error Generator" href="error-generator.html"/>
       <menu-item label="Search Generator" href="search-generator.html"/>
       <menu-item label="LinkStatus Generator" href="linkstatus-generator.html"/>
  +    <menu-item label="Text Parser Generator" href="textparser-generator.html"/>
     </menu>
     <menu label="Optional">
       <menu-item label="Php Generator" href="php-generator.html"/>
  
  
  
  1.4       +1 -0      xml-cocoon2/src/documentation/xdocs/userdocs/generators/generators.xml
  
  Index: generators.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/userdocs/generators/generators.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- generators.xml	30 Jun 2002 16:40:42 -0000	1.3
  +++ generators.xml	15 Aug 2002 13:43:18 -0000	1.4
  @@ -47,6 +47,7 @@
   				<li><link href="php-generator.html">Php Generator</link> (optional)</li>
   				<li><link href="xmldb-generator.html">XML:DB Generator</link> (optional)</li>
   				<li><link href="xmldbcollection-generator.html">XML:DB Collection Generator</link> (optional)</li>
  +        <li><link href="textparser-generator.html">Text Parser Generator</link></li>
   			</ul>
   		</s1>
   	</body>
  
  
  
  1.1                  xml-cocoon2/src/documentation/xdocs/userdocs/generators/textparser-generator.xml
  
  Index: textparser-generator.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "../../dtd/document-v10.dtd">
  
  <document>
   <header>
  	<title>Text Parser Generator</title>
    <version>0.1</version>
    <type>Technical document</type>
    <authors>
     <person id="SMS" name="Stephan Michels" email="stephan@apache.org"/>
    </authors>
    <abstract>This document describes the text parser generator of Cocoon.</abstract>
   </header>
   <body>
    <s1 title="Text Parser Generator">
     <p>The text parser generator parser a text file, which an specified grammar, and 
        generates a XML file from it.</p>
  
     <ul>
      <li>Name : textparser</li>
      <li>Class: org.apache.cocoon.generation.TextParserGenerator</li>
      <li>Cacheable: yes - uses the last modification date of the text document and of the grammar file 
          for validation.</li>
     </ul>
  
     <p>The location of the source xml document is specified in
        the pipeline by the src attribute.</p>
  
     <source><![CDATA[
  <map:generate src="example.txt" type="textparser">
   <map:parameter name="grammar" value="example.grm"/>
   <map:parameter name="includeignorabletokens" value="false"/>
  </map:generate>
  ]]></source>
  
     <p>The parameter to specify the grammar must be declared. The second paramter tells the parser
        if it should include all obsolete tokens, and must not specified.<p>
  
     <p>The explanation of function and the grammar format can be found at the <link
       href="../../howto/chaperon/howto-chaperon-intro.html">howto section</link></p>
  
    </s1>
   </body>
  </document>
  
  
  
  1.5       +1 -0      xml-cocoon2/src/documentation/xdocs/userdocs/transformers/book.xml
  
  Index: book.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/userdocs/transformers/book.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- book.xml	4 Aug 2002 12:23:21 -0000	1.4
  +++ book.xml	15 Aug 2002 13:43:18 -0000	1.5
  @@ -29,6 +29,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="Text Parser Transformer" href="textparser-transformer.html"/>
     </menu>
     <menu label="Optional">
       <menu-item label="XT Transformer" href="xt-transformer.html"/>
  
  
  
  1.6       +1 -0      xml-cocoon2/src/documentation/xdocs/userdocs/transformers/transformers.xml
  
  Index: transformers.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/userdocs/transformers/transformers.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- transformers.xml	4 Aug 2002 12:23:21 -0000	1.5
  +++ transformers.xml	15 Aug 2002 13:43:18 -0000	1.6
  @@ -44,6 +44,7 @@
                                   <li><link href="augment-transformer.html">Augment Transformer</link></li>
   				<li><link href="xt-transformer.html">XT Transformer</link> (optional)</li>
   				<li><link href="ldap-transformer.html">LDAP Transformer</link> (optional)</li>
  +        <li><link href="textparser-transformer.html">Text Parser Transformer</link></li>
   			</ul>
   		</s1>
   	</body>
  
  
  
  1.1                  xml-cocoon2/src/documentation/xdocs/userdocs/transformers/textparser-transformer.xml
  
  Index: textparser-transformer.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "../../dtd/document-v10.dtd">
  
  <document>
   <header>
    <title>Text Parser Transformer</title>
    <version>0.1</version>
    <type>Technical document</type>
    <authors>
     <person id="SMS" name="Stephan Michels" email="stephan@apache.org"/>
    </authors>
    <abstract>This document describes the text parser transformer of Cocoon.</abstract>
   </header>
   <body>
    <s1 title="Text Parser Transformer">
     <p>The text parser transformer parse the content of special marked element of a SAX stream, by using
        a grammar file.</p>
  
     <ul>
      <li>Name : textparser</li>
      <li>Class: org.apache.cocoon.transformation.TextFragmentParserTransformer</li>
      <li>Cacheable: yes - uses the last modification date of the grammar document for validation.</li>
     </ul>
  
     <p>The parser parse following elements from the SAX stream, and replace them through
        generated documents.</p>
  
     <source><![CDATA[
  <tf:textfragment xmlns:tf="http://chaperon.sourceforge.net/schema/textfragment/1.0">
   [Text, which should be parsed]
  </tf:textfragment>
  ]]></source>
  
     <p>The parameter to specify the grammar must be declared. The second parameter tells the parser
        if it should include all obsolete tokens, and must not specified.<p>
  
     <source><![CDATA[
  <map:transform type="textparser">
   <map:parameter name="grammar" value="example.grm"/>
   <map:parameter name="includeignorabletokens" value="false"/>
  </map:transform>
  ]]></source>
  
     <p>The explanation of function and the grammar format can be found at the <link
       href="../../howto/chaperon/howto-chaperon-intro.html">howto section</link></p>
  
    </s1>
   </body>
  </document>
  
  
  
  1.1                  xml-cocoon2/src/java/org/apache/cocoon/generation/TextParserGenerator.java
  
  Index: TextParserGenerator.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache Cocoon" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cocoon.generation;
  
  import org.apache.avalon.excalibur.pool.Recyclable;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameters;
  
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.components.source.SourceUtil;
  import org.apache.cocoon.caching.CacheableProcessingComponent;
  import org.apache.cocoon.environment.Request;
  import org.apache.cocoon.environment.SourceResolver;
  import org.apache.cocoon.generation.ComposerGenerator;
  import org.apache.cocoon.util.HashUtil;
  import org.apache.cocoon.xml.EmbeddedXMLPipe;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  import org.apache.excalibur.source.SourceValidity;
  import org.apache.excalibur.source.impl.validity.AggregatedValidity;
  import org.apache.excalibur.store.Store;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  import org.xml.sax.helpers.AttributesImpl;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.helpers.AttributesImpl;
  
  import java.io.ByteArrayInputStream;
  import java.io.IOException;
  import java.io.Serializable;
  import java.util.Map;
  
  import net.sourceforge.chaperon.grammar.Grammar;
  import net.sourceforge.chaperon.grammar.SyntaxErrorException;
  import net.sourceforge.chaperon.grammar.generator.SAXGrammarGenerator;
  import net.sourceforge.chaperon.parser.ParserException;
  import net.sourceforge.chaperon.parser.Parser;
  import net.sourceforge.chaperon.parser.ParserTable;
  import net.sourceforge.chaperon.parser.generator.ParserTableGenerator;
  import net.sourceforge.chaperon.parser.output.EventQueue;
  import net.sourceforge.chaperon.parser.output.SAXEventAdapter;
  
  /**
   * A generator that parse text via a LR Paser.
   * The generator owns two parameter 'includeignorabletokens', which 
   * decides if the ignorable tokens should be included, and 'grammar',
   * which specified the grammar.
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
   * @version CVS $Id: TextParserGenerator.java,v 1.1 2002/08/15 13:43:18 stephan Exp $
   */
  public class TextParserGenerator extends ComposerGenerator
         implements CacheableProcessingComponent {
  
      /** The URI of the parser exception */
      public final static String URI = "http://chaperon.sourceforge.net/schema/parser-exception/1.0";
  
      /** Element name */
      public final static String ELEMENT = "parser-exception";
  
      /** Attribute name of the message property */
      public final static String MESSAGE_ATTRIBUTE = "message";
  
      /** Attribute name of the message property */
      public final static String LINENUMBER_ATTRIBUTE = "linenr";
  
      /** Attribute name of the message property */
      public final static String COLUMNNUMBER_ATTRIBUTE = "columnnr";
  
      /** Element name for acceptedsymbols */
      public final static String ACCEPTEDSYMBOL_ELEMENT = "parser-exception-accept";
  
      /** The input source */
      private Source      inputSource = null;
      private Source      grammarSource = null;
  
      private String      grammar = null;
      private boolean     includeIgnorableTokens = false;
  
      private ParserTable parsertable = null;
  
      private Parser      parser = null;
  
      /**
       * Recycle this component.
       * All instance variables are set to <code>null</code>.
       */
    	public void recycle()	{
  
          if (this.inputSource!=null)
              super.resolver.release(this.inputSource);
          this.inputSource = null;
          if (this.grammarSource!=null)
              super.resolver.release(this.grammarSource);
          this.grammarSource = null;
  
          inputSource = null;
          grammarSource = null;
          grammar = null;
          includeIgnorableTokens = false;
          parsertable = null;
          parser = null;
  
          super.recycle();
    	}
  
      /**
       * Set the SourceResolver, objectModel Map, the source and sitemap 
       * Parameters used to process the request.
       *
       * @param resolver Source resolver
       * @param objectmodel Object model
       * @param src Source
       * @param parameters Parameters
       *
       * @throws IOException
       * @throws ProcessingException
       * @throws SAXException
       */
      public void setup(SourceResolver resolver, Map objectmodel, String src,
                        Parameters parameters)
                        throws ProcessingException, SAXException, IOException {
          super.setup(resolver, objectmodel, src, parameters);
          Store store = null;
          try {
              this.includeIgnorableTokens = parameters.getParameterAsBoolean("includeignorabletokens", false);
              this.grammar = parameters.getParameter("grammar");
  
              this.grammarSource = resolver.resolveURI(this.grammar);
  
              // Retrieve the parser table from the transient store 
              store = (Store)this.manager.lookup(Store.TRANSIENT_STORE);
              ParserTableEntry entry = (ParserTableEntry)store.get(this.grammarSource.getSystemId());
  
              // If the parser table has changed, rebuild the parser table
              if ((entry==null) ||
                  (entry.getValidity()==null) ||
                  (!entry.getValidity().isValid(this.grammarSource.getValidity()))) {
                  getLogger().debug("(Re)building the parsertable from '"+this.grammarSource.getSystemId()+"'");
  
                  SAXGrammarGenerator grammargenerator = new SAXGrammarGenerator();
                  SourceUtil.toSAX(this.grammarSource, grammargenerator, this.manager);
  
                  Grammar grammar = grammargenerator.getGrammar();
                  SyntaxErrorException see = grammar.validate();
                  if (see!=null) {
                      getLogger().error("Grammar is not correct", see);
                      throw new ProcessingException("Grammar is not correct", see);
                  }
  
                  ParserTableGenerator parsertablegenerator = new ParserTableGenerator(grammar);
                  this.parsertable = parsertablegenerator.getParserTable();
  
                  store.store(this.grammarSource.getSystemId(), new ParserTableEntry(this.parsertable,
                                                                    this.grammarSource.getValidity()));
              } else {
                  getLogger().debug("Getting parsertable from store for '"+this.grammarSource.getSystemId()+"'");
                  this.parsertable = entry.getParserTable();
              }
  
              this.inputSource = resolver.resolveURI(src);
  
          } catch (ParameterException pe) {
              getLogger().error("Error during retrieving a parameter", pe);
              throw new ProcessingException("Error during retrieving a parameter", pe);
          } catch (SourceException se) {
              getLogger().error("Error during resolving of '" + src + "'.", se);
              throw new ProcessingException("Error during resolving of '" + src + "'.", se);
          } catch (ComponentException ce) {
              getLogger().error("Could not lookup for component", ce);
              throw new ProcessingException("Could not lookup for component", ce);
          } catch (SyntaxErrorException see) {
              getLogger().error("Grammar is not correct", see);
              throw new ProcessingException("Grammar is not correct", see);
          } finally {
              if (store!=null)
              this.manager.release(store);
          }
      }
  
      /**
       * Generate the unique key.
       * This key must be unique inside the space of this component.
       * This method must be invoked before the generateValidity() method.
       *
       * @return The generated key or <code>null</code> if the component
       *              is currently not cacheable.
       */
      public Serializable generateKey() {
          return "TPG("+this.inputSource.getSystemId()+";"+this.grammarSource.getSystemId()+")";
      }
  
      /**
       * Generate the validity object.
       * Before this method can be invoked the generateKey() method
       * must be invoked.
       *
       * @return The generated validity object or <code>null</code> if the
       *         component is currently not cacheable.
       */
      public SourceValidity generateValidity() {
          SourceValidity inputsourcevalidity  = this.inputSource.getValidity();
          SourceValidity grammarsourcevalidity = this.grammarSource.getValidity();
  
          if ((inputsourcevalidity==null) && (grammarsourcevalidity==null))
              return null;
  
          AggregatedValidity validity = new AggregatedValidity();
          if (inputsourcevalidity!=null)
              validity.add(inputsourcevalidity);
          if (grammarsourcevalidity!=null)
              validity.add(grammarsourcevalidity);
          return validity;
      }
  
      /**
       * Generate XML data.
       */
      public void generate() throws IOException, SAXException, ProcessingException {
          try {
              if (parser==null) {
                  parser = new Parser();
                  parser.enableLogging(getLogger());
              }
  
              EventQueue queue = parser.parse(this.parsertable, this.inputSource.getInputStream());
  
              SAXEventAdapter adapter = new SAXEventAdapter(super.contentHandler, 
                                                          this.includeIgnorableTokens, false);
              queue.fireEvents(adapter);
          } catch (ParserException pe) {
              getLogger().error("Document ist not valid", pe);
              toSAX(super.contentHandler, pe);
          } catch (SourceException se) {
              getLogger().error("Could not get inputstream from source", se);
              throw new ProcessingException("Could not get inputstream from source", se);
          }
      }
  
      /** 
       * Serialize the exception to a SAX stream
       *
       * @param handler The content handler, which receives the SAX events
       *
       * @throws SAXException
       */
      public void toSAX(ContentHandler handler, ParserException pe) throws SAXException { 
          handler.startDocument();
  
          handler.startPrefixMapping("", URI);
      
          AttributesImpl attributes = new AttributesImpl();
      
          attributes.addAttribute(URI, MESSAGE_ATTRIBUTE, MESSAGE_ATTRIBUTE,
                                  "CDATA", pe.getMessage());
          attributes.addAttribute(URI, LINENUMBER_ATTRIBUTE, LINENUMBER_ATTRIBUTE,
                                  "CDATA", String.valueOf(pe.getLineNumber()));
          attributes.addAttribute(URI, COLUMNNUMBER_ATTRIBUTE, COLUMNNUMBER_ATTRIBUTE,
                                  "CDATA", String.valueOf(pe.getColumnNumber()));
        
          handler.startElement(URI, ELEMENT, ELEMENT, attributes);
    
          for(int i=0; i<pe.getAcceptedSymbols().length; i++) { 
              handler.startElement(URI, ACCEPTEDSYMBOL_ELEMENT, ACCEPTEDSYMBOL_ELEMENT, new AttributesImpl());
              handler.characters(pe.getAcceptedSymbols()[i].toCharArray(), 0, 
                                 pe.getAcceptedSymbols()[i].length());
              handler.endElement(URI, ACCEPTEDSYMBOL_ELEMENT, ACCEPTEDSYMBOL_ELEMENT);
          } 
  
          handler.endElement(URI, ELEMENT, ELEMENT);
  
          handler.endPrefixMapping("");
    
          handler.endDocument();
      }
  
      /**
       * This class represent a entry in a store to cache the parsertable.
       */
      public class ParserTableEntry implements Serializable {
          private SourceValidity validity    = null;
          private ParserTable    parsertable = null;
  
          public ParserTableEntry(ParserTable parsertable, SourceValidity validity) {
              this.parsertable = parsertable;
              this.validity = validity;
          }
  
          public SourceValidity getValidity() {
              return this.validity;
          }
  
          public ParserTable getParserTable() {
              return this.parsertable;
          }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/java/org/apache/cocoon/transformation/TextFragmentParserTransformer.java
  
  Index: TextFragmentParserTransformer.java
  ===================================================================
  /*
   *  Copyright (C) Chaperon. All rights reserved.
   *  -------------------------------------------------------------------------
   *  This software is published under the terms of the Apache Software License
   *  version 1.1, a copy of which has been included  with this distribution in
   *  the LICENSE file.
   */
  
  package org.apache.cocoon.transformation;
  
  import org.apache.avalon.excalibur.pool.Recyclable;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameters;
  
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.caching.CacheableProcessingComponent;
  import org.apache.cocoon.components.source.SourceUtil;
  import org.apache.cocoon.environment.SourceResolver;
  import org.apache.cocoon.transformation.AbstractTransformer;
  import org.apache.cocoon.util.HashUtil;
  import org.apache.cocoon.xml.EmbeddedXMLPipe;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  import org.apache.excalibur.source.SourceValidity;
  import org.apache.excalibur.store.Store;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.helpers.AttributesImpl;
  
  import java.io.ByteArrayInputStream;
  import java.io.IOException;
  import java.io.Serializable;
  import java.util.Map;
  
  import net.sourceforge.chaperon.grammar.Grammar;
  import net.sourceforge.chaperon.grammar.SyntaxErrorException;
  import net.sourceforge.chaperon.grammar.generator.SAXGrammarGenerator;
  import net.sourceforge.chaperon.parser.ParserException;
  import net.sourceforge.chaperon.parser.Parser;
  import net.sourceforge.chaperon.parser.ParserTable;
  import net.sourceforge.chaperon.parser.generator.ParserTableGenerator;
  import net.sourceforge.chaperon.parser.output.EventQueue;
  import net.sourceforge.chaperon.parser.output.SAXEventAdapter;
  
  /**
   * The FragmentTextParser parse text in a XML document
   *
   * @author Stephan Michels
   * @version CVS $Id: TextFragmentParserTransformer.java,v 1.1 2002/08/15 13:43:18 stephan Exp $
   */
  public class TextFragmentParserTransformer extends AbstractTransformer
          implements Composable, Recyclable, Disposable, CacheableProcessingComponent {
      private static String EXTRACT_URI = "http://chaperon.sourceforge.net/schema/textfragment/1.0";
      private static String EXTRACT_ELEMENT = "textfragment";
  
      /** The URI of the parser exception DTD */
      public final static String URI = "http://chaperon.sourceforge.net/schema/parser-exception/1.0";
  
      /** Element name */
      public final static String ELEMENT = "parser-exception";
  
      /** Attribute name of the message property */
      public final static String MESSAGE_ATTRIBUTE = "message";
  
      /** Attribute name of the message property */
      public final static String LINENUMBER_ATTRIBUTE = "linenr";
  
      /** Attribute name of the message property */
      public final static String COLUMNNUMBER_ATTRIBUTE = "columnnr";
  
      /** Element name for acceptedsymbols */
      public final static String ACCEPTEDSYMBOL_ELEMENT = "parser-exception-accept";
  
      private int              extractLevel = 0;
  
      private StringBuffer     text = null;
  
      private Source           grammarSource = null;
    
      private ComponentManager manager = null;
      private SourceResolver   resolver = null;
    
      private String           grammar = null;
      private boolean          includeIgnorableTokens = false;
    
      private ParserTable      parsertable = null;
  
      private Parser      parser = null;
  
      /**
       * Pass the ComponentManager to the composer. The Composable 
       * implementation should use the specified ComponentManager
       * to acquire the components it needs for execution.
       *
       * @param manager The ComponentManager which this Composable uses.
       */
      public void compose(ComponentManager manager) {
          this.manager = manager;
      }
  
      /**
       * Recycle this component.
       * All instance variables are set to <code>null</code>.
       */
      public void recycle() {
          if ((this.resolver!=null) && (this.grammarSource!=null)) {
              this.resolver.release(this.grammarSource);
              this.grammarSource = null;
          }
  
          this.parsertable = null;
      }
  
      /**
       * The dispose operation is called at the end of a 
       * components lifecycle.
       */
      public void dispose() {
          if ((this.resolver!=null) && (this.grammarSource!=null)) {
              this.resolver.release(this.grammarSource);
              this.grammarSource = null;
          }
  
          this.manager = null;
      }
  
      /**
       * Set the SourceResolver, objectModel Map, the source and sitemap 
       * Parameters used to process the request.
       *
       * @param resolver Source resolver
       * @param objectmodel Object model
       * @param src Source
       * @param parameters Parameters
       */
      public void setup(SourceResolver resolver, Map objectmodel, String src,
                        Parameters parameters)
              throws ProcessingException, SAXException, IOException {
          this.resolver = resolver;
          Store store = null;
          try {
              this.includeIgnorableTokens = parameters.getParameterAsBoolean("includeignorabletokens", false);
              this.grammar = parameters.getParameter("grammar");
  
              this.grammarSource = resolver.resolveURI(this.grammar);
  
              // Retrieve the parser table from the transient store 
              store = (Store)this.manager.lookup(Store.TRANSIENT_STORE);
              ParserTableEntry entry = (ParserTableEntry)store.get(this.grammarSource.getSystemId());
  
              // If the parser table has changed, rebuild the parser table
              if ((entry==null) ||
                  (entry.getValidity()==null) ||
                  (!entry.getValidity().isValid(this.grammarSource.getValidity()))) {
                  getLogger().debug("(Re)building the parsertable from '"+this.grammarSource.getSystemId()+"'");
  
                  SAXGrammarGenerator grammargenerator = new SAXGrammarGenerator();
                  SourceUtil.toSAX(this.grammarSource, grammargenerator, this.manager);
  
                  Grammar grammar = grammargenerator.getGrammar();
                  SyntaxErrorException see = grammar.validate();
                  if (see!=null) { 
                      getLogger().error("Grammar is not correct", see);
                      throw new ProcessingException("Grammar is not correct", see);
                  }
  
                  ParserTableGenerator parsertablegenerator = new ParserTableGenerator(grammar);
                  this.parsertable = parsertablegenerator.getParserTable();
  
                  store.store(this.grammarSource.getSystemId(), new ParserTableEntry(this.parsertable,
                                                                    this.grammarSource.getValidity()));
              } else {
                  getLogger().debug("Getting parsertable from store for '"+this.grammarSource.getSystemId()+"'");
                  this.parsertable = entry.getParserTable();
              }
  
          } catch (ParameterException pe) {
              getLogger().error("Error during retrieving a parameter", pe);
              throw new ProcessingException("Error during retrieving a parameter", pe);
          } catch (SourceException se) {
              getLogger().error("Error during resolving of '" + src + "'.", se);
              throw new ProcessingException("Error during resolving of '" + src + "'.", se);
          } catch (ComponentException ce) {
              getLogger().error("Could not lookup for component", ce);
              throw new ProcessingException("Could not lookup for component", ce);
          } catch (SyntaxErrorException see) {
              getLogger().error("Grammar is not correct", see);
              throw new ProcessingException("Grammar is not correct", see);
          } finally {
              if (store!=null)
                  this.manager.release(store);
          }
      }
  
      /**
       * Generate the unique key.
       * This key must be unique inside the space of this component.
       *
       * @return The generated key hashes the src
       */
      public Serializable generateKey() {
          return this.grammarSource.getSystemId();
      }
  
      /**
       * Generate the validity object.
       *
       * @return The generated validity object or <code>null</code> if the
       *         component is currently not cacheable.
       */
      public SourceValidity generateValidity() {
          return this.grammarSource.getValidity();
      }
  
      /**
       * Receive notification of the beginning of an element.
       *
       * @param uri The Namespace URI, or the empty string if the element has no
       *            Namespace URI or if Namespace
       *            processing is not being performed.
       * @param loc The local name (without prefix), or the empty string if
       *            Namespace processing is not being performed.
       * @param raw The raw XML 1.0 name (with prefix), or the empty string if
       *            raw names are not available.
       * @param a The attributes attached to the element. If there are no
       *          attributes, it shall be an empty Attributes object.
       */
      public void startElement(String uri, String loc, String raw,
                               Attributes a) throws SAXException {
          if (this.EXTRACT_URI.equals(uri) && this.EXTRACT_ELEMENT.equals(loc)
              && (this.grammar != null)) {
  
              this.extractLevel++;
              this.text = new StringBuffer();
          } else
              super.startElement(uri, loc, raw, a);
      }
  
      /**
       * Receive notification of the end of an element.
       *
       * @param uri The Namespace URI, or the empty string if the element has no
       *            Namespace URI or if Namespace
       *            processing is not being performed.
       * @param loc The local name (without prefix), or the empty string if
       *            Namespace processing is not being performed.
       * @param raw The raw XML 1.0 name (with prefix), or the empty string if
       *            raw names are not available.
       */
      public void endElement(String uri, String loc,
                             String raw) throws SAXException {
          if (this.EXTRACT_URI.equals(uri) && this.EXTRACT_ELEMENT.equals(loc)
              && (this.grammar != null)) {
  
              this.extractLevel--;
    
              try {
                  if (parser==null) {
                      parser = new Parser();
                      parser.enableLogging(getLogger());
                  }
             
                  EventQueue queue = parser.parse(this.parsertable, 
                      new ByteArrayInputStream(this.text.toString().getBytes()));
  
                  SAXEventAdapter adapter = new SAXEventAdapter(super.contentHandler, 
                                                                this.includeIgnorableTokens, true);
                  //adapter.enableLogging(getLogger());
                  queue.fireEvents(adapter);
              } catch (ParserException pe) {
                  getLogger().error("Document ist not valid", pe);
                  EmbeddedXMLPipe pipe = new EmbeddedXMLPipe(super.contentHandler);
                  toSAX(pipe, pe);
              }  
  
              this.text = null;
          } else
              super.endElement(uri, loc, raw);
      }
  
      /**
       * Receive notification of character data.
       *
       * @param c The characters from the XML document.
       * @param start The start position in the array.
       * @param len The number of characters to read from the array.
       */
      public void characters(char c[], int start, int len) throws SAXException {
          if (this.extractLevel > 0)
              this.text.append(c, start, len);
          else
              super.characters(c, start, len);
      }
  
      /** 
       * Serialize the exception to a SAX stream
       *
       * @param handler The content handler, which receives the SAX events
       *
       * @throws SAXException
       */
      public void toSAX(ContentHandler handler, ParserException pe) throws SAXException {
          handler.startDocument();
  
          handler.startPrefixMapping("", URI);
  
          AttributesImpl attributes = new AttributesImpl();
  
          attributes.addAttribute(URI, MESSAGE_ATTRIBUTE, MESSAGE_ATTRIBUTE,
                                  "CDATA", pe.getMessage());
          attributes.addAttribute(URI, LINENUMBER_ATTRIBUTE, LINENUMBER_ATTRIBUTE,
                                  "CDATA", String.valueOf(pe.getLineNumber()));
          attributes.addAttribute(URI, COLUMNNUMBER_ATTRIBUTE, COLUMNNUMBER_ATTRIBUTE,
                                  "CDATA", String.valueOf(pe.getColumnNumber()));
  
          handler.startElement(URI, ELEMENT, ELEMENT, attributes);
  
          for(int i=0; i<pe.getAcceptedSymbols().length; i++) {
              handler.startElement(URI, ACCEPTEDSYMBOL_ELEMENT, ACCEPTEDSYMBOL_ELEMENT, new AttributesImpl());
              handler.characters(pe.getAcceptedSymbols()[i].toCharArray(), 0, 
                                 pe.getAcceptedSymbols()[i].length());
              handler.endElement(URI, ACCEPTEDSYMBOL_ELEMENT, ACCEPTEDSYMBOL_ELEMENT);
          }
  
          handler.endElement(URI, ELEMENT, ELEMENT);
  
          handler.endPrefixMapping("");
  
          handler.endDocument();
      }
  
      /**
       * This class represent a entry in a store to cache the parsertable.
       */
      public class ParserTableEntry implements Serializable {
          private SourceValidity validity    = null;
          private ParserTable    parsertable = null;
  
          public ParserTableEntry(ParserTable parsertable, SourceValidity validity) {
              this.parsertable = parsertable;
              this.validity = validity;
          }
  
          public SourceValidity getValidity() {
              return this.validity;
          }
  
          public ParserTable getParserTable() {
              return this.parsertable;
          }
      }
  }
  
  
  
  1.21      +6 -1      xml-cocoon2/src/webapp/samples/samples.xml
  
  Index: samples.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/samples/samples.xml,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- samples.xml	28 Jul 2002 15:11:14 -0000	1.20
  +++ samples.xml	15 Aug 2002 13:43:19 -0000	1.21
  @@ -181,6 +181,11 @@
       with Cocoon.
      </sample>
   
  +   <sample name="Chaperon Text Parser" href="chaperon/">
  +    Samples showing how to use the Chaperon Parser to parse common text files 
  +    like Wiki of Java files.
  +   </sample>
  +
      <sample name="Miscellaneous" href="misc/">
       Other samples: Catalog entity resolver, ...
      </sample>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  <?xml version="1.0"?>
  
  <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  
  <!-- =========================== Components ================================ -->
  
   <map:components>
  
  <!-- =========================== Generators ================================= -->
  
    <map:generators default="file">
  
     <map:generator label="content,data" logger="sitemap.generator.file" name="file"
                    src="org.apache.cocoon.generation.FileGenerator"/>
  
     <map:generator name="serverpages" logger="sitemap.generator.serverpages" label="content,data"
                    src="org.apache.cocoon.generation.ServerPagesGenerator"/>
  
     <map:generator name="textparser" label="content,data"
                    src="org.apache.cocoon.generation.TextParserGenerator" 
                    logger="sitemap.generator.textparser"/>
  
    </map:generators>
  
  <!-- =========================== Transformers ================================= -->
  
    <map:transformers default="xslt">
     <map:transformer logger="sitemap.transformer.xslt" name="xslt"
                      src="org.apache.cocoon.transformation.TraxTransformer">
      <use-request-parameters>true</use-request-parameters>
      <use-browser-capabilities-db>false</use-browser-capabilities-db>
     </map:transformer>
  
     <map:transformer name="textparser" 
                      src="org.apache.cocoon.transformation.TextFragmentParserTransformer" 
                      logger="sitemap.transformer.textparser"/>
  
    </map:transformers>
  
  <!-- =========================== Readers ================================= -->
  
    <map:readers default="resource">
     <map:reader logger="sitemap.reader.resource" name="resource" 
                  src="org.apache.cocoon.reading.ResourceReader"/>
    </map:readers>
  
  <!-- =========================== Serializers ================================= -->
  
    <map:serializers default="html">
     <map:serializer logger="sitemap.serializer.xml" mime-type="text/xml" name="xml"
                     src="org.apache.cocoon.serialization.XMLSerializer"/>
  
     <map:serializer logger="sitemap.serializer.html" mime-type="text/html" name="html" 
                     src="org.apache.cocoon.serialization.HTMLSerializer">
      <buffer-size>1024</buffer-size>
     </map:serializer>
    </map:serializers>
  
  <!-- =========================== Matchers ================================= -->
  
    <map:matchers default="wildcard">
     <map:matcher logger="sitemap.matcher.wildcard" name="wildcard"
                  src="org.apache.cocoon.matching.WildcardURIMatcher"/>
    </map:matchers>
  
  <!-- ====================== Pipelines defintions ============================= -->
  
    <map:pipelines default="caching">
     <map:pipeline name="caching" src="org.apache.cocoon.components.pipeline.impl.CachingProcessingPipeline"/>
     <map:pipeline name="noncaching" src="org.apache.cocoon.components.pipeline.impl.NonCachingProcessingPipeline"/>
    </map:pipelines>
  
   </map:components>
  
  
  <!-- =========================== Pipelines ================================= -->
  
   <map:pipelines>
  
    <map:pipeline internal-only="true">
  
     <!-- IMPORTANT! This pipeline sould be cachable -->
     <map:match pattern="*.grm">
      <map:generate type="textparser" src="grammars/{1}.rgrm">
       <map:parameter name="grammar" value="context://samples/chaperon/grammars/rgrm.grm"/>
      </map:generate>
  
      <map:transform src="stylesheets/rgrm2grm.xsl"/>
      <map:serialize type="xml"/>
     </map:match>
    </map:pipeline>
  
    <map:pipeline>   
  
     <map:match pattern="">
      <map:redirect-to uri="welcome"/>
     </map:match>
     
     <map:match pattern="welcome">
      <map:generate src="misc/samples.xml"/>
      <map:transform src="context://samples/stylesheets/simple-samples2html.xsl"/>
      <map:serialize/>
     </map:match>
  
     <!-- ========================= Chaperon ================================ -->
  
     <map:match pattern="mathexp.html">
      <map:generate type="serverpages" src="misc/mathexp.xsp"/>
  
      <map:transform src="stylesheets/parsefragment.xsl">
       <map:parameter name="parse_element" value="math"/>
      </map:transform>
  
      <map:transform type="textparser">
       <map:parameter name="grammar" value="context://samples/chaperon/grammars/mathexp.grm"/>
      </map:transform>
  
      <map:transform src="stylesheets/mathexp2html.xsl"/>
      <map:serialize/>
     </map:match>
  
     <map:match pattern="wiki.html">
      <map:generate type="serverpages" src="misc/wiki.xsp"/>
  
      <map:transform type="textparser">
       <!--<map:parameter name="grammar" value="cocoon:/wiki.grm"/>-->
       <map:parameter name="grammar" value="context://samples/chaperon/grammars/wiki.grm"/>
      </map:transform>
  
      <map:transform src="stylesheets/wiki2html.xsl"/>
      <map:serialize type="html"/>
     </map:match>
  
     <map:match pattern="java.html">
      <map:generate type="textparser" src="misc/test.java">
       <map:parameter name="grammar" value="cocoon:/java.grm"/>
       <!--<map:parameter name="grammar" value="context:/grammars/java.grm"/>-->
       <map:parameter name="includeignorabletokens" value="true"/>
      </map:generate>
  
      <map:transform src="stylesheets/java2html.xsl"/>
      <map:serialize type="html"/>
     </map:match>
  
     <map:match pattern="java2.html">
      <map:generate type="textparser" src="misc/test2.java">
       <map:parameter name="grammar" value="cocoon:/java.grm"/>
       <!--<map:parameter name="grammar" value="context:/grammars/java.grm"/>-->
       <map:parameter name="includeignorabletokens" value="true"/>
      </map:generate>
  
      <map:transform src="stylesheets/java2html.xsl"/>
      <map:serialize type="html"/>
     </map:match>
  
     <map:match pattern="java.css">
      <map:read src="misc/java.css"/>
     </map:match>
  
     <!-- ========================= Server ================================ -->
  
     <map:handle-errors>
      <map:transform src="context://stylesheets/system/error2html.xsl"/>
      <map:serialize status-code="500"/>
     </map:handle-errors>
  
    </map:pipeline>
   </map:pipelines>
  
  </map:sitemap>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/grammars/java.rgrm
  
  Index: java.rgrm
  ===================================================================
  /*------------------------------------------------------------------
   * Copyright (C)
   *   1996, 1997, 1998 Dmitri Bronnikov, All rights reserved.
   *
   * THIS GRAMMAR IS PROVIDED "AS IS" WITHOUT  ANY  EXPRESS  OR
   * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   * WARRANTIES  OF  MERCHANTABILITY  AND  FITNESS  FOR  A  PARTICULAR
   * PURPOSE, OR NON-INFRINGMENT.
   *
   * Bronikov@inreach.com
   *
   *------------------------------------------------------------------
   *
   * VERSION 1.06 DATE 20 AUG 1998
   *
   *------------------------------------------------------------------
   *
   * UPDATES
   *
   * 1.06 Correction of Java 1.1 syntax
   * 1.05 Yet more Java 1.1
   *      <qualified name>.<allocation expression>
   * 1.04 More Java 1.1 features:
   *      <class name>.this
   *      <type name>.class
   * 1.03 Added Java 1.1 features:
   *      inner classes,
   *      anonymous classes,
   *      non-static initializer blocks,
   *      array initialization by new operator
   * 1.02 Corrected cast expression syntax
   * 1.01 All shift/reduce conflicts, except dangling else, resolved
   *
   *------------------------------------------------------------------
   *
   * PARSING CONFLICTS RESOLVED
   *
   * Some Shift/Reduce conflicts have been resolved at the expense of
   * the grammar defines a superset of the language. The following
   * actions have to be performed to complete program syntax checking:
   *
   * 1) Check that modifiers applied to a class, interface, field,
   *    or constructor are allowed in respectively a class, inteface,
   *    field or constructor declaration. For example, a class
   *    declaration should not allow other modifiers than abstract,
   *    final and public.
   *
   * 2) For an expression statement, check it is either increment, or
   *    decrement, or assignment expression.
   *
   * 3) Check that type expression in a cast operator indicates a type.
   *    Some of the compilers that I have tested will allow simultaneous
   *    use of identically named type and variable in the same scope
   *    depending on context.
   *
   * 4) Change lexical definition to change '[' optionally followed by
   *    any number of white-space characters immediately followed by ']'
   *    to OP_DIM token. I defined this token as [\[]{white_space}*[\]]
   *    in the lexer.
   *
   *------------------------------------------------------------------
   *
   * UNRESOLVED SHIFT/REDUCE CONFLICTS
   *
   * Dangling else in if-then-else
   *
   *------------------------------------------------------------------
   */
  
  %uri "http://chaperon.sourceforge.net/grammar/java/1.0";
  
  %token DOPEN     \(;
  %token DCLOSE    \);
  %token COPEN     \{;
  %token CCLOSE    \};
  %token BOPEN     \[;
  %token BCLOSE    \];
  %token SEMICOLON \;;
  %token COMMA     \,;
  %token DOT       \.;
  
  %token OP_EQ    ==;
  %token OP_LE    \<=;
  %token OP_GE    \>=;
  %token OP_NE    !=;
  %token OP_LOR   \|\|;
  %token OP_LAND  &&;
  %token OP_INC   \+\+;
  %token OP_DEC   \-\-;
  %token OP_SHR   \>\>;
  %token OP_SHL   \<\<;
  %token OP_SHRR  \>\>\>;
  %token ASS_OP   \+= | \-= | \*= | /= | &= | \|= | \^= | \%= | \<\<= | \>\>= | \>\>\>=;
  
  %token EQ    \=;
  %token GT    \>;
  %token LT    \<;
  %token NOT   \!;
  %token TILDE \~;
  %token QM    \?;
  %token COLON \:;
  %token PLUS  \+;
  %token MINUS \-;
  %token MULT  \*;
  %token DIV   \/;
  %token AND   \&;
  %token OR    \|;
  %token XOR   \^;
  %token MOD   \%;
  
  %token BOOLLIT true|false;
  
  %token ABSTRACT     abstract;
  %token DO           do;
  %token IMPLEMENTS   implements;
  %token PACKAGE      package;
  %token THROW        throw;
  %token BOOLEAN      boolean;
  %token DOUBLE       double;
  %token IMPORT       import;
  %token PRIVATE      private;
  %token THROWS       throws;
  %token BREAK        break;
  
  %right ELSE         else;
  
  %token INNER        inner;
  %token PROTECTED    protected;
  %token TRANSIENT    transient;
  %token BYTE         byte;
  %token EXTENDS      extends;
  %token INSTANCEOF   instanceof;
  %token PUBLIC       public;
  %token TRY          try;
  %token CASE         case;
  %token FINAL        final;
  %token INT          int;
  %token REST         rest;
  %token VAR          var;
  %token CAST         cast;
  %token FINALLY      finally;
  %token INTERFACE    interface;
  %token RETURN       return;
  %token VOID         void;
  %token CATCH        catch;
  %token FLOAT        float;
  %token LONG         long;
  %token SHORT        short;
  %token VOLATILE     volatile;
  %token CHAR         char;
  %token FOR          for;
  %token NATIVE       native;
  %token STATIC       static;
  %token WHILE        while;
  %token CLASS        class;
  %token FUTURE       future;
  %token NEW          new;
  %token SUPER        super;
  %token CONST        const;
  %token GENERIC      generic;
  %token NULL         null;
  %token SWITCH       switch;
  %token CONTINUE     continue;
  %token GOTO         goto;
  %token OPERATOR     operator;
  %token SYNCHRONIZED synchronized;
  %token DEFAULT      default;
  %token IF           if;
  %token OUTER        outer;
  %token THIS         this;
  
  %ab HexDigit        [0-9a-fA-F];
  %ab Digit           [0-9];
  %ab OctalDigit      [0-7];
  %ab TetraDigit      [0-3];
  %ab NonZeroDigit    [1-9];
  %ab Letter          [a-zA-Z_];
  %ab AnyButSlash     [^\/];
  %ab AnyButAstr      [^\*];
  %ab UniEsc          [\1b];
  
  %ab OctEscape1      \\ <OctalDigit>;
  %ab OctEscape2      \\ <OctalDigit><OctalDigit>;
  %ab OctEscape3      \\ <TetraDigit><OctalDigit><OctalDigit>;
  %ab OctEscape       (<OctEscape1>|<OctEscape2>|<OctEscape3>);
  
  %ab Escape          [\\]([rnbft\\\'\"]);
  %ab ULetter         (<Letter>|<UniEsc>);
  %ab Identifier      <ULetter>(<ULetter>|<Digit>)*;
  
  %ab IntSuffix       (l|L);
  %ab DecimalNum      <NonZeroDigit><Digit>*<IntSuffix>?;
  %ab OctalNum        0 <OctalDigit>*<IntSuffix>?;
  %ab HexNum          0 (x|X) <HexDigit><HexDigit>*<IntSuffix>?;
  %ab IntegerLiteral  (<DecimalNum>|<OctalNum>|<HexNum>);
  
  %ab Sign            (\+ | \-);
  %ab FlSuffix        (f|F|d|D);
  %ab SignedInt       <Sign>?<Digit>+;
  %ab Expo            (e|E);
  %ab ExponentPart    <Expo><SignedInt>?;
  %ab Float1          <Digit>+ \. (<Digit>+)?<ExponentPart>?<FlSuffix>?;
  %ab Float2          \. <Digit>+<ExponentPart>?<FlSuffix>?;
  %ab Float3          <Digit>+<ExponentPart><FlSuffix>?;
  %ab Float4          <Digit>+<FlSuffix>;
  %ab FloatingPoint   (<Float1>|<Float2>|<Float3>|<Float4>);
  
  %ab AnyChrChr       [^\\'];
  %ab AnyStrChr       [^\\\"];
  %ab Character       \' (<Escape>|<OctEscape>|<AnyChrChr>)  \' ;
  %ab String          \" (<Escape>|<OctEscape>|<AnyStrChr>)* \" ;
  %ab Numeric         (<IntegerLiteral>|<FloatingPoint>);
  
  %token LITERAL         (<Numeric>|<Character>|<String>);
  
  %token IDENTIFIER   ([a-zA-Z_]|[\1b])(([a-zA-Z_]|[\1b])|[0-9])*;
  
  
  //%token OP_DIM \[ ([\r\n\f\t\b\ ]|( \/ \* ([^\*]| \* [^\/])* \*  \/ |
  //              \/ \/ (.*)))* \] ;
  
  //%whitespace [\r\n\f\t\b\ ];
  
  
  %token OP_DIM \[ ([\r\n\t\ ]|( \/ \* ([^\*]| \* [^\/])* \*  \/ |
                 \/ \/ (.*)))* \] ;
  
  %ignore whitespace [\t\ ];
  
  %ignore eol \r(\n)?|\n;
  
  %ab Comment1        \/ \* (<AnyButAstr>|[\*]<AnyButSlash>)* \* \/;
  %ab Comment2        \/ \/ (.*);
  %ignore comment         (<Comment1>|<Comment2>);
  
  %start CompilationUnit;
  
  %%
  
  TypeSpecifier
  	: TypeName
  	| TypeName Dims
  	;
  
  TypeName
  	: PrimitiveType
  	| QualifiedName
  	;
  
  ClassNameList
    : QualifiedName
    | ClassNameList COMMA QualifiedName
  	;
  
  PrimitiveType
  	: BOOLEAN
  	| CHAR
  	| BYTE
  	| SHORT
  	| INT
  	| LONG
  	| FLOAT
  	| DOUBLE
  	| VOID
  	;
  
  SemiColons
  	: SEMICOLON
    | SemiColons SEMICOLON
    ;
  
  CompilationUnit
  	: ProgramFile
    ;
  
  ProgramFile
  	: PackageStatement ImportStatements TypeDeclarations
  	| PackageStatement ImportStatements
  	| PackageStatement                  TypeDeclarations
  	|                  ImportStatements TypeDeclarations
  	| PackageStatement
  	|                  ImportStatements
  	|                                   TypeDeclarations
  	;
  
  PackageStatement
  	: PACKAGE QualifiedName SemiColons
  	;
  
  TypeDeclarations
  	: TypeDeclarationOptSemi
  	| TypeDeclarations TypeDeclarationOptSemi
  	;
  
  TypeDeclarationOptSemi
    : TypeDeclaration
    | TypeDeclaration SemiColons
    ;
  
  ImportStatements
  	: ImportStatement
  	| ImportStatements ImportStatement
  	;
  
  ImportStatement
  	: IMPORT QualifiedName SemiColons
  	| IMPORT QualifiedName DOT MULT SemiColons
  	;
  
  QualifiedName
  	: IDENTIFIER %append
  	| QualifiedName DOT IDENTIFIER %append
  	;
  
  TypeDeclaration
  	: ClassHeader COPEN FieldDeclarations CCLOSE
  	| ClassHeader COPEN CCLOSE
  	;
  
  ClassHeader
  	: Modifiers ClassWord IDENTIFIER Extends Interfaces
  	| Modifiers ClassWord IDENTIFIER Extends
  	| Modifiers ClassWord IDENTIFIER         Interfaces
  	|           ClassWord IDENTIFIER Extends Interfaces
  	| Modifiers ClassWord IDENTIFIER
  	|           ClassWord IDENTIFIER Extends
  	|           ClassWord IDENTIFIER         Interfaces
  	|           ClassWord IDENTIFIER
  	;
  
  Modifiers
  	: Modifier %append
  	| Modifiers Modifier %append
  	;
  
  Modifier
  	: ABSTRACT
  	| FINAL
  	| PUBLIC
  	| PROTECTED
  	| PRIVATE
  	| STATIC
  	| TRANSIENT
  	| VOLATILE
  	| NATIVE
  	| SYNCHRONIZED
  	;
  
  ClassWord
  	: CLASS
  	| INTERFACE
  	;
  
  Interfaces
  	: IMPLEMENTS ClassNameList
  	;
  
  FieldDeclarations
  	: FieldDeclarationOptSemi
    | FieldDeclarations FieldDeclarationOptSemi
  	;
  
  FieldDeclarationOptSemi
    : FieldDeclaration
    | FieldDeclaration SemiColons
    ;
  
  FieldDeclaration
  	: FieldVariableDeclaration SEMICOLON
  	| MethodDeclaration
  	| ConstructorDeclaration
  	| StaticInitializer
    | NonStaticInitializer
    | TypeDeclaration
  	;
  
  FieldVariableDeclaration
  	: Modifiers TypeSpecifier VariableDeclarators
  	|           TypeSpecifier VariableDeclarators
  	;
  
  VariableDeclarators
  	: VariableDeclarator
  	| VariableDeclarators COMMA VariableDeclarator
  	;
  
  VariableDeclarator
  	: DeclaratorName
  	| DeclaratorName EQ VariableInitializer
  	;
  
  VariableInitializer
  	: Expression
  	| COPEN CCLOSE
    | COPEN ArrayInitializers CCLOSE
    ;
  
  ArrayInitializers
  	: VariableInitializer
  	| ArrayInitializers COMMA VariableInitializer
  	| ArrayInitializers COMMA
  	;
  
  MethodDeclaration
  	: Modifiers TypeSpecifier MethodDeclarator Throws MethodBody
  	| Modifiers TypeSpecifier MethodDeclarator        MethodBody
  	|           TypeSpecifier MethodDeclarator Throws MethodBody
  	|           TypeSpecifier MethodDeclarator        MethodBody
  	;
  
  MethodDeclarator
  	: DeclaratorName DOPEN ParameterList DCLOSE
  	| DeclaratorName DOPEN DCLOSE
  	| MethodDeclarator OP_DIM
  	;
  
  ParameterList
  	: Parameter
  	| ParameterList COMMA Parameter
  	;
  
  Parameter
  	: TypeSpecifier DeclaratorName
    | FINAL TypeSpecifier DeclaratorName
  	;
  
  DeclaratorName
  	: IDENTIFIER
    | DeclaratorName OP_DIM
    ;
  
  Throws
  	: THROWS ClassNameList
  	;
  
  MethodBody
  	: Block
  	| SEMICOLON
  	;
  
  ConstructorDeclaration
  	: Modifiers ConstructorDeclarator Throws Block
  	| Modifiers ConstructorDeclarator        Block
  	|           ConstructorDeclarator Throws Block
  	|           ConstructorDeclarator        Block
  	;
  
  ConstructorDeclarator
  	: IDENTIFIER DOPEN ParameterList DCLOSE
  	| IDENTIFIER DOPEN DCLOSE
  	;
  
  StaticInitializer
  	: STATIC Block
  	;
  
  NonStaticInitializer
    : Block
    ;
  
  Extends
  	: EXTENDS TypeName
  	| Extends COMMA TypeName
  	;
  
  Block
  	: COPEN LocalVariableDeclarationsAndStatements CCLOSE
  	| COPEN CCLOSE
    ;
  
  LocalVariableDeclarationsAndStatements
  	: LocalVariableDeclarationOrStatement %append
  	| LocalVariableDeclarationsAndStatements LocalVariableDeclarationOrStatement %append
  	;
  
  LocalVariableDeclarationOrStatement
  	: LocalVariableDeclarationStatement
  	| Statement
  	;
  
  LocalVariableDeclarationStatement
  	: TypeSpecifier VariableDeclarators SEMICOLON
    | FINAL TypeSpecifier VariableDeclarators SEMICOLON
  	;
  
  Statement
  	: EmptyStatement
  	| LabelStatement
  	| ExpressionStatement SEMICOLON
    | SelectionStatement
    | IterationStatement
  	| JumpStatement
  	| GuardingStatement
  	| Block
  	;
  
  EmptyStatement
  	: SEMICOLON
    ;
  
  LabelStatement
  	: IDENTIFIER COLON
    | CASE ConstantExpression COLON
  	| DEFAULT COLON
    ;
  
  ExpressionStatement
  	: Expression
  	;
  
  SelectionStatement
  	: IF DOPEN Expression DCLOSE Statement %prec ELSE
    | IF DOPEN Expression DCLOSE Statement ELSE Statement %prec ELSE
    | SWITCH DOPEN Expression DCLOSE Block
    ;
  
  IterationStatement
  	: WHILE DOPEN Expression DCLOSE Statement
  	| DO Statement WHILE DOPEN Expression DCLOSE SEMICOLON
  	| FOR DOPEN ForInit ForExpr ForIncr DCLOSE Statement
  	| FOR DOPEN ForInit ForExpr         DCLOSE Statement
  	;
  
  ForInit
  	: ExpressionStatements SEMICOLON
  	| LocalVariableDeclarationStatement
  	| SEMICOLON
  	;
  
  ForExpr
  	: Expression SEMICOLON
  	| SEMICOLON
  	;
  
  ForIncr
  	: ExpressionStatements
  	;
  
  ExpressionStatements
  	: ExpressionStatement %resolve
  	| ExpressionStatements COMMA ExpressionStatement
  	;
  
  JumpStatement
  	: BREAK IDENTIFIER SEMICOLON
  	| BREAK            SEMICOLON
    | CONTINUE IDENTIFIER SEMICOLON
  	| CONTINUE            SEMICOLON
  	| RETURN Expression SEMICOLON
  	| RETURN            SEMICOLON
  	| THROW Expression SEMICOLON
  	;
  
  GuardingStatement
  	: SYNCHRONIZED DOPEN Expression DCLOSE Statement
  	| TRY Block Finally
  	| TRY Block Catches
  	| TRY Block Catches Finally
  	;
  
  Catches
  	: Catch
  	| Catches Catch
  	;
  
  Catch
  	: CatchHeader Block
  	;
  
  CatchHeader
  	: CATCH DOPEN TypeSpecifier IDENTIFIER DCLOSE
  	| CATCH DOPEN TypeSpecifier DCLOSE
  	;
  
  Finally
  	: FINALLY Block
  	;
  
  PrimaryExpression
  	: QualifiedName %resolve
  	| NotJustName %resolve
  	;
  
  NotJustName
  	: SpecialName %resolve
  	| NewAllocationExpression %resolve
  	| ComplexPrimary %resolve
  	;
  
  ComplexPrimary
  	: DOPEN Expression DCLOSE
  	| ComplexPrimaryNoParenthesis %resolve
  	;
  
  ComplexPrimaryNoParenthesis
  	: LITERAL
  	| BOOLLIT
  	| ArrayAccess
  	| FieldAccess
  	| MethodCall
  	;
  
  ArrayAccess
  	: QualifiedName  BOPEN Expression BCLOSE
  	| ComplexPrimary BOPEN Expression BCLOSE
  	;
  
  FieldAccess
  	: NotJustName DOT IDENTIFIER
  	| RealPostfixExpression DOT IDENTIFIER
    | QualifiedName DOT THIS
    | QualifiedName DOT CLASS
    | PrimitiveType DOT CLASS
  	;
  
  MethodCall
  	: MethodAccess DOPEN ArgumentList DCLOSE
  	| MethodAccess DOPEN DCLOSE
  	;
  
  MethodAccess
  	: ComplexPrimaryNoParenthesis
  	| SpecialName
  	| QualifiedName
  	;
  
  SpecialName
  	: THIS
  	| SUPER
  	| NULL
  	;
  
  ArgumentList
  	: Expression
  	| ArgumentList COMMA Expression
  	;
  
  NewAllocationExpression
    : PlainNewAllocationExpression
    | QualifiedName DOT PlainNewAllocationExpression
    ;
  
  PlainNewAllocationExpression
   	: ArrayAllocationExpression
   	| ClassAllocationExpression
   	| ArrayAllocationExpression COPEN CCLOSE
   	| ClassAllocationExpression COPEN CCLOSE
   	| ArrayAllocationExpression COPEN ArrayInitializers CCLOSE
   	| ClassAllocationExpression COPEN FieldDeclarations CCLOSE
   	;
  
  ClassAllocationExpression
  	: NEW TypeName DOPEN ArgumentList DCLOSE
  	| NEW TypeName DOPEN              DCLOSE
    ;
  
  ArrayAllocationExpression
  	: NEW TypeName DimExprs Dims
  	| NEW TypeName DimExprs
    | NEW TypeName Dims
  	;
  
  DimExprs
  	: DimExpr
  	| DimExprs DimExpr
  	;
  
  DimExpr
  	: BOPEN Expression BCLOSE
  	;
  
  Dims
  	: OP_DIM
  	| Dims OP_DIM
  	;
  
  PostfixExpression
  	: PrimaryExpression %resolve
  	| RealPostfixExpression %resolve
  	;
  
  RealPostfixExpression
  	: PostfixExpression OP_INC
  	| PostfixExpression OP_DEC
  	;
  
  UnaryExpression
  	: OP_INC UnaryExpression
  	| OP_DEC UnaryExpression
  	| ArithmeticUnaryOperator CastExpression
  	| LogicalUnaryExpression %resolve
  	;
  
  LogicalUnaryExpression
  	: PostfixExpression %resolve
  	| LogicalUnaryOperator UnaryExpression
  	;
  
  LogicalUnaryOperator
  	: TILDE
  	| NOT
  	;
  
  ArithmeticUnaryOperator
  	: PLUS
  	| MINUS
  	;
  
  CastExpression
  	: UnaryExpression %resolve
  	| DOPEN PrimitiveTypeExpression DCLOSE CastExpression
  	| DOPEN ClassTypeExpression DCLOSE CastExpression
  	| DOPEN Expression DCLOSE LogicalUnaryExpression
  	;
  
  PrimitiveTypeExpression
  	: PrimitiveType 
    | PrimitiveType Dims
    ;
  
  ClassTypeExpression
  	: QualifiedName Dims
    ;
  
  MultiplicativeExpression
  	: CastExpression %resolve
  	| MultiplicativeExpression MULT CastExpression
  	| MultiplicativeExpression DIV CastExpression
  	| MultiplicativeExpression MOD CastExpression
  	;
  
  AdditiveExpression
  	: MultiplicativeExpression %resolve
    | AdditiveExpression PLUS MultiplicativeExpression
  	| AdditiveExpression MINUS MultiplicativeExpression
    ;
  
  ShiftExpression 
  	: AdditiveExpression %resolve
    | ShiftExpression OP_SHL AdditiveExpression
    | ShiftExpression OP_SHR AdditiveExpression
    | ShiftExpression OP_SHRR AdditiveExpression
  	;
  
  RelationalExpression
  	: ShiftExpression %resolve
    | RelationalExpression LT ShiftExpression
  	| RelationalExpression GT ShiftExpression
  	| RelationalExpression OP_LE ShiftExpression
  	| RelationalExpression OP_GE ShiftExpression
  	| RelationalExpression INSTANCEOF TypeSpecifier
  	;
  
  EqualityExpression
  	: RelationalExpression %resolve
    | EqualityExpression OP_EQ RelationalExpression
    | EqualityExpression OP_NE RelationalExpression
    ;
  
  AndExpression
  	: EqualityExpression %resolve
    | AndExpression AND EqualityExpression
    ;
  
  ExclusiveOrExpression
  	: AndExpression %resolve
  	| ExclusiveOrExpression XOR AndExpression
  	;
  
  InclusiveOrExpression
  	: ExclusiveOrExpression %resolve
  	| InclusiveOrExpression OR ExclusiveOrExpression
  	;
  
  ConditionalAndExpression
  	: InclusiveOrExpression %resolve
  	| ConditionalAndExpression OP_LAND InclusiveOrExpression
  	;
  
  ConditionalOrExpression
  	: ConditionalAndExpression %resolve
  	| ConditionalOrExpression OP_LOR ConditionalAndExpression
  	;
  
  ConditionalExpression
  	: ConditionalOrExpression %resolve
  	| ConditionalOrExpression QM Expression COLON ConditionalExpression
  	;
  
  AssignmentExpression
  	: ConditionalExpression %resolve
  	| UnaryExpression AssignmentOperator AssignmentExpression
  	;
  
  AssignmentOperator
  	: EQ
  	| ASS_OP
  	;
  
  Expression
  	: AssignmentExpression
    ;
  
  ConstantExpression
  	: ConditionalExpression
  	;
  
  
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/grammars/mathexp.grm
  
  Index: mathexp.grm
  ===================================================================
  <?xml version="1.0"?>
  <!--<!DOCTYPE grammar PUBLIC "-//Chaperon//DTD grammar 1.0//EN" "grammar.dtd">-->
  
  <grammar uri="http://chaperon.sourceforge.net/grammar/mathexp/1.0">
   <tokens>
  
    <token tsymbol="plus">
     <cc><cs content="+-"/></cc>
    </token>
  
    <token tsymbol="mult">
     <cc><cs content="*/"/></cc>
    </token>
  
    <token tsymbol="dopen">
     <string content="("/>
    </token>
  
    <token tsymbol="dclose">
     <string content=")"/>
    </token>
  
    <token tsymbol="id">
     <concat>
      <cc><ci min="A" max="Z"/><ci min="a" max="z"/></cc>
      <cc minOccurs="0" maxOccurs="*"><ci min="A" max="Z"/><ci min="a" max="z"/><ci min="0" max="9"/><cs content="_"/></cc>
     </concat>
    </token>
  
    <token tsymbol="number">
     <alt>
      <concat>
       <cc minOccurs="1" maxOccurs="*"><ci min="0" max="9"/></cc>
       <concat minOccurs="0" maxOccurs="1">
        <string content="."/>
        <cc minOccurs="0" maxOccurs="*"><ci min="0" max="9"/></cc>
       </concat>
      </concat>
      <concat>
       <string content="."/>
       <cc minOccurs="1" maxOccurs="*"><ci min="0" max="9"/></cc>
      </concat>
     </alt>
    </token>
  
   </tokens>
  
   <ignorabletokens>
    <token tsymbol="whitespace">
     <cc maxOccurs="*"><cs content="&#10;&#13;&#9;&#32;"/></cc>
    </token>
   </ignorabletokens>
  
   <productions>
  
    <production ntsymbol="E">
     <ntsymbol name="E"/><tsymbol name="plus"/><ntsymbol name="T"/>
  	</production>
  
    <production ntsymbol="E">
     <ntsymbol name="T"/>
    </production>
  
    <production ntsymbol="T">
     <ntsymbol name="T"/><tsymbol name="mult"/><ntsymbol name="F"/>
    </production>
  
    <production ntsymbol="T">
     <ntsymbol name="F"/>
    </production>
  
    <production ntsymbol="F">
     <tsymbol name="dopen"/><ntsymbol name="E"/><tsymbol name="dclose"/>
    </production>
  
    <production ntsymbol="F">
     <tsymbol name="id"/>
    </production>
  
    <production ntsymbol="F">
     <tsymbol name="number"/>
    </production>
  
   </productions>
  
   <ssymbol ntsymbol="E"/>
  </grammar>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/grammars/rgrm.grm
  
  Index: rgrm.grm
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!--<!DOCTYPE grammar PUBLIC "-//Chaperon//DTD grammar 1.0//EN" "grammar.dtd">-->
  
  <grammar uri="http://chaperon.sourceforge.net/grammar/rgrm/1.0">
   <tokens>
  
    <token tsymbol="token_decl">
     <alt>
      <string content="%token"/>
      <string content="%left"/>
      <string content="%right"/>
     </alt>
    </token>
  
    <token tsymbol="ab_decl">
     <string content="%ab"/>
    </token>
  
    <token tsymbol="start_decl">
     <string content="%start"/>
    </token>
  
    <token tsymbol="ignorabletoken_decl">
     <string content="%ignore"/>
    </token>
  
    <token tsymbol="reducetype_decl">
     <alt>
      <string content="%normal"/>
      <string content="%append"/>
      <string content="%resolve"/>
      <string content="%neglect"/>
     </alt>
    </token>
  
    <token tsymbol="prec_decl">
     <string content="%prec"/>
    </token>
  
    <token tsymbol="uri_decl">
     <string content="%uri"/>
    </token>
  
    <token tsymbol="delimiter">
     <string content="%%"/>
    </token>
  
    <token tsymbol="colon">
     <string content=":"/>
    </token>
  
    <token tsymbol="alt">
     <string content="|"/>
    </token>
  
    <token tsymbol="semicolon">
     <string content=";"/>
    </token>
  
    <token tsymbol="comma">
     <string content=","/>
    </token>
  
    <token tsymbol="number">
     <cc minOccurs="1" maxOccurs="*"><ci min="0" max="9"/></cc>
    </token>
  
    <token tsymbol="copen">
     <string content="{"/>
    </token>
  
    <token tsymbol="cclose">
     <string content="}"/>
    </token>
  
    <token tsymbol="abopen">
     <string content="&lt;"/>
    </token>
  
    <token tsymbol="abclose">
     <string content=">"/>
    </token>
  
    <token tsymbol="string">
     <concat>
      <string content="&#34;"/>
      <alt minOccurs="1" maxOccurs="*">
       <ncc><cs content="&#92;&#34;"/></ncc>
       <concat><string content="&#92;"/><ncc><cs content="u"/></ncc></concat>
       <concat>
        <string content="&#92;u"/>
        <cc><ci min="0" max="9"/><ci min="a" max="f"/><ci min="A" max="F"/></cc>
        <cc><ci min="0" max="9"/><ci min="a" max="f"/><ci min="A" max="F"/></cc>
        <cc><ci min="0" max="9"/><ci min="a" max="f"/><ci min="A" max="F"/></cc>
        <cc><ci min="0" max="9"/><ci min="a" max="f"/><ci min="A" max="F"/></cc>
       </concat>
      </alt>
      <string content="&#34;"/>
     </concat>
    </token>
  
    <token tsymbol="id">
     <concat>
      <cc><ci min="A" max="Z"/><ci min="a" max="z"/></cc>
      <cc minOccurs="0" maxOccurs="*">
       <ci min="A" max="Z"/><ci min="a" max="z"/><ci min="0" max="9"/><cs content="_"/>
      </cc>
     </concat>
    </token>
  
  	<token tsymbol="character">
     <!--<alt>-->
      <ncc><cs content="&#92;[]-&#10;&#13;&#32;();%[]|+?*^$&lt;>&#34;"/></ncc>
      <!--<concat><string content="&#92;"/><dot/></concat>
      <concat><string content="&#92;"/><ncc><cs content="u"/></ncc></concat>
  		<concat>
       <string content="&#92;u"/>
       <cc><ci min="0" max="9"/><ci min="a" max="f"/><ci min="A" max="F"/></cc>
       <cc><ci min="0" max="9"/><ci min="a" max="f"/><ci min="A" max="F"/></cc>
       <cc><ci min="0" max="9"/><ci min="a" max="f"/><ci min="A" max="F"/></cc>
       <cc><ci min="0" max="9"/><ci min="a" max="f"/><ci min="A" max="F"/></cc>
      </concat>
  	 </alt>-->
  	</token>
  
    <token tsymbol="maskedcharacter">
      <concat><string content="&#92;"/><dot/></concat>
    </token>
  
    <token tsymbol="minus">
     <string content="-"/>
    </token>
  
    <token tsymbol="hat">
     <string content="^"/>
    </token>
  
    <token tsymbol="dollar">
     <string content="$"/>
    </token>
  
    <token tsymbol="ccbegin">
     <string content="["/>
    </token>
  
    <token tsymbol="ccend">
     <string content="]"/>
    </token>
  
    <token tsymbol="regexdot">
     <string content="."/>
    </token>
  
    <token tsymbol="dopen">
     <string content="("/>
    </token>
  
    <token tsymbol="dclose">
     <string content=")"/>
    </token>
  
    <token tsymbol="questionmark">
     <string content="?"/>
    </token>
  
    <token tsymbol="mult">
     <string content="*"/>
    </token>
  
    <token tsymbol="plus">
     <string content="+"/>
    </token>
  
   </tokens>
  
   <ignorabletokens>
    <token tsymbol="comment">
     <alt>
      <concat><string content="//"/><ncc minOccurs="0" maxOccurs="*"><cs content="&#10;"/></ncc></concat>
      <concat>
       <string content="/*"/>
       <alt minOccurs="0" maxOccurs="*">
        <ncc><cs content="*"/></ncc>
        <concat><string content="*"/><ncc><cs content="/"/></ncc></concat>
       </alt>
       <string content="*/"/>
      </concat>
     </alt>
    </token>
   
    <token tsymbol="whitespace"> 
     <cc maxOccurs="*"><cs content="&#10;&#13;&#9;&#32;"/></cc>
    </token>
   </ignorabletokens>
  
   <productions>
  
    <production ntsymbol="intervall">
     <tsymbol name="character"/><tsymbol name="minus"/><tsymbol name="character"/>
  	</production>
  
    <production ntsymbol="intervall">
     <tsymbol name="maskedcharacter"/><tsymbol name="minus"/><tsymbol name="character"/>
    </production>
  
    <production ntsymbol="intervall">
     <tsymbol name="character"/><tsymbol name="minus"/><tsymbol name="maskedcharacter"/>
    </production>
  
    <production ntsymbol="intervall">
     <tsymbol name="maskedcharacter"/><tsymbol name="minus"/><tsymbol name="maskedcharacter"/>
    </production>
  
    <production ntsymbol="sequence" reducetype="resolve">
  	 <ntsymbol name="sequence"/><ntsymbol name="intervall"/>
  	</production>
  
    <production ntsymbol="sequence" reducetype="resolve">
     <ntsymbol name="sequence"/><tsymbol name="character"/>
    </production>
  
    <production ntsymbol="sequence" reducetype="resolve">
     <ntsymbol name="sequence"/><tsymbol name="maskedcharacter"/>
    </production>
  
    <production ntsymbol="sequence" reducetype="resolve">
     <ntsymbol name="intervall"/>
    </production>
  
    <production ntsymbol="sequence" reducetype="resolve">
     <tsymbol name="character"/>
    </production>
  
    <production ntsymbol="sequence" reducetype="resolve">
     <tsymbol name="maskedcharacter"/>
    </production>
  
    <production ntsymbol="string" reducetype="append">
     <ntsymbol name="string"/><tsymbol name="character"/>
    </production>
  
    <production ntsymbol="string" reducetype="append">
     <ntsymbol name="string"/><tsymbol name="maskedcharacter"/>
    </production>
  
    <production ntsymbol="string" reducetype="append">
     <tsymbol name="character"/>
    </production>
  
    <production ntsymbol="string" reducetype="append">
     <tsymbol name="maskedcharacter"/>
    </production>
  
    <production ntsymbol="characterclass">
  	 <tsymbol name="ccbegin"/><ntsymbol name="sequence"/><tsymbol name="ccend"/>
    </production>
  
    <production ntsymbol="negatedcharacterclass">
     <tsymbol name="ccbegin"/><tsymbol name="hat"/><ntsymbol name="sequence"/><tsymbol name="ccend"/>
    </production>
  
  	<production ntsymbol="regexdot">
  	 <tsymbol name="regexdot"/>
  	</production>
  
    <production ntsymbol="regexbol">
     <tsymbol name="hat"/>
    </production>
  
    <production ntsymbol="regexeol">
     <tsymbol name="dollar"/>
    </production>
  
    <production ntsymbol="regexklammer">
  	 <tsymbol name="dopen"/><ntsymbol name="regexalternation"/><tsymbol name="dclose"/>
  	</production>
  
    <production ntsymbol="regexabref">
     <tsymbol name="abopen"/><tsymbol name="id"/><tsymbol name="abclose"/>
    </production>
  
    <production ntsymbol="regexterm" reducetype="resolve">
  	 <ntsymbol name="characterclass"/>
  	</production>
  
    <production ntsymbol="regexterm" reducetype="resolve">
     <ntsymbol name="negatedcharacterclass"/>
    </production>
  
    <production ntsymbol="regexterm" reducetype="resolve">
     <ntsymbol name="regexklammer"/>
    </production>
  
    <production ntsymbol="regexterm" reducetype="resolve">
     <ntsymbol name="string"/>
    </production>
  
    <production ntsymbol="regexterm" reducetype="resolve">
     <ntsymbol name="regexdot"/>
    </production>
  
    <production ntsymbol="regexterm" reducetype="resolve">
     <ntsymbol name="regexbol"/>
    </production>
  
    <production ntsymbol="regexterm" reducetype="resolve">
     <ntsymbol name="regexeol"/>
    </production>
  
    <production ntsymbol="regexterm" reducetype="resolve">
     <ntsymbol name="regexabref"/>
    </production>
  
    <production ntsymbol="regexoptional">
  	 <ntsymbol name="regexterm"/><tsymbol name="questionmark"/>
  	</production>
  
    <production ntsymbol="regexstar">
  	 <ntsymbol name="regexterm"/><tsymbol name="mult"/>
  	</production>
  
    <production ntsymbol="regexplus">
     <ntsymbol name="regexterm"/><tsymbol name="plus"/>
    </production>
  
    <production ntsymbol="regexmultiplicator">
     <tsymbol name="copen"/><tsymbol name="number"/><tsymbol name="cclose"/>
    </production>
  
    <production ntsymbol="regexmultiplicator">
     <tsymbol name="copen"/><tsymbol name="number"/>
     <tsymbol name="comma"/><tsymbol name="number"/><tsymbol name="cclose"/>
    </production>
  
    <production ntsymbol="regexvar">
     <ntsymbol name="regexterm"/><ntsymbol name="regexmultiplicator"/>
    </production>
  
  	<production ntsymbol="regexquantifier" reducetype="resolve">
  	 <ntsymbol name="regexoptional"/>
  	</production>
  
    <production ntsymbol="regexquantifier" reducetype="resolve">
     <ntsymbol name="regexstar"/>
    </production>
  
    <production ntsymbol="regexquantifier" reducetype="resolve">
     <ntsymbol name="regexplus"/>
    </production>
  
    <production ntsymbol="regexquantifier" reducetype="resolve">
     <ntsymbol name="regexterm"/>
    </production>
  
    <production ntsymbol="regexquantifier" reducetype="resolve">
     <ntsymbol name="regexvar"/>
    </production>
  
  	<production ntsymbol="regexconcatenation" reducetype="append">
  	 <ntsymbol name="regexconcatenation"/><ntsymbol name="regexquantifier"/>
  	</production>
  
    <production ntsymbol="regexconcatenation" reducetype="resolve">
     <ntsymbol name="regexquantifier"/>
    </production>
  
    <production ntsymbol="regexalternation" reducetype="append">
  	 <ntsymbol name="regexalternation"/><tsymbol name="alt"/><ntsymbol name="regexconcatenation"/>
  	</production>
  
    <production ntsymbol="regexalternation" reducetype="resolve">
     <ntsymbol name="regexconcatenation"/>
    </production>
  
    <production ntsymbol="regexexpression">
  	 <ntsymbol name="regexalternation"/>
    </production>
  
    <production ntsymbol="grammar">
     <ntsymbol name="token_decls"/><tsymbol name="delimiter"/>
     <ntsymbol name="production_decls"/>
  	</production>
  
    <production ntsymbol="token_decls" reducetype="append">
     <ntsymbol name="token_decls"/> <ntsymbol name="token_decl"/>
    </production>
  
    <production ntsymbol="token_decls" reducetype="append">
     <ntsymbol name="token_decl"/>
    </production>
  
    <production ntsymbol="token_decls" reducetype="append">
     <ntsymbol name="token_decls"/><ntsymbol name="start_decl"/>
    </production>
  
    <production ntsymbol="token_decls" reducetype="append">
     <ntsymbol name="start_decl"/>
    </production>
  
    <production ntsymbol="token_decls" reducetype="append">
     <ntsymbol name="token_decls"/><ntsymbol name="ignorabletoken_decl"/>
    </production>
  
    <production ntsymbol="token_decls" reducetype="append">
     <ntsymbol name="ignorabletoken_decl"/>
    </production>
  
    <production ntsymbol="token_decls" reducetype="append">
     <ntsymbol name="token_decls"/><ntsymbol name="uri_decl"/>
    </production>
    
    <production ntsymbol="token_decls" reducetype="append">
     <ntsymbol name="uri_decl"/>
    </production>
  
    <production ntsymbol="token_decls" reducetype="append">
     <ntsymbol name="token_decls"/><ntsymbol name="ab_decl"/>
    </production>
    
    <production ntsymbol="token_decls" reducetype="append">
     <ntsymbol name="ab_decl"/>
    </production>
  
    <production ntsymbol="token_decl">
     <tsymbol name="token_decl"/><tsymbol name="id"/><ntsymbol name="regexexpression"/><tsymbol name="semicolon"/>
    </production>
  
    <production ntsymbol="start_decl">
     <tsymbol name="start_decl"/><tsymbol name="id"/><tsymbol name="semicolon"/>
    </production>
  
    <production ntsymbol="ignorabletoken_decl">
     <tsymbol name="ignorabletoken_decl"/><tsymbol name="id"/><ntsymbol name="regexexpression"/>
     <tsymbol name="semicolon"/>
    </production>
  
    <production ntsymbol="uri_decl">
     <tsymbol name="uri_decl"/><tsymbol name="string"/><tsymbol name="semicolon"/>
    </production>
  
    <production ntsymbol="ab_decl">
     <tsymbol name="ab_decl"/><tsymbol name="id"/><ntsymbol name="regexexpression"/><tsymbol name="semicolon"/>
    </production>
  
    <production ntsymbol="production_decls" reducetype="append">
     <ntsymbol name="production_decls"/><ntsymbol name="production_decl"/>
    </production>
  
    <production ntsymbol="production_decls" reducetype="append">
     <ntsymbol name="production_decl"/>
    </production>
  
    <production ntsymbol="production_decl">
     <tsymbol name="id"/><tsymbol name="colon"/><ntsymbol name="production_defs"/><tsymbol name="semicolon"/>
    </production>
  
    <production ntsymbol="production_defs" reducetype="append">
     <ntsymbol name="production_defs"/><tsymbol name="alt"/><ntsymbol name="production_def"/>
    </production>
   
    <production ntsymbol="production_defs" reducetype="append">
     <ntsymbol name="production_def"/>
    </production>
  
    <production ntsymbol="prec_decl" reducetype="append">
     <tsymbol name="prec_decl"/><tsymbol name="id"/>
    </production>
  
    <production ntsymbol="production_def" reducetype="append">
     <ntsymbol name="ids"/>
    </production>
  
    <production ntsymbol="production_def" reducetype="append">
     <ntsymbol name="ids"/><ntsymbol name="prec_decl"/>
    </production>
  
    <production ntsymbol="production_def" reducetype="append">
     <ntsymbol name="ids"/><tsymbol name="reducetype_decl"/>
    </production>
  
    <production ntsymbol="production_def" reducetype="append">
     <ntsymbol name="ids"/><ntsymbol name="prec_decl"/><tsymbol name="reducetype_decl"/>
    </production>
  
    <production ntsymbol="ids" reducetype="append">
     <ntsymbol name="ids"/><tsymbol name="id"/>
    </production>
  
    <production ntsymbol="ids" reducetype="append">
     <tsymbol name="id"/>
    </production>
   </productions>
  
   <ssymbol ntsymbol="grammar"/>
  </grammar>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/grammars/wiki.grm
  
  Index: wiki.grm
  ===================================================================
  <?xml version="1.0" encoding="US-ASCII"?>
  <!--<!DOCTYPE grammar PUBLIC "-//Chaperon//DTD grammar 1.0//EN" "grammar.dtd">-->
  <grammar uri="http://chaperon.sourceforge.net/grammar/wiki/1.0">
  <tokens>
  <token tsymbol="LINE">
  <concat>
  <string content="---"/>
  <concat maxOccurs="*" minOccurs="1">
  <string content="-"/>
  </concat>
  </concat>
  </token>
  <token tsymbol="QUOTE">
  <string content=":"/>
  </token>
  <token tsymbol="BULLETED">
  <concat maxOccurs="*" minOccurs="1">
  <string content="*"/>
  </concat>
  </token>
  <token tsymbol="NUMBERED3">
  <string content="###"/>
  </token>
  <token tsymbol="NUMBERED2">
  <string content="##"/>
  </token>
  <token tsymbol="NUMBERED1">
  <string content="#"/>
  </token>
  <token tsymbol="HEAD">
  <concat maxOccurs="*" minOccurs="1">
  <string content="!"/>
  </concat>
  </token>
  <token assoc="left" tsymbol="ITALIC">
  <string content="&quot;"/>
  </token>
  <token assoc="left" tsymbol="BOLD">
  <string content="__"/>
  </token>
  <token assoc="left" tsymbol="UNDERLINE">
  <string content="_"/>
  </token>
  <token tsymbol="LINK">
  <concat>
  <alt>
  <string content="http"/>
  <string content="ftp"/>
  <string content="mailto"/>
  <string content="news"/>
  </alt>
  <string content=":"/>
  <concat minOccurs="1" maxOccurs="3">
  <string content="/"/>
  </concat>
  <concat maxOccurs="*" minOccurs="0">
  <cc>
  <ci min="A" max="Z"/>
  <ci min="a" max="z"/>
  <ci min="0" max="9"/>
  <cs content="."/>
  <cs content="_"/>
  <cs content="-"/>
  </cc>
  </concat>
  </concat>
  </token>
  <token tsymbol="BOPEN">
  <string content="["/>
  </token>
  <token tsymbol="BCLOSE">
  <string content="]"/>
  </token>
  <token tsymbol="TEXT">
  <concat>
  <concat maxOccurs="*" minOccurs="1">
  <cc>
  <ci min="A" max="Z"/>
  <ci min="a" max="z"/>
  <ci min="0" max="9"/>
  <cs content=","/>
  <cs content="'"/>
  <cs content="."/>
  <cs content="?"/>
  <cs content=":"/>
  </cc>
  </concat>
  <concat maxOccurs="*" minOccurs="0">
  <cc>
  <ci min="A" max="Z"/>
  <ci min="a" max="z"/>
  <ci min="0" max="9"/>
  <cs content=" "/>
  <cs content="	"/>
  <cs content=","/>
  <cs content="'"/>
  <cs content="."/>
  <cs content="?"/>
  <cs content="!"/>
  <cs content=":"/>
  </cc>
  </concat>
  </concat>
  </token>
  <token assoc="left" tsymbol="EMPTY">
  <alt>
  <concat>
  <string content="&#10;"/>
  <concat maxOccurs="*" minOccurs="0">
  <cc>
  <cs content=" "/>
  <cs content="	"/>
  </cc>
  </concat>
  <string content="&#10;"/>
  </concat>
  <concat>
  <string content="&#13;"/>
  <concat maxOccurs="*" minOccurs="0">
  <cc>
  <cs content=" "/>
  <cs content="	"/>
  </cc>
  </concat>
  <string content="&#13;"/>
  </concat>
  <concat>
  <string content="&#10;"/>
  <concat maxOccurs="*" minOccurs="0">
  <cc>
  <cs content=" "/>
  <cs content="	"/>
  </cc>
  </concat>
  <string content="&#10;"/>
  </concat>
  </alt>
  </token>
  <token tsymbol="EOL">
  <alt>
  <concat>
  <string content="&#13;"/>
  <concat maxOccurs="1" minOccurs="0">
  <string content="&#10;"/>
  </concat>
  </concat>
  <string content="&#10;"/>
  </alt>
  </token>
  </tokens>
   <ignorabletokens>
    <token tsymbol="whitespace">
  <concat maxOccurs="*" minOccurs="1">
  <cc>
  <cs content=" "/>
  <cs content="&#13;"/>
  <cs content="&#10;"/>
  </cc>
  </concat>
    </token>
   </ignorabletokens>
  <productions>
  <production ntsymbol="wiki" reducetype="append">
  <ntsymbol name="wiki"/>
  <ntsymbol name="paragraphs"/>
  </production>
  <production ntsymbol="wiki" reducetype="append">
  <ntsymbol name="paragraphs"/>
  </production>
  <production ntsymbol="paragraphs" reducetype="append">
  <ntsymbol name="paragraphs"/>
  <ntsymbol name="paragraph"/>
  </production>
  <production ntsymbol="paragraphs" reducetype="append">
  <ntsymbol name="paragraph"/>
  </production>
  <production ntsymbol="paragraph">
  <ntsymbol name="bulletedlist"/>
  </production>
  <production ntsymbol="paragraph">
  <ntsymbol name="numberedlist1"/>
  </production>
  <production ntsymbol="paragraph">
  <ntsymbol name="textitem"/>
  </production>
  <production ntsymbol="paragraph">
  <ntsymbol name="headitem"/>
  </production>
  <production ntsymbol="paragraph">
  <ntsymbol name="footnote"/>
  </production>
  <production ntsymbol="paragraph">
  <tsymbol name="LINE"/>
  </production>
  <production ntsymbol="paragraph">
  <tsymbol name="EMPTY"/>
  </production>
  <production ntsymbol="bulletedlist" reducetype="append">
  <ntsymbol name="bulletedlist"/>
  <ntsymbol name="bulletedlistitem"/>
  </production>
  <production ntsymbol="bulletedlist" reducetype="append">
  <ntsymbol name="bulletedlistitem"/>
  </production>
  <production ntsymbol="bulletedlistitem">
  <tsymbol name="BULLETED"/>
  <ntsymbol name="textblock"/>
  <ntsymbol name="textsequence"/>
  </production>
  <production ntsymbol="bulletedlistitem">
  <tsymbol name="BULLETED"/>
  <ntsymbol name="textblock"/>
  </production>
  <production ntsymbol="numberedlist1" reducetype="append">
  <ntsymbol name="numberedlist1"/>
  <ntsymbol name="numberedlistitem1"/>
  </production>
  <production ntsymbol="numberedlist1" reducetype="append">
  <ntsymbol name="numberedlistitem1"/>
  </production>
  <production ntsymbol="numberedlist1" reducetype="append">
  <ntsymbol name="numberedlist1"/>
  <ntsymbol name="numberedlist2"/>
  </production>
  <production ntsymbol="numberedlist1" reducetype="append">
  <ntsymbol name="numberedlist2"/>
  </production>
  <production ntsymbol="numberedlistitem1">
  <tsymbol name="NUMBERED1"/>
  <ntsymbol name="textblock"/>
  <ntsymbol name="textsequence"/>
  </production>
  <production ntsymbol="numberedlistitem1">
  <tsymbol name="NUMBERED1"/>
  <ntsymbol name="textblock"/>
  </production>
  <production ntsymbol="numberedlist2" reducetype="append">
  <ntsymbol name="numberedlist2"/>
  <ntsymbol name="numberedlistitem2"/>
  </production>
  <production ntsymbol="numberedlist2" reducetype="append">
  <ntsymbol name="numberedlistitem2"/>
  </production>
  <production ntsymbol="numberedlist2" reducetype="append">
  <ntsymbol name="numberedlist2"/>
  <ntsymbol name="numberedlist3"/>
  </production>
  <production ntsymbol="numberedlist2" reducetype="append">
  <ntsymbol name="numberedlist3"/>
  </production>
  <production ntsymbol="numberedlistitem2">
  <tsymbol name="NUMBERED2"/>
  <ntsymbol name="textblock"/>
  <ntsymbol name="textsequence"/>
  </production>
  <production ntsymbol="numberedlistitem2">
  <tsymbol name="NUMBERED2"/>
  <ntsymbol name="textblock"/>
  </production>
  <production ntsymbol="numberedlist3" reducetype="append">
  <ntsymbol name="numberedlist3"/>
  <ntsymbol name="numberedlistitem3"/>
  </production>
  <production ntsymbol="numberedlist3" reducetype="append">
  <ntsymbol name="numberedlistitem3"/>
  </production>
  <production ntsymbol="numberedlistitem3">
  <tsymbol name="NUMBERED3"/>
  <ntsymbol name="textblock"/>
  <ntsymbol name="textsequence"/>
  </production>
  <production ntsymbol="numberedlistitem3">
  <tsymbol name="NUMBERED3"/>
  <ntsymbol name="textblock"/>
  </production>
  <production ntsymbol="textitem">
  <ntsymbol name="firstblock"/>
  <ntsymbol name="textblock"/>
  <ntsymbol name="textsequence"/>
  </production>
  <production ntsymbol="textitem">
  <ntsymbol name="firstblock"/>
  <ntsymbol name="textblock"/>
  </production>
  <production ntsymbol="textitem">
  <ntsymbol name="firstblock"/>
  </production>
  <production ntsymbol="headitem">
  <tsymbol name="HEAD"/>
  <ntsymbol name="textblock"/>
  <ntsymbol name="textsequence"/>
  </production>
  <production ntsymbol="headitem">
  <tsymbol name="HEAD"/>
  <ntsymbol name="textblock"/>
  </production>
  <production ntsymbol="footnote">
  <ntsymbol name="note"/>
  <ntsymbol name="textblock"/>
  <ntsymbol name="textsequence"/>
  </production>
  <production ntsymbol="footnote">
  <ntsymbol name="note"/>
  <ntsymbol name="textblock"/>
  </production>
  <production ntsymbol="textsequence" reducetype="resolve">
  <ntsymbol name="textsequence"/>
  <tsymbol name="EOL"/>
  </production>
  <production ntsymbol="textsequence" reducetype="resolve">
  <tsymbol name="EOL"/>
  </production>
  <production ntsymbol="textsequence" reducetype="resolve">
  <ntsymbol name="textsequence"/>
  <ntsymbol name="textblock"/>
  </production>
  <production ntsymbol="textsequence" reducetype="resolve">
  <ntsymbol name="textblock"/>
  </production>
  <production ntsymbol="textblock">
  <tsymbol name="LINK"/>
  </production>
  <production ntsymbol="textblock">
  <ntsymbol name="boldblock"/>
  </production>
  <production ntsymbol="textblock">
  <ntsymbol name="italicblock"/>
  </production>
  <production ntsymbol="textblock">
  <ntsymbol name="underlineblock"/>
  </production>
  <production ntsymbol="textblock">
  <tsymbol name="TEXT"/>
  </production>
  <production ntsymbol="textblock">
  <ntsymbol name="note"/>
  </production>
  <production ntsymbol="firstblock">
  <tsymbol name="LINK"/>
  </production>
  <production ntsymbol="firstblock">
  <ntsymbol name="boldblock"/>
  </production>
  <production ntsymbol="firstblock">
  <ntsymbol name="italicblock"/>
  </production>
  <production ntsymbol="firstblock">
  <ntsymbol name="underlineblock"/>
  </production>
  <production ntsymbol="firstblock">
  <tsymbol name="TEXT"/>
  </production>
  <production ntsymbol="italicblock">
  <tsymbol name="ITALIC"/>
  <tsymbol name="TEXT"/>
  <tsymbol name="ITALIC"/>
  </production>
  <production ntsymbol="boldblock">
  <tsymbol name="BOLD"/>
  <tsymbol name="TEXT"/>
  <tsymbol name="BOLD"/>
  </production>
  <production ntsymbol="underlineblock">
  <tsymbol name="UNDERLINE"/>
  <tsymbol name="TEXT"/>
  <tsymbol name="UNDERLINE"/>
  </production>
  <production ntsymbol="note">
  <tsymbol name="BOPEN"/>
  <tsymbol name="TEXT"/>
  <tsymbol name="BCLOSE"/>
  </production>
  <production ntsymbol="note">
  <tsymbol name="BOPEN"/>
  <tsymbol name="LINK"/>
  <tsymbol name="BCLOSE"/>
  </production>
  </productions>
  <ssymbol ntsymbol="wiki"/>
  </grammar>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/grammars/wiki.rgrm
  
  Index: wiki.rgrm
  ===================================================================
  %uri "http://chaperon.sourceforge.net/grammar/wiki/1.0";
  
  %token LINE \-\-\-(\-)+;
  
  %token QUOTE  :;
  %token BULLETED (\*)+;
  
  %token NUMBERED3 \#\#\#;
  %token NUMBERED2 \#\#;
  %token NUMBERED1 \#;
  
  %token HEAD (\!)+;
  
  %left ITALIC \";
  %left BOLD __;
  %left UNDERLINE _;
  
  %token LINK (http|ftp|mailto|news):(/){1,3}[A-Za-z0-9\.\_\-]*;
  
  %token BOPEN \[;
  %token BCLOSE \];
  
  %token TEXT [A-Za-z0-9\,\'\.\?\:]+[A-Za-z0-9\ \t\,\'\.\?\!\:]*;
  
  %left EMPTY \r\n [\ \t]* \r\n |
              \r   [\ \t]* \r   |
              \n   [\ \t]* \n   ;
  
  %token EOL (\r(\n)?|\n);
  
  
  %start wiki;
  
  %ignore whitespace [\ \r\n]+;
  
  %%
  
  wiki : wiki paragraphs %append
       | paragraphs      %append
       ;
  
  paragraphs : paragraphs paragraph %append
             | paragraph            %append
             ;
  
  paragraph : bulletedlist
            | numberedlist1
            | textitem 
            | headitem 
            | footnote
            | LINE
            | EMPTY
            ;
  
  bulletedlist : bulletedlist bulletedlistitem %append
               | bulletedlistitem              %append
               ;
  
  bulletedlistitem : BULLETED textblock textsequence
                   | BULLETED textblock
                   ;
  
  numberedlist1 : numberedlist1 numberedlistitem1 %append
                | numberedlistitem1               %append
                | numberedlist1 numberedlist2     %append
                | numberedlist2                   %append
                ;
  
  numberedlistitem1 : NUMBERED1 textblock textsequence
                    | NUMBERED1 textblock
                    ;
  
  numberedlist2 : numberedlist2 numberedlistitem2 %append
                | numberedlistitem2               %append
                | numberedlist2 numberedlist3     %append
                | numberedlist3                   %append
                ; 
  
  numberedlistitem2 : NUMBERED2 textblock textsequence
                    | NUMBERED2 textblock 
                    ;
  
  numberedlist3 : numberedlist3 numberedlistitem3 %append
                | numberedlistitem3               %append
                ; 
  
  numberedlistitem3 : NUMBERED3 textblock textsequence
                    | NUMBERED3 textblock 
                    ;
  
  textitem : firstblock textblock textsequence
           | firstblock textblock
           | firstblock
           ;
  
  headitem : HEAD textblock textsequence
           | HEAD textblock
           ;
  
  footnote : note textblock textsequence
           | note textblock
           ;
  
  textsequence : textsequence EOL       %resolve
               | EOL                    %resolve
               | textsequence textblock %resolve
               | textblock              %resolve
               ; 
  
  textblock : LINK                           
            | boldblock                      
            | italicblock            
            | underlineblock                
            | TEXT                         
            | note                         
            ;
  
  firstblock : LINK                 
             | boldblock                
             | italicblock                
             | underlineblock          
             | TEXT               
             ;
  
  italicblock : ITALIC TEXT ITALIC
              ;
  
  boldblock : BOLD TEXT BOLD
            ;
  
  underlineblock : UNDERLINE TEXT UNDERLINE 
                 ;
  
  note : BOPEN TEXT BCLOSE
       | BOPEN LINK BCLOSE
       ;
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/misc/index.html
  
  Index: index.html
  ===================================================================
  <?xml version="1.0" encoding="ASCII"?>
  <html>
   <head>
    <title>Chaperon Examples</title>
   </head>
   <body>
  
    <h1>Chaperon Examples</h1>
  
    <p>
     <ul>
      <li><a href="mathexp.html">Mathexp example</a></li>
      <li><a href="wiki.html">Wiki Example</a></li>
      <li><a href="java.html">Java Example (Need once 2-3min, for the parser table generation process)</a></li>
     </ul>
    </p>
  
   </body>
  </html>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/misc/java.css
  
  Index: java.css
  ===================================================================
  
  body { background-color: #FFFFFF; }
  
  body {  color: #000000}
  
  #Header  { color: #ffffff;  background-color:#8697a5 }
  
  #CharacerLiteral	{ color: #FF00FF; }
  #StringLiteral		{ color: #FF00FF; }
  #SingleLineComment	{ color: #008000; }
  #FormalComment		{ color: #008000; }
  #MultiLineComment	{ color: #008000; }
  #ABSTRACT		{ color: #0000FF ; font-weight: bold }
  #BOOLEAN		{ color: #0000FF ; font-weight: bold }
  #BREAK			{ color: #0000FF ; font-weight: bold }
  #BYTE			{ color: #0000FF ; font-weight: bold }
  #CASE			{ color: #0000FF ; font-weight: bold }
  #CATCH			{ color: #0000FF ; font-weight: bold }
  #CHAR			{ color: #0000FF ; font-weight: bold }
  #CLASS			{ color: #0000FF ; font-weight: bold }
  #CONST			{ color: #0000FF ; font-weight: bold }
  #CONTINUE		{ color: #0000FF ; font-weight: bold }
  #DEFAULT		{ color: #0000FF ; font-weight: bold }
  #DO			{ color: #0000FF ; font-weight: bold }
  #DOUBLE		{ color: #0000FF ; font-weight: bold }
  #ELSE			{ color: #0000FF ; font-weight: bold }
  #EXTENDS		{ color: #0000FF ; font-weight: bold }
  #FALSE			{ color: #0000FF ; font-weight: bold }
  #FINAL			{ color: #0000FF ; font-weight: bold }
  #FINALLY		{ color: #0000FF ; font-weight: bold }
  #FLOAT			{ color: #0000FF ; font-weight: bold }
  #FOR			{ color: #0000FF ; font-weight: bold }
  #GOTO			{ color: #0000FF ; font-weight: bold }
  #IF			{ color: #0000FF ; font-weight: bold }
  #IMPLEMENTS		{ color: #0000FF ; font-weight: bold }
  #IMPORT		{ color: #0000FF ; font-weight: bold }
  #INSTANCEOF		{ color: #0000FF ; font-weight: bold }
  #INT			{ color: #0000FF ; font-weight: bold }
  #INTERFACE		{ color: #0000FF ; font-weight: bold }
  #LONG			{ color: #0000FF ; font-weight: bold }
  #NATIVE		{ color: #0000FF ; font-weight: bold }
  #NEW			{ color: #0000FF ; font-weight: bold }
  #PACKAGE		{ color: #0000FF ; font-weight: bold }
  #PRIVATE		{ color: #0000FF ; font-weight: bold }
  #PROTECTED		{ color: #0000FF ; font-weight: bold }
  #PUBLIC		{ color: #0000FF ; font-weight: bold }
  #RETURN		{ color: #0000FF ; font-weight: bold }
  #SHORT			{ color: #0000FF ; font-weight: bold }
  #STATIC		{ color: #0000FF ; font-weight: bold }
  #SUPER			{ color: #0000FF ; font-weight: bold }
  #SWITCH		{ color: #0000FF ; font-weight: bold }
  #SYCHRONIZED		{ color: #0000FF ; font-weight: bold }
  #THIS			{ color: #0000FF ; font-weight: bold }
  #THROW			{ color: #0000FF ; font-weight: bold }
  #THROWS		{ color: #0000FF ; font-weight: bold }
  #TRANSIENT		{ color: #0000FF ; font-weight: bold }
  #TRUE			{ color: #0000FF ; font-weight: bold }
  #TRY			{ color: #0000FF ; font-weight: bold }
  #VOID			{ color: #0000FF ; font-weight: bold }
  #VOLATILE		{ color: #0000FF ; font-weight: bold }
  #WHILE			{ color: #0000FF ; font-weight: bold }
  #StrictFP			{ color: #0000FF ; font-weight: bold }
  #LITERAL	{ color: #b27b8c }
  #IDENTIFIER { color: #000000 }
  
  
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/misc/matex.xsp
  
  Index: matex.xsp
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <xsp:page language="java"
            xmlns:xsp="http://apache.org/xsp"
            xmlns:xsp-request="http://apache.org/xsp/request/2.0">
  
  <html>
   <head>
    <title>Matex Exmaple</title>
   </head>
   <body>
  
    <h1>Matex Exmaple</h1>
  
    <p>
   <textfragment xmlns="http://chaperon.sourceforge.net/schema/textfragment/1.0"><xsp-request:get-parameter name="text" 
    default="M^+(t) = {i} M^{p_0}_1 \\left( P_3^4 - PQP^5_667 + \\frac{PQ}67.89PQP - \\right)"/></textfragment>
    </p>
  
    <p>
     <form action="matex.html" method="get">
  
      <xsp:element name="input">
       <xsp:attribute name="name">text</xsp:attribute>
       <xsp:attribute name="type">text</xsp:attribute>
       <xsp:attribute name="size">80</xsp:attribute>
       <xsp:attribute name="maxlength">110</xsp:attribute>
       <xsp:attribute name="value"><xsp-request:get-parameter name="text" 
         default="M^+(t) = {i} M^{p_0}_1 \\left( P_3^4 - PQP^5_667 + \\frac{PQ}67.89PQP - \\right)"/></xsp:attribute>
      </xsp:element>
     </form>
    </p>
  
   </body>
  </html>
  
  </xsp:page>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/misc/mathexp.xsp
  
  Index: mathexp.xsp
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <xsp:page language="java"
            xmlns:xsp="http://apache.org/xsp"
            xmlns:xsp-request="http://apache.org/xsp/request/2.0">
  
  <html>
   <head>
    <title>Mathexp Example</title>
   </head>
   <body>
  
    <h1>Mathexp Example</h1>
  
    <p>
     <textfragment xmlns="http://chaperon.sourceforge.net/schema/textfragment/1.0"><xsp-request:get-parameter name="text" 
      default="3*a-5*6/7 + ( b-c)*5- b"/></textfragment>
    </p>
  
    <p>
     <form action="mathexp.html" method="post">
  
      <xsp:element name="input">
       <xsp:attribute name="name">text</xsp:attribute>
       <xsp:attribute name="type">text</xsp:attribute>
       <xsp:attribute name="size">80</xsp:attribute>
       <xsp:attribute name="maxlength">110</xsp:attribute>
       <xsp:attribute name="value"><xsp-request:get-parameter name="text" 
         default="3*a-5*6/7 + ( b-c)*5- b"/></xsp:attribute>
      </xsp:element>
     </form>
    </p>
  
   </body>
  </html>
  
  </xsp:page>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/misc/samples.xml
  
  Index: samples.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <samples xmlns:xlink="http://www.w3.org/1999/xlink">
  
   <group name="Main examples page.">
    <sample name="Back" href="..">to Cocoon examples main page</sample>
   </group>
  
   <group name="Mathexp example">
    <sample name="Mathexp" href="mathexp.html">This example demonstrate how parser can be use to
     parse input text, like mathematical expressions.</sample>
   </group>
  
   <group name="Wiki example">
    <sample name="Wiki" href="wiki.html">In this example the parser were used to build an online editor,
     which based on the very popular syntax of Wiki.</sample>
   </group>
  
   <group name="Syntax highlighting example">
    <sample name="Syntax highlighting" href="java1.html">The parser also be used to colorize
     some source code.
    </sample>
  
    <sample name="Syntax highlighting" href="java2.html">Another example.
    </sample>
   </group>
  
  </samples>
  
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/misc/test1.java
  
  Index: test1.java
  ===================================================================
  /*
   *  Copyright (C) Chaperon. All rights reserved.                               
   *  ------------------------------------------------------------------------- 
   *  This software is published under the terms of the Apache Software License 
   *  version 1.1, a copy of which has been included  with this distribution in 
   *  the LICENSE file.                                                         
   */
  
  package example;
  
  public class Example
  {
  
    public String concat(String param1, String param2) 
    {
      return param1 + param2;
    }
  
    public static void main(String[] args)
    {
      System.out.println("result is "+concat(args[0], args[1]));
    }
  }
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/misc/test2.java
  
  Index: test2.java
  ===================================================================
  /*
   *  Copyright (C) Chaperon. All rights reserved.                               
   *  ------------------------------------------------------------------------- 
   *  This software is published under the terms of the Apache Software License 
   *  version 1.1, a copy of which has been included  with this distribution in 
   *  the LICENSE file.                                                         
   */
  
  package net.sourceforge.chaperon.helpers;
  
  /**
   * The class maskes special characters
   *
   * @author Stephan Michels
   * @version %version%
   */
  public class Decoder
  {
  
    /**
     * Mask special characters
     *
     * @param string String
     *
     * @return Mask string
     */
    public static String decode(String string)
    {
      StringBuffer buffer = new StringBuffer();
  
      for (int i = 0; i < string.length(); i++)
      {
        if (string.charAt(i) == '\n')
          buffer.append("\\n");
        else if (string.charAt(i) == '\t')
          buffer.append("\\t");
        else if (string.charAt(i) == '\r')
          buffer.append("\\r");
        else if (string.charAt(i) == '\"')
          buffer.append("\"");
        else if (string.charAt(i) == '\\')
          buffer.append("\\");
        else if ((string.charAt(i) >= '!') && (string.charAt(i) <= '~'))
          buffer.append(string.charAt(i));
        else
        {
          String hexstring = Integer.toHexString((int) string.charAt(i));
          String zeros = "0000";
  
          buffer.append("\\u" + zeros.substring(4 - hexstring.length())
                        + hexstring);
        }
      }
      return buffer.toString();
    }
  }
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/misc/wiki.xsp
  
  Index: wiki.xsp
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <xsp:page language="java"
            xmlns:xsp="http://apache.org/xsp"
            xmlns:xsp-request="http://apache.org/xsp/request/2.0">
  
  <html>
   <head>
    <title>Wiki example</title>
    <style>
   .title
        {
          text-align: center;
          font-size: 18px;
          font-weight: bold;
          font-family: sans-serif,Arial,Tahoma;
          color: black;
          background: white;
          border-color: black;
          border-width: 10px;
        }
        
        .main
        {
          border: 1px solid #0086B2;
          padding: 0px;
          margin: 6px;
          min-width: 630px;
        }
        
        .head
        {
          border-bottom: #0086B2;
          border-width: 0 0 1px 0;
          border-style: none none solid none;
          padding: 6px 6px 3px 6px;
        }
        
        .block { padding: 6px; }
        
        .confirm
        {
          width: 40%;
          margin-left: 50%;
          padding: 6px;
        }
        
        .content
        {
          border: 1px solid #0086B2; 
          padding: 6px;
          margin: 1px;
        }
   
        tr 
        {
          padding: 2px 6px 2px 6px;
        }
             
      
        .col1
        {
          font-weight: bold;
        }
  
         .error .col1
        {
          padding: 2px 20px 2px 6px;
        }
  
         .error .col2
        {
          color:#BB0000;
          padding: 2px 20px 2px 6px;
        }
       
        .field { }
        
        .notify
        {
          font-size: 15px;
          text-align: left;
        }
        
        .tools { text-align: right; }
        .tool { padding: 6px; }
        
        .notes
        {
          font-size: 12px;
          font-weight: bold;
          color: white;
          background: #0086B2;
          text-align: left;
          padding: 6px 6px 3px 6px;
        }
        
        .foot
        {
          text-align: center;
          font-size: 12px;
          margin-top: 50px;
        }
        
        .hspace { margin: 30px; }
        #left { float: left; }
        #right { float: right; }
        #center { text-align: center; }
        #row { background: #EEFFFF; }
        
        .failure
        {
          font-weight: bold;
          color: #BB0000;
        }
        
        .warning
        {
          font-weight: bold;
          color: #BB0000;
        }
        
        .success
        {
          font-weight: bold;
          color: green;
        }
        
        .tab
        {
          font-size: 12px;
          font-weight: bold;
          color: white;
          background: #0086B2;
          padding: 4px 4px 2px 4px;
          border: 0px solid #0086B2;
          margin: 1px;
        }
        
        .tab a
        {
          text-decoration: none;
          color: white;
        }
        
        .tab a:visited
        {
          text-decoration: none;
          color: white;
        }
        
        .tab a:link
        {
          text-decoration: none;
          color: white;
        }
        
        .tab a:hover
        {
          text-decoration: underline;
          color: red;
        }
        
        a { text-decoration: none; }
        
        a:hover
        {
          text-decoration: underline;
          color: red;
        }
        
        body
        {
          font-size: 12px;
          font-family: sans-serif,Arial,Tahoma;
          color: black;
          background: white;
        }
        
        form { font-size: 12px; }
        
        textarea
        {
          background-color: #EEFFFF;
          font-size: 12px;
          font-family: geneva,arial,sans-serif;
          border-color: #0086B2;
          border-width: 1px;
          padding-left: 2px;
        }
        
        textarea.hidden { display: none; }
        
        input
        {
          background-color: #EEFFFF;
          font-size: 12px;
          font-family: geneva,arial,sans-serif;
          border-color: #0086B2;
          border-width: 1px;
          padding-left: 2px;
        }
        
        input.submit
        {
          background-color: #0086B2;
          font-size: 12px;
          font-family: geneva,arial,sans-serif;
          border-color: black;
          border-width: 1px;
          padding: 2px 6px;
          font-weight: bold;
          color: white;
        }
        
        input.button
        {
          background-color: #BB0000;
          font-size: 12px;
          font-family: geneva,arial,sans-serif;
          border-color: black;
          border-width: 1px;
          padding: 2px 6px;
          font-weight: bold;
          color: white;
        }
   </style>
   </head>
   <body>
  
    <div class="title">Wiki example</div>
  
    <p>
     <div class="block"><span class="tab">Preview</span><div class="content">
   <textfragment xmlns="http://chaperon.sourceforge.net/schema/textfragment/1.0"><xsp-request:get-parameter name="text" default="No text"/></textfragment>
     </div></div>
    </p>
  
    <p>
  
     <form action="wiki.html" method="post">
  
     <div class="block"><span class="tab">Content</span><div class="field">
  
     <textarea name="text" type="textarea" cols="100" rows="23" style="width: 100%">!Example heading
    
  !!bold and italics stuff
  Here's some __bold text__ and now &quot;some italic text I hope &quot;. Not
  sure about italics though.
  
  !!bullets
  * first bulleted item
  * second bulleted item
  
  !!numbered lists
  # number list point 1
  ## is that 1.1?
  ### is that 1.1.1?
  # this is point 2
  # and point 3
  
  We _love_ horizontal rules [1]
  ------------
  Brought to you by [http://www.perdu.com].
  
  [1] and footnotes too.
     </textarea><br/>
     </div></div>
  
     <div style="text-align:right" class="block">
     <input value="Preview" type="submit" class="submit"/>
     </div>
  
     </form>
    </p>
  
   </body>
  </html>
  
  </xsp:page>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/stylesheets/java2html.xsl
  
  Index: java2html.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                  xmlns:java="http://chaperon.sourceforge.net/grammar/java/1.0"
                  xmlns="http://www.w3.org/1999/xhtml">
  
   <xsl:output indent="no"/>
  
   <!--<xsl:strip-space elements="*"/>-->
   <xsl:param name="selected">MethodDeclaration</xsl:param>
  
   <xsl:template match="java:CompilationUnit" >
    <html>
     <head>
      <link rel="stylesheet" type="text/css" href="java.css" title="Style"/>
      <title>java2html example</title>
     </head>
     <body>
      <table id="Header" border="0" cellpadding="0" cellspacing="0" width="100%">
       <tr>
        <td colspan="2" width="33%">&#160;</td>
        <td align="center" colspan="2" width="33%">
         <font size="4">java2html example</font>
        </td>
        <td align="right" colspan="2" width="33%"></td>
       </tr>
      </table>
  <!--    <p>
       <form>
        <select size="1" name="selected">
         <option value=""><xsl:if test="$selected=''"><xsl:attribute name="selected"/></xsl:if>Nothing selected</option>
         <option value="QualifiedName"><xsl:if test="$selected='QualifiedName'"><xsl:attribute name="selected"/></xsl:if>Qualified name</option>
         <option value="FieldVariableDeclaration"><xsl:if test="$selected='FieldVariableDeclaration'"><xsl:attribute name="selected"/></xsl:if>Field variable declaration</option>
         <option value="MethodDeclaration"><xsl:if test="$selected='MethodDeclaration'"><xsl:attribute name="selected"/></xsl:if>Method declaration</option>
         <option value="SelectionStatement"><xsl:if test="$selected='SelectionStatement'"><xsl:attribute name="selected"/></xsl:if>Selection statement</option>
         <option value="IterationStatement"><xsl:if test="$selected='IterationStatement'"><xsl:attribute name="selected"/></xsl:if>Iteration statement</option>
         <option value="GuardingStatement"><xsl:if test="$selected='GuardingStatement'"><xsl:attribute name="selected"/></xsl:if>Guarding statement</option>
        </select>
       </form>
      </p>-->
      <pre id="Classes">
       <xsl:apply-templates/>
      </pre>
     </body>
    </html>
   </xsl:template>
  
   <xsl:template match="java:ABSTRACT">
    <font id="ABSTRACT"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:BOOLEAN">
    <font id="BOOLEAN"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:BREAK">
    <font id="BREAK"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:BYTE">
    <font id="BYTE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:CASE">
    <font id="CASE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:CATCH">
    <font id="CATCH"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:CHAR">
    <font id="CHAR"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:CLASS">
    <font id="CLASS"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:CONST">
    <font id="CONST"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:CONTINUE">
    <font id="CONTINUE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:DEFAULT">
    <font id="DEFAULT"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:DO">
    <font id="DO"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:DOUBLE">
    <font id="DOUBLE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:ELSE">
    <font id="ELSE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:EXTENDS">
    <font id="EXTENDS"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:FALSE">
    <font id="FALSE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:FINAL">
    <font id="FINAL"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:FINALLY">
    <font id="FINALLY"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:FLOAT">
    <font id="FLOAT"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:FOR">
    <font id="FOR"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:GOTO">
    <font id="GOTO"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:IF">
    <font id="IF"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:IMPLEMENTS">
    <font id="IMPLEMENTS"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:IMPORT">
    <font id="IMPORT"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:INSTANCEOF">
    <font id="INSTANCEOF"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:INT">
    <font id="INT"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:INTERFACE">
    <font id="INTERFACE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:LONG">
    <font id="LONG"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:NATIVE">
    <font id="NATIVE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:NEW">
    <font id="NEW"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:PACKAGE">
    <font id="PACKAGE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:PRIVATE">
    <font id="PRIVATE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:PROTECTED">
    <font id="PROTECTED"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:PUBLIC">
    <font id="PUBLIC"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:RETURN">
    <font id="RETURN"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:SHORT">
    <font id="SHORT"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:STATIC">
    <font id="STATIC"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:SUPER">
    <font id="SUPER"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:SWITCH">
    <font id="SWITCH"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:SYCHRONIZED">
    <font id="SYCHRONIZED"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:THIS">
    <font id="THIS"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:THROW">
    <font id="THROW"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:THROWS">
    <font id="THROWS"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:TRANSIENT">
    <font id="TRANSIENT"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:TRUE">
    <font id="TRUE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:TRY">
    <font id="TRY"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:VOID">
    <font id="VOID"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:VOLATILE">
    <font id="VOLATILE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:WHILE">
    <font id="WHILE"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:LITERAL">
    <font id="LITERAL"><xsl:apply-templates/></font>
   </xsl:template>
  
   <xsl:template match="java:IDENTIFIER">
    <font id="IDENTIFIER"><xsl:apply-templates/></font> 
   </xsl:template>
  
   <xsl:template match="java:DOPEN">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:DCLOSE">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:COPEN">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:CCLOSE">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:BOPEN">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:BCLOSE">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:SEMICOLON">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:COMMA">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:DOT">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_EQ">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_LE">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_GE">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_NE">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_LOR">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_LAND">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_INC">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_DEC">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_SHR">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_SHL">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OP_SHRR">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ASS_OP">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:EQ">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:GT">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:LT">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:NOT">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:TILDE">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:QM">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:COLON">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:PLUS">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:MINUS">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:MULT">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:DIV">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:AND">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:OR">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:XOR">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:MOD">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:BOOLLIT">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:eol">
    <xsl:text>
  </xsl:text>
   </xsl:template>
  
   <xsl:template match="java:whitespace">
    <!--<xsl:text><xsl:value-of select="."/></xsl:text>-->
    <xsl:value-of select="."/>
   </xsl:template>
  
   <xsl:template match="java:comment">
    <font id="MultiLineComment"><xsl:value-of select="."/></font>
   </xsl:template>
  
   <xsl:template match="java:TypeSpecifier">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:TypeName">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ClassNameList">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:PrimitiveType">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:SemiColons">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:ProgramFile">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:PackageStatement">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:TypeDeclarations">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:TypeDeclarationOptSemi">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:ImportStatements">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:ImportStatement">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:QualifiedName">
    <xsl:choose>
     <xsl:when test="$selected=local-name(.)">
      <span class="selected"><xsl:apply-templates/></span>
     </xsl:when>
     <xsl:otherwise>
      <xsl:apply-templates/>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:template>
    
   <xsl:template match="java:TypeDeclaration">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:ClassHeader">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:Modifiers">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:Modifier">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:ClassWord">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:Interfaces">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:FieldDeclarations">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:FieldDeclarationOptSemi">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:FieldDeclaration">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:FieldVariableDeclaration">
    <xsl:choose>
     <xsl:when test="$selected=local-name(.)">
      <span class="selected"><xsl:apply-templates/></span>
     </xsl:when>
     <xsl:otherwise>
      <xsl:apply-templates/>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:template>
    
   <xsl:template match="java:VariableDeclarators">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:VariableDeclarator">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:VariableInitializer">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:ArrayInitializers">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:MethodDeclaration">
    <xsl:choose>
     <xsl:when test="$selected=local-name(.)">
      <span class="selected"><xsl:apply-templates/></span>
     </xsl:when>
     <xsl:otherwise>
      <xsl:apply-templates/>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:template>
    
   <xsl:template match="java:MethodDeclarator">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:ParameterList">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:Parameter">
    <xsl:apply-templates/>
   </xsl:template>
    
   <xsl:template match="java:DeclaratorName">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:Throws">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:MethodBody">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ConstructorDeclaration">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ConstructorDeclarator">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:StaticInitializer">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:NonStaticInitializer">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:Extends">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:Block">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:LocalVariableDeclarationsAndStatements">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:LocalVariableDeclarationOrStatement">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:LocalVariableDeclarationStatement">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:Statement">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:EmptyStatement">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:LabelStatement">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ExpressionStatement">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:SelectionStatement">
    <xsl:choose>
     <xsl:when test="$selected=local-name(.)">
      <span class="selected"><xsl:apply-templates/></span>
     </xsl:when>
     <xsl:otherwise>
      <xsl:apply-templates/>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:template>
  
   <xsl:template match="java:IterationStatement">
    <xsl:choose>
     <xsl:when test="$selected=local-name(.)">
      <span class="selected"><xsl:apply-templates/></span>
     </xsl:when>
     <xsl:otherwise>
      <xsl:apply-templates/>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:template>
  
   <xsl:template match="java:ForInit">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ForExpr">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ForIncr">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ExpressionStatements">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:JumpStatement">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:GuardingStatement">
    <xsl:choose>
     <xsl:when test="$selected=local-name(.)">
      <span class="selected"><xsl:apply-templates/></span>
     </xsl:when>
     <xsl:otherwise>
      <xsl:apply-templates/>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:template>
  
   <xsl:template match="java:Catches">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:Catch">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:CatchHeader">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:Finally">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:PrimaryExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:NotJustName">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ComplexPrimary">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ComplexPrimaryNoParenthesis">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ArrayAccess">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:FieldAccess">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:MethodCall">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:MethodAccess">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:SpecialName">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ArgumentList">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:NewAllocationExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:PlainNewAllocationExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ClassAllocationExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ArrayAllocationExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:DimExprs">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:DimExpr">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:Dims">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:PostfixExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:RealPostfixExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:UnaryExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:LogicalUnaryExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:LogicalUnaryOperator">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ArithmeticUnaryOperator">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:CastExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:PrimitiveTypeExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ClassTypeExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:MultiplicativeExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:AdditiveExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ShiftExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:RelationalExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:EqualityExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:AndExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ExclusiveOrExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:InclusiveOrExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ConditionalAndExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ConditionalOrExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ConditionalExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:AssignmentExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:AssignmentOperator">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:Expression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="java:ConstantExpression">
    <xsl:apply-templates/>
   </xsl:template>
  
   <xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
    <xsl:copy>
     <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
    </xsl:copy>
   </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/stylesheets/mathexp2html.xsl
  
  Index: mathexp2html.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                  xmlns:m="http://chaperon.sourceforge.net/grammar/mathexp/1.0"
                  xmlns="http://www.w3.org/1999/xhtml" version="1.0">
  
  
   <xsl:template match="m:E">
    <table bgcolor="#a0ffff" cellspacing="1">
     <tr>
      <xsl:for-each select="child::node()">
       <td>
        <xsl:apply-templates select="."/>
       </td>
      </xsl:for-each>
     </tr>
    </table>
   </xsl:template>
  
   <xsl:template match="m:F">
    <table bgcolor="#ffffa0" cellspacing="1">
     <tr>
      <xsl:for-each select="child::node()">
       <td>
        <xsl:apply-templates select="."/>
       </td>
      </xsl:for-each>
     </tr>
    </table>
   </xsl:template>
  
   <xsl:template match="m:T">
    <table bgcolor="#ffa0ff" cellspacing="1">
     <tr>
      <xsl:for-each select="child::node()">
       <td>
        <xsl:apply-templates select="."/>
       </td>
      </xsl:for-each>
     </tr>
    </table>
   </xsl:template>
  
   <xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
    <xsl:copy>
     <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
    </xsl:copy>
   </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/stylesheets/parsefragment.xsl
  
  Index: parsefragment.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:tf="http://chaperon.sourceforge.net/schema/textfragment/1.0">
  
   <xsl:param name="parse_element">math</xsl:param>
  
   <xsl:template match="*[name()=$parse_element]">
    <xsl:element name="{$parse_element}">
     <tf:textfragment>
      <xsl:value-of select="."/>
     </tf:textfragment>
    </xsl:element>
   </xsl:template>
  
    <xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
      <xsl:copy>
        <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
      </xsl:copy>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/stylesheets/rgrm2grm.xsl
  
  Index: rgrm2grm.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                  xmlns:rgrm="http://chaperon.sourceforge.net/grammar/rgrm/1.0"
                  xmlns="http://chaperon.sourceforge.net/schema/grammar/1.0">
  
   <xsl:output indent="yes" method="xml" encoding="US-ASCII"/>
  
  <!-- <xsl:template match="/">
   </xsl:template>-->
  
   <xsl:template match="rgrm:grammar" >
    <grammar>
     <xsl:attribute name="uri"><xsl:value-of select="substring(rgrm:token_decls/rgrm:uri_decl/rgrm:string,2,
                           string-length(rgrm:token_decls/rgrm:uri_decl/rgrm:string)-2)"/></xsl:attribute>
     <tokens>
      <xsl:apply-templates select="rgrm:token_decls/rgrm:token_decl"/>
     </tokens>
  
     <ignorabletokens>
      <xsl:apply-templates select="rgrm:token_decls/rgrm:ignorabletoken_decl"/>
     </ignorabletokens>
  
     <xsl:apply-templates select="rgrm:production_decls"/>
  
     <xsl:apply-templates select="rgrm:token_decls/rgrm:start_decl"/>
    </grammar>
   </xsl:template>
  
   <xsl:template match="rgrm:token_decl" >
    <token>
     <xsl:if test="rgrm:token_decl = '%left'">
      <xsl:attribute name="assoc">left</xsl:attribute>
     </xsl:if>
     <xsl:if test="rgrm:token_decl = '%right'">
      <xsl:attribute name="assoc">right</xsl:attribute>
     </xsl:if>
     <xsl:attribute name="tsymbol"><xsl:value-of select="rgrm:id"/></xsl:attribute>
     <xsl:apply-templates select="rgrm:regexexpression"/>
    </token>
   </xsl:template>
  
   <xsl:template match="rgrm:ignorabletoken_decl" >
    <token>
     <xsl:attribute name="tsymbol"><xsl:value-of select="rgrm:id"/></xsl:attribute>
     <xsl:apply-templates select="rgrm:regexexpression"/>
    </token>
   </xsl:template>
  
   <xsl:template match="rgrm:regexexpression" >
    <xsl:apply-templates
      select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
              rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|
              rgrm:regexdot|rgrm:regexbol|rgrm:regexeol|rgrm:regexabref"/>
   </xsl:template>
  
   <xsl:template match="rgrm:regexalternation" >
    <alt>
     <xsl:apply-templates
       select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
               rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|rgrm:regexdot|rgrm:regexbol|rgrm:regexeol|rgrm:regexabref"/>
    </alt>
   </xsl:template>
  
   <xsl:template match="rgrm:regexconcatenation" >
    <concat>
     <xsl:apply-templates
       select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
               rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|rgrm:regexdot|rgrm:regexbol|rgrm:regexeol|rgrm:regexabref"/>
    </concat>
   </xsl:template>
  
   <xsl:template match="rgrm:regexquantifier" >
    <xsl:apply-templates
      select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
              rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|rgrm:regexdot|rgrm:regexbol|rgrm:regexeol|rgrm:regexabref"/>
   </xsl:template>
  
   <xsl:template match="rgrm:regexoptional" >
    <concat minOccurs="0" maxOccurs="1">
     <xsl:apply-templates
       select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
               rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|rgrm:regexdot|rgrm:regexbol|rgrm:regexeol|rgrm:regexabref"/>
    </concat>
   </xsl:template>
  
   <xsl:template match="rgrm:regexstar" >
    <concat minOccurs="0" maxOccurs="*">
     <xsl:apply-templates
       select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
               rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|rgrm:regexdot|rgrm:regexbol|rgrm:regexeol|rgrm:regexabref"/>
    </concat>
   </xsl:template>
  
   <xsl:template match="rgrm:regexplus" >
    <concat minOccurs="1" maxOccurs="*">
     <xsl:apply-templates
       select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
               rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|rgrm:regexdot|rgrm:regexbol|rgrm:regexeol|rgrm:regexabref"/>
    </concat>
   </xsl:template>
  
   <xsl:template match="rgrm:regexvar" >
    <xsl:choose>
     <xsl:when test="count(rgrm:regexmultiplicator/rgrm:number)=2">
      <concat>
       <xsl:attribute name="minOccurs"><xsl:value-of select="rgrm:regexmultiplicator/rgrm:number[1]"/></xsl:attribute>
       <xsl:attribute name="maxOccurs"><xsl:value-of select="rgrm:regexmultiplicator/rgrm:number[2]"/></xsl:attribute>
       <xsl:apply-templates
         select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
                 rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|rgrm:regexdot|rgrm:regexbol|rgrm:regexeol|rgrm:regexabref"/>
      </concat>
     </xsl:when>
     <xsl:otherwise>
      <concat>
       <xsl:attribute name="minOccurs"><xsl:value-of select="rgrm:regexmultiplicator/rgrm:number"/></xsl:attribute>
       <xsl:attribute name="maxOccurs"><xsl:value-of select="rgrm:regexmultiplicator/rgrm:number"/></xsl:attribute>
       <xsl:apply-templates
         select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
                 rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|rgrm:regexdot|rgrm:regexbol|rgrm:regexeol|rgrm:regexabref"/>
      </concat>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:template>
  
   <xsl:template match="rgrm:regexterm" >
    <xsl:apply-templates
      select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
              rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|rgrm:regexabref"/>
   </xsl:template>
  
   <xsl:template match="rgrm:regexklammer" >
    <xsl:apply-templates
      select="rgrm:regexalternation|rgrm:regexconcatenation|rgrm:regexklammer|rgrm:regexoptional|rgrm:regexstar|
              rgrm:regexplus|rgrm:regexvar|rgrm:string|rgrm:characterclass|rgrm:negatedcharacterclass|rgrm:regexabref"/>
   </xsl:template>
  
   <xsl:template match="rgrm:regexdot" >
    <dot/>
   </xsl:template>
  
   <xsl:template match="rgrm:regexbol" >
    <bol/>
   </xsl:template>
  
   <xsl:template match="rgrm:regexeol" >
    <eol/>
   </xsl:template>
  
   <xsl:template match="rgrm:regexabref" >
    <xsl:variable name="ref" select="rgrm:id"/>
    <xsl:apply-templates select="/rgrm:grammar/rgrm:token_decls/rgrm:ab_decl[rgrm:id=$ref]/rgrm:regexexpression"/>
   </xsl:template>
  
   <!--<xsl:template match="string" >
    <string>
     <xsl:attribute name="content"><xsl:value-of select="translate(normalize-space(substring(., 2, string-length(.)-2)),' ', '')"/></xsl:attribute>
    </string>
   </xsl:template>-->
  
   <xsl:template match="rgrm:string" >
    <string>
     <xsl:attribute name="content"><xsl:apply-templates select="rgrm:character|rgrm:maskedcharacter" mode="string"/></xsl:attribute>
    </string>
   </xsl:template>
  
   <xsl:template match="rgrm:characterclass" >
    <cc>
     <xsl:apply-templates select="rgrm:character|rgrm:maskedcharacter|rgrm:intervall"/>
    </cc>
   </xsl:template>
  
   <xsl:template match="rgrm:negatedcharacterclass" >
    <ncc>
     <xsl:apply-templates select="rgrm:character|rgrm:maskedcharacter|rgrm:intervall"/>
    </ncc>
   </xsl:template>
  
   <xsl:template match="rgrm:character" >
    <cs>
     <xsl:attribute name="content"><xsl:value-of select="translate(normalize-space(.), ' ', '')"/></xsl:attribute>
    </cs>
   </xsl:template>
  
   <xsl:template match="rgrm:maskedcharacter" >
    <cs>
     <xsl:choose>
      <xsl:when test="substring(translate(normalize-space(.), ' ', ''), 2,1) = 'n'">
       <xsl:attribute name="content"><xsl:text disable-output-escaping="yes">&#10;</xsl:text></xsl:attribute>
      </xsl:when>
      <xsl:when test="substring(translate(normalize-space(.), ' ', ''), 2,1) = 'r'">
       <xsl:attribute name="content"><xsl:text disable-output-escaping="yes">&#13;</xsl:text></xsl:attribute>
      </xsl:when>
      <xsl:when test="substring(translate(normalize-space(.), ' ', ''), 2,1) = 't'">
       <xsl:attribute name="content"><xsl:text disable-output-escaping="yes">&#9;</xsl:text></xsl:attribute>
      </xsl:when>
      <xsl:when test="contains(.,'\ ')">
       <xsl:attribute name="content"><xsl:text disable-output-escaping="yes">&#32;</xsl:text></xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
       <xsl:attribute name="content"><xsl:value-of select="substring(translate(normalize-space(.), ' ', ''), 2,1)"/></xsl:attribute>
      </xsl:otherwise>
     </xsl:choose>
    </cs>
   </xsl:template>
  
   <xsl:template match="rgrm:character" mode="string">
    <xsl:value-of select="translate(normalize-space(.), ' ', '')"/>
   </xsl:template>
   
   <xsl:template match="rgrm:maskedcharacter" mode="string">
    <xsl:choose>
      <xsl:when test="substring(translate(normalize-space(.), ' ', ''), 2,1) = 'n'">
       <xsl:text disable-output-escaping="yes">&#10;</xsl:text>
      </xsl:when>
      <xsl:when test="substring(translate(normalize-space(.), ' ', ''), 2,1) = 'r'">
       <xsl:text disable-output-escaping="yes">&#13;</xsl:text>
      </xsl:when>
      <xsl:when test="substring(translate(normalize-space(.), ' ', ''), 2,1) = 't'">
       <xsl:text disable-output-escaping="yes">&#9;</xsl:text>
      </xsl:when>
      <xsl:when test="contains(.,'\ ')">
       <xsl:text disable-output-escaping="yes">&#32;</xsl:text>
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="substring(translate(normalize-space(.), ' ', ''),2,1)"/>
      </xsl:otherwise>
     </xsl:choose>
   </xsl:template>
  
   <xsl:template match="rgrm:intervall" >
    <ci>
     <xsl:attribute name="min"><xsl:value-of select="rgrm:character[1]"/></xsl:attribute>
     <xsl:attribute name="max"><xsl:value-of select="rgrm:character[2]"/></xsl:attribute>
    </ci>
   </xsl:template>
  
   <xsl:template match="rgrm:comment_decl" >
    <comment>
     <xsl:apply-templates select="rgrm:regexexpression"/>
    </comment>
   </xsl:template>
  
   <xsl:template match="rgrm:whitespace_decl" >
    <whitespace>
     <xsl:apply-templates select="rgrm:regexexpression"/>
    </whitespace>
   </xsl:template>
  
   <xsl:template match="rgrm:production_decls" >
    <productions>
     <xsl:for-each select="rgrm:production_decl/rgrm:production_defs/rgrm:production_def">
      <production>
       <xsl:attribute name="ntsymbol"><xsl:value-of select="../../rgrm:id"/></xsl:attribute>
       
       <xsl:choose>
        <xsl:when test="rgrm:reducetype_decl[.='%append']">
         <xsl:attribute name="reducetype">append</xsl:attribute>
        </xsl:when>
        <xsl:when test="rgrm:reducetype_decl[.='%resolve']">
         <xsl:attribute name="reducetype">resolve</xsl:attribute>
        </xsl:when>
        <xsl:when test="rgrm:reducetype_decl[.='%neglect']">
         <xsl:attribute name="reducetype">neglect</xsl:attribute>
        </xsl:when>
       </xsl:choose>
  
       <xsl:if test="rgrm:prec_decl">
        <xsl:attribute name="prec"><xsl:value-of select="rgrm:prec_decl/rgrm:id"/></xsl:attribute>
       </xsl:if>
  
       <xsl:apply-templates select="rgrm:ids/rgrm:id"/>
      </production>
     </xsl:for-each>
    </productions>
   </xsl:template>
  
   <xsl:template match="rgrm:id" >
    <xsl:variable name="symbol" select="text()"/>
    <xsl:choose>
     <xsl:when test="/rgrm:grammar/rgrm:token_decls/rgrm:token_decl/rgrm:id[.=$symbol]">
      <tsymbol>
       <xsl:attribute name="name"><xsl:value-of select="."/></xsl:attribute>
      </tsymbol>
     </xsl:when>
     <xsl:otherwise>
      <ntsymbol>
        <xsl:attribute name="name"><xsl:value-of select="."/></xsl:attribute>
      </ntsymbol>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:template>
  
   <xsl:template match="rgrm:start_decl" >
    <ssymbol>
     <xsl:attribute name="ntsymbol"><xsl:value-of select="rgrm:id"/></xsl:attribute>
    </ssymbol>
   </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/chaperon/stylesheets/wiki2html.xsl
  
  Index: wiki2html.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                  xmlns:wiki="http://chaperon.sourceforge.net/grammar/wiki/1.0"
                  xmlns="http://www.w3.org/1999/xhtml">
  
   <xsl:output indent="yes" method="html"/>
  
   <xsl:template match="/">
    <xsl:choose>
     <xsl:when test="wiki:wiki">
      <html>
       <head>
        <title>Wiki example</title>
       </head>
       <body>
        <xsl:apply-templates select="wiki:wiki/wiki:paragraphs/wiki:paragraph"/>
       </body>
      </html>   
     </xsl:when>
     <xsl:otherwise>
      <xsl:apply-templates/>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:template>
  
   <xsl:template match="//wiki">
    <div style="background: #b9d3ee; border: thin; border-color: black; border-style: solid; padding-left: 0.8em; 
                 padding-right: 0.8em; padding-top: 0px; padding-bottom: 0px; margin: 0.5ex 0px; clear: both;">
     <xsl:apply-templates select="paragraphs/paragraph"/>
    </div>
   </xsl:template>
  
   <xsl:template match="wiki:paragraph" >
    <xsl:apply-templates select="wiki:bulletedlist|wiki:numberedlist1|wiki:numberedlist2|wiki:numberedlist3|wiki:headitem|wiki:footnote|wiki:textitem|wiki:LINE"/>
   </xsl:template>
  
   <xsl:template match="wiki:textitem" >
    <p>
     <xsl:apply-templates select="wiki:firstblock|wiki:textblock"/>
    </p>
   </xsl:template>
  
   <xsl:template match="wiki:textblock" >
    <xsl:apply-templates select="wiki:LINK|wiki:boldblock|wiki:italicblock|wiki:underlineblock|wiki:TEXT|wiki:note"/>
   </xsl:template>
  
   <xsl:template match="wiki:firstblock" >
    <xsl:apply-templates select="wiki:LINK|wiki:boldblock|wiki:italicblock|wiki:underlineblock|wiki:TEXT"/>
   </xsl:template>
  
   <xsl:template match="wiki:LINE" >
    <hr/>
   </xsl:template>
  
   <xsl:template match="wiki:bulletedlist" >
    <ul>
     <xsl:apply-templates select="wiki:bulletedlistitem"/>
    </ul>
   </xsl:template>
  
   <xsl:template match="wiki:bulletedlistitem" >
    <li>
     <xsl:apply-templates select="wiki:textblock"/>
    </li>
   </xsl:template>
  
   <xsl:template match="wiki:numberedlist1" >
    <ol>
     <xsl:apply-templates select="wiki:numberedlistitem1|wiki:numberedlist2"/>
    </ol>
   </xsl:template>
  
   <xsl:template match="wiki:numberedlistitem1" >
    <li>
     <xsl:apply-templates select="wiki:textblock"/>
    </li>
   </xsl:template>
  
   <xsl:template match="wiki:numberedlist2" >
    <ol>
     <xsl:apply-templates select="wiki:numberedlistitem2|wiki:numberedlist3"/>
    </ol>
   </xsl:template>
      
   <xsl:template match="wiki:numberedlistitem2" >
    <li>
     <xsl:apply-templates select="wiki:textblock"/>
    </li>
   </xsl:template>
  
   <xsl:template match="wiki:numberedlist3" >
    <ol>
     <xsl:apply-templates select="wiki:numberedlistitem3"/>
    </ol>
   </xsl:template>
      
   <xsl:template match="wiki:numberedlistitem3" >
    <li>
     <xsl:apply-templates select="wiki:textblock"/>
    </li>
   </xsl:template>
  
   <xsl:template match="wiki:headitem" >
    <xsl:choose>
     <xsl:when test="string-length(wiki:HEAD)=2">
      <h2>
       <xsl:apply-templates select="wiki:textblock"/>
      </h2>
     </xsl:when>
     <xsl:when test="string-length(wiki:HEAD)=3">
      <h3>
       <xsl:apply-templates select="wiki:textblock"/>
      </h3>
     </xsl:when>
     <xsl:otherwise>
      <h1>
       <xsl:apply-templates select="wiki:textblock"/>
      </h1>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:template>
  
   <xsl:template match="wiki:footnote" >
    <a name="{normalize-space(wiki:note/wiki:TEXT|wiki:note/wiki:LINK)}">
     [<xsl:apply-templates select="wiki:note/wiki:TEXT|wiki:note/wiki:LINK"/>]
     <xsl:apply-templates select="wiki:textblock"/>
    </a>
   </xsl:template>
  
   <xsl:template match="wiki:LINK" >
    <a href="{normalize-space(.)}">
     <xsl:value-of select="."/>
    </a>
   </xsl:template>
  
   <xsl:template match="wiki:boldblock" >
    <b>
     <xsl:value-of select="wiki:TEXT"/>
    </b>
   </xsl:template>
  
   <xsl:template match="wiki:italicblock" >
    <i>
     <xsl:value-of select="wiki:TEXT"/>
    </i>
   </xsl:template>
  
   <xsl:template match="wiki:underlineblock" >
    <u>
     <xsl:value-of select="wiki:TEXT"/>
    </u><xsl:text> </xsl:text>
   </xsl:template>
  
   <xsl:template match="wiki:note" >
    <a href="#{normalize-space(wiki:TEXT|wiki:LINK)}">
     [<xsl:apply-templates select="wiki:TEXT|wiki:LINK"/>]
    </a>
   </xsl:template>
  
   <xsl:template match="wiki:TEXT" >
    <xsl:value-of select="."/>
   </xsl:template>
  
   <xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
    <xsl:copy>
     <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
    </xsl:copy>
   </xsl:template>
  
  </xsl:stylesheet>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org