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 2004/02/20 12:29:39 UTC

cvs commit: cocoon-2.1/src/blocks/chaperon/samples/stylesheets quote2page.xsl

stephan     2004/02/20 03:29:38

  Modified:    src/blocks/chaperon/samples sitemap.xmap
               src/blocks/chaperon/samples/grammars quote.grm
               src/blocks/chaperon/samples/misc samples.xml
               src/blocks/chaperon/samples/stylesheets quote2page.xsl
  Added:       src/blocks/chaperon/samples/misc quote1.txt quote2.txt
  Removed:     src/blocks/chaperon/samples/grammars quote.xgrm quote.xlex
               src/blocks/chaperon/samples/misc quote.txt
  Log:
  Add another CSV example.
  Update grammar to process empty cells, see
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27061
  
  Revision  Changes    Path
  1.19      +4 -4      cocoon-2.1/src/blocks/chaperon/samples/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/chaperon/samples/sitemap.xmap,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- sitemap.xmap	5 Feb 2004 14:37:42 -0000	1.18
  +++ sitemap.xmap	20 Feb 2004 11:29:38 -0000	1.19
  @@ -195,10 +195,10 @@
       <map:serialize type="html"/>
      </map:match>
   
  -   <map:match pattern="quote.html">
  -    <map:generate  type="text"    src="misc/quote.txt"/>
  -    <map:transform type="lexer"   src="grammars/quote.xlex"/>
  -    <map:transform type="parser"  src="grammars/quote.xgrm" label="ast"/>
  +   <map:match pattern="quote*.html">
  +    <map:generate  type="text"    src="misc/quote{1}.txt"/>
  +    <map:transform type="lexer"   src="cocoon:/quote.xlex"/>
  +    <map:transform type="parser"  src="cocoon:/quote.xgrm" label="ast"/>
       <map:transform                src="stylesheets/quote2page.xsl"/>
       <map:transform                src="context://samples/common/style/xsl/html/complex-page2html.xsl">
        <map:parameter name="contextPath" value="{request:contextPath}"/>
  
  
  
  1.3       +11 -3     cocoon-2.1/src/blocks/chaperon/samples/grammars/quote.grm
  
  Index: quote.grm
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/chaperon/samples/grammars/quote.grm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- quote.grm	11 Dec 2003 11:21:36 -0000	1.2
  +++ quote.grm	20 Feb 2004 11:29:38 -0000	1.3
  @@ -1,7 +1,7 @@
   %ignore          "^#(.*)";
   %token Comma     "\,";
   %token Value     "[^\n\r\,]+";
  -%token Break "\r(\n?) | \n";
  +%token Break     "\r(\n?) | \n";
   
   %start document;
   
  @@ -11,6 +11,7 @@
   document
     : rows Break
     | rows
  +  | /* empty */
     ;
   
   // each row seprated with one break
  @@ -22,6 +23,13 @@
                                                                                                                                                                                  
   // values separated by spaces
   row
  -  : row Comma Value
  -  | Value
  +  : row Comma column
  +  | column
     ;
  +
  +// allow empty columns
  +column
  +  : Value
  +  | /* empty */
  +  ;
  +
  
  
  
  1.6       +4 -1      cocoon-2.1/src/blocks/chaperon/samples/misc/samples.xml
  
  Index: samples.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/chaperon/samples/misc/samples.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- samples.xml	20 Jan 2004 15:23:58 -0000	1.5
  +++ samples.xml	20 Feb 2004 11:29:38 -0000	1.6
  @@ -39,8 +39,11 @@
    </group>
   
    <group name="Comma-Separated Values (CSV)">
  -  <sample name="Stock Quote" href="quote.html">
  +  <sample name="Stock Quote" href="quote1.html">
      This example processes a CSV file and generates a table from it.
  +  </sample>
  +  <sample name="Excel output" href="quote2.html">
  +   This example processes a CSV file generate by MS Excel.
     </sample>
    </group>
   
  
  
  
  1.1                  cocoon-2.1/src/blocks/chaperon/samples/misc/quote1.txt
  
  Index: quote1.txt
  ===================================================================
  Date,Open,High,Low,Close,Volume
  20021101,0.11,0.11,0.11,0.11,74000
  20021104,0.11,0.11,0.1,0.105,1166900
  20021105,0.1,0.105,0.1,0.105,759670
  20021106,0.1,0.105,0.1,0.105,101000
  20021107,0.105,0.105,0.097,0.097,808230
  20021108,0.1,0.105,0.1,0.1,685199
  20021111,0.105,0.11,0.1,0.1,1109000
  20021112,0.105,0.105,0.1,0.1,0
  20021113,0.105,0.11,0.105,0.105,564856
  20021114,0.105,0.105,0.1,0.105,617400
  20021115,0.105,0.11,0.105,0.11,343500
  20021118,0.11,0.11,0.105,0.11,427602
  20021119,0.11,0.11,0.105,0.105,458679
  20021120,0.11,0.115,0.11,0.115,669019
  20021121,0.115,0.14,0.115,0.135,2906144
  20021122,0.135,0.135,0.125,0.13,749000
  20021125,0.13,0.13,0.12,0.12,1417533
  20021126,0.125,0.125,0.12,0.12,505800
  20021127,0.12,0.12,0.115,0.115,195472
  20021128,0.115,0.12,0.11,0.12,322800
  20021129,0.12,0.12,0.115,0.115,371600
  20021202,0.115,0.115,0.11,0.11,1112575
  20021203,0.11,0.11,0.105,0.105,252652
  20021204,0.11,0.115,0.11,0.115,829171
  20021205,0.115,0.115,0.11,0.11,390148
  20021206,0.11,0.11,0.105,0.105,640881
  20021209,0.11,0.115,0.11,0.11,1809529
  20021210,0.11,0.11,0.105,0.105,1251090
  20021211,0.105,0.11,0.1,0.1,515300
  20021212,0.105,0.105,0.105,0.105,139000
  20021213,0.11,0.115,0.11,0.11,2567966
  20021216,0.115,0.115,0.11,0.115,605650
  20021217,0.115,0.115,0.105,0.11,1219014
  20021218,0.115,0.115,0.11,0.115,718090
  20021219,0.12,0.125,0.115,0.12,2068299
  20021220,0.12,0.125,0.12,0.125,954000
  20021223,0.12,0.12,0.115,0.12,153300
  20021224,0.12,0.12,0.12,0.12,554900
  20021225,0.12,0.12,0.12,0.12,0
  20021226,0.12,0.12,0.12,0.12,0
  20021227,0.12,0.125,0.12,0.12,537133
  20021230,0.12,0.125,0.115,0.115,1012467
  20021231,0.12,0.12,0.115,0.115,442733
  20030101,0.115,0.115,0.115,0.115,0
  20030102,0.12,0.12,0.115,0.115,218000
  20030103,0.12,0.12,0.115,0.12,640134
  20030106,0.12,0.12,0.115,0.12,922506
  20030107,0.125,0.125,0.115,0.12,529170
  20030108,0.12,0.12,0.11,0.115,586026
  20030109,0.12,0.135,0.115,0.135,6947552
  20030110,0.14,0.155,0.14,0.145,7828670
  20030113,0.15,0.15,0.135,0.14,3047764
  20030114,0.14,0.14,0.125,0.125,2840680
  20030115,0.125,0.13,0.12,0.125,1365666
  20030116,0.13,0.13,0.12,0.13,1208000
  20030117,0.13,0.13,0.12,0.12,1387520
  20030120,0.125,0.125,0.12,0.12,664292
  20030121,0.12,0.12,0.115,0.12,2164262
  20030122,0.12,0.13,0.12,0.13,2751434
  20030123,0.125,0.135,0.125,0.13,2718754
  20030124,0.135,0.135,0.13,0.13,1035888
  20030128,0.130,0.135,0.130,0.135,1933154
  20030129,0.135,0.135,0.130,0.130,681900
  20030130,0.130,0.130,0.125,0.125,661360
  
  
  
  1.1                  cocoon-2.1/src/blocks/chaperon/samples/misc/quote2.txt
  
  Index: quote2.txt
  ===================================================================
  DATE,EVENT,VENUE,RACE DISTANCE,ORGANISER,CONTAC No.
  JAN,,,,,
  17th,GAUTENG NORTH AQUATHLON CHAMPS,Blue Bay quarry,Standard (run-swim-run),JOHAN KOK,072 659 2014
  24th,TUKKIES TRIATHLON,ROODEPLAAT,1/2 Standard,ALBIE DE LANGE,082 453 0096
  31st,TRI CHAMPS  GAUTENG NORTH,ROODEPLAAT,Standard(swim-cycle-run),JEAN-PIERRE TEN NAPEL,082 358 4005
  FEB,,,,,
  8th,GARY WHITEHOUSE MEMORIAL,ROODEPLAAT,1/2 Standard(swim-cycle-run),HENNING VAN ASWEGEN,082 344 5641
  14th,GAUTENG NORTH TRIATHLON CLINIC,LC DE VILLIERS,,JAN VAN ROOYEN,083 601 8103
  28th,S.A. TRIATHLON CHAMPS,TBA,Standard (swim-cycle-run),,
  MAR,,,,,
  
  
  
  1.6       +16 -37    cocoon-2.1/src/blocks/chaperon/samples/stylesheets/quote2page.xsl
  
  Index: quote2page.xsl
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/chaperon/samples/stylesheets/quote2page.xsl,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- quote2page.xsl	20 Jan 2004 15:23:58 -0000	1.5
  +++ quote2page.xsl	20 Feb 2004 11:29:38 -0000	1.6
  @@ -12,58 +12,37 @@
      </header>
      <body>
       <section>
  -     <title>Stock quote</title>
  +     <title>CSV Example</title>
   
  -     <p>
  -      The example Comma-Separated Values (CSV) file is three months of end-of-day
  -      data for one particular stock symbol (data such as that obtained from
  -      <a href="http://finance.yahoo.com/">Yahoo Finance</a>).
  -     </p>
  -     <p>
  -      Here are the first 5 lines (total 64) of the input file ...
  -     </p>
  -     <pre>--------------------------------------------
  -20021101,0.11,0.11,0.11,0.11,74000
  -20021104,0.11,0.11,0.1,0.105,1166900
  -20021105,0.1,0.105,0.1,0.105,759670
  -20021106,0.1,0.105,0.1,0.105,101000
  -20021107,0.105,0.105,0.097,0.097,808230
  -...
  ---------------------------------------------</pre>
  -     <p>
  -      After processing with the Lexer Transformer and the Parser Transformer,
  -      here is the result ...
  -     </p>
        <table cellpadding="3" border="1">
  -      <tr>
  -       <th>Line #</th>
  -       <th>Date</th>
  -       <th>Open</th>
  -       <th>High</th>
  -       <th>Low</th>
  -       <th>Close</th>
  -       <th>Volume</th>
  -      </tr>
  -      <xsl:apply-templates select="st:document/st:rows"/>
  +      <xsl:apply-templates select="st:document/st:rows/st:row[1]" mode="title"/>
  +      <xsl:apply-templates select="st:document/st:rows/st:row[position()>1]"/>
        </table>
       </section>
      </body>
     </document>
    </xsl:template>
   
  - <xsl:template match="st:rows">
  -  <xsl:apply-templates select="st:row"/>
  + <xsl:template match="st:row" mode="title">
  +  <tr>
  +   <th>Line #</th>
  +   <xsl:apply-templates select="st:column" mode="title"/>
  +  </tr>
    </xsl:template>
   
    <xsl:template match="st:row">
     <tr>
  -   <td><xsl:number/></td>
  -   <xsl:apply-templates select="st:Value"/>
  +   <td><xsl:value-of select="position()"/></td>
  +   <xsl:apply-templates select="st:column"/>
     </tr>
    </xsl:template>
   
  - <xsl:template match="st:Value">
  -  <td><xsl:value-of select="."/></td>
  + <xsl:template match="st:column" mode="title">
  +  <th><xsl:value-of select="st:Value"/></th>
  + </xsl:template>
  +
  + <xsl:template match="st:column">
  +  <td><xsl:value-of select="st:Value"/></td>
    </xsl:template>
   
    <xsl:template match="@*|*|text()|processing-instruction()" priority="-1">