shannon     2002/07/15 07:02:20

  Added:       targets/cocoon/snippet snippet-xslt-options.html
  Log:
  release 2.0.3 update
  
  Revision  Changes    Path
  1.1                  xml-site/targets/cocoon/snippet/snippet-xslt-options.html
  
  Index: snippet-xslt-options.html
  ===================================================================
  <html xmlns:NetUtils="org.apache.cocoon.util.NetUtils">
  <head>
  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>Specifying Different XSLT Processor Options</title>
  <STYLE type="text/css">
  a.menu {
        color: #FFFFFF;
      text-align:left;               
      font-size:12px;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-weight:plain;
      text-decoration:none;
      padding-left: 14px
  }
  
  A.menu:hover {
        color: #FFCC00
  }
  
  
  .menutitle {
        color: #000000;
      text-align:left;               
      font-size:10px;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-weight:bold;
      padding-left: 8px
  }
  .menuselected {
        color: #FFCC00;
      text-align:left;               
      font-size:12px;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-weight:bold;
      padding-left: 14px
  }
  </STYLE>
  </head>
  <body bgcolor="#ffffff" marginheight="4" marginwidth="4" leftmargin="4" 
topmargin="4" alink="#cc0000" vlink="#0086b2" link="#039acc" text="#000000">
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
  <td align="left" valign="top" rowspan="3" height="60" width="135"><img 
border="0" vspace="0" hspace="0" src="images/logo.gif" height="60" 
width="135"></td><td background="images/line.gif" rowspan="1" colSpan="2" 
align="left" valign="top" height="0" width="100%"></td><td align="left" 
valign="top" rowspan="3" height="60" width="29"><img border="0" vspace="0" 
hspace="0" src="images/right.gif" height="60" width="29"></td>
  </tr>
  <tr>
  <td bgcolor="#0086b2" colspan="2" align="right" valign="top" height="35" 
width="100%"><font color="#ffffff" face="Verdana, Arial, Helvetica, sans-serif" 
size="5">Specifying Different XSLT Processor Options</font></td>
  </tr>
  <tr>
  <td background="images/bottom.gif" colspan="2" width="100%" valign="top" 
height="20" bgcolor="#0086b2" align="right">
  <table width="288" cellspacing="0" cellpadding="0" border="0">
  <tr>
  <td align="left" valign="top" height="20" width="96"><a target="new" 
href="http://xml.apache.org/";><img border="0" vspace="0" hspace="0" name="xml" 
src="images/button-xml-lo.gif" height="20" width="96" 
alt="http://xml.apache.org/";></a></td><td align="left" valign="top" height="20" 
width="96"><a target="new" href="http://www.apache.org/";><img border="0" 
vspace="0" hspace="0" name="asf" src="images/button-asf-lo.gif" height="20" 
width="96" alt="http://www.apache.org/";></a></td><td align="left" valign="top" 
height="20" width="96"><a target="new" href="http://www.w3.org/";><img 
border="0" vspace="0" hspace="0" name="w3c" src="images/button-w3c-lo.gif" 
height="20" width="96" alt="http://www.w3.org/";></a></td>
  </tr>
  </table>
  </td>
  </tr>
  </table>
  <table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr width="100%">
  <td align="left" valign="top" width="120">
  <table width="120" cellspacing="0" cellpadding="0" border="0" 
bgcolor="#a0a0a0">
  <tr>
  <td valign="top" align="left"><img width="120" vspace="0" 
src="images/join.gif" hspace="0" height="14" border="0"><br>
  </td>
  </tr>
  <tr 
xmlns:NetUtils="http://xml.apache.org/xslt/java/org.apache.cocoon.util.NetUtils";>
  <td valign="top" bgcolor="#959595" 
background="images/label-background_a.gif"><a class="menu" 
href="../index.html">Main</a></td>
  </tr>
  <tr 
xmlns:NetUtils="http://xml.apache.org/xslt/java/org.apache.cocoon.util.NetUtils";>
  <td background="images/label-background_b.gif" bgcolor="#959595" 
valign="top"><img width="120" height="6" src="images/separator.gif"><br>
  <span class="menutitle">Snippets</span></td>
  </tr>
  <tr 
xmlns:NetUtils="http://xml.apache.org/xslt/java/org.apache.cocoon.util.NetUtils";>
  <td valign="top" bgcolor="#959595" 
background="images/label-background_a.gif"><a class="menu" 
href="index.html">Index</a></td>
  </tr>
  <tr 
xmlns:NetUtils="http://xml.apache.org/xslt/java/org.apache.cocoon.util.NetUtils";>
  <td background="images/label-background_b.gif" bgcolor="#959595" 
valign="top"><img width="120" height="6" src="images/separator.gif"><br>
  <span class="menutitle">Using Cocoon</span></td>
  </tr>
  <tr 
xmlns:NetUtils="http://xml.apache.org/xslt/java/org.apache.cocoon.util.NetUtils";>
  <td valign="top" bgcolor="#959595" 
background="images/label-background_a.gif"><a class="menu" 
href="snippet-internal-pipeline.html">Internal Pipeline</a></td>
  </tr>
  <tr 
xmlns:NetUtils="http://xml.apache.org/xslt/java/org.apache.cocoon.util.NetUtils";>
  <td background="images/label-background_b.gif" bgcolor="#959595" 
valign="top"><img width="120" height="6" src="images/separator.gif"><br>
  <span class="menutitle">XSLT</span></td>
  </tr>
  <tr 
xmlns:NetUtils="http://xml.apache.org/xslt/java/org.apache.cocoon.util.NetUtils";>
  <td valign="top" bgcolor="#959595" 
background="images/label-background_a.gif"><span class="menuselected">Processor 
Options</span></td>
  </tr>
  <tr>
  <td align="left" valign="top"><img width="120" vspace="0" 
src="images/close.gif" hspace="0" height="14" border="0"><br>
  </td>
  </tr>
  </table>
  </td><td>
  <table cellspacing="15" cellpadding="0" border="0">
  <tr>
  <td>
   
  
   
  
    <font face="verdana, helvetica, sans serif" size="+2" 
color="#0086b2">Overview</font>
  <hr style="color: #0086b2" size="1">
  
  <p>
  <font color="black" face="verdana,helvetica,sanserif">
  This Snippet shows how to specify different options of the same XSLT 
processor when processing different pipeline requests. The following example is 
based on the need to turn incremental processing both off and on. This is 
useful in situations when processing requests for both PDF and HTML output. For 
example, you may want to turn incremental processing "off" for PDF requests but 
leave it "on" for HTML requests. In addition, you can follow the <b>same</b> 
approach in order to utilize two <b>different</b> XSLT processors when 
processing requests.
  </font>
  </p>
    
  
    
  <font face="verdana, helvetica, sans serif" size="+2" 
color="#0086b2">Version</font>
  <hr style="color: #0086b2" size="1">
  
  <p>
  <font color="black" face="verdana,helvetica,sanserif">
  At the time of this writing, this Snippet was tested against the Cocoon 
version 2.0.3. Please note that this approach does not work with Cocoon 2.1. 
Stay tuned for an upcoming Snippet which illustrates a different approach for 
version 2.1.
  </font>
  </p>
    
    
    
  <font face="verdana, helvetica, sans serif" size="+2" 
color="#0086b2">cocoon.xconf</font>
  <hr style="color: #0086b2" size="1">
  
  <p>
  <font color="black" face="verdana,helvetica,sanserif">
  Here is a snippet from cocoon.xconf which declares a default XSLT processor. 
It assumes the use of Xalan. You can see that the default XSLT processor is 
configured to allow the incremental processing of SAX events. Check your 
cocoon.xconf file, as the value for incremental-processing may be different 
from what is shown here.
  </font>
  </p>
  
  
  <div align="center">
  <table border="0" cellpadding="0" cellspacing="4">
  <tr>
  <td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" 
vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" 
bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img 
border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td>
  </tr>
  <tr>
  <td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" 
height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
  <pre>
  &lt;xslt-processor class="org.apache.cocoon.components.xslt.XSLTProcessorImpl"
     logger="core.xslt-processor"&gt;
   &lt;parameter name="use-store" value="true"/&gt;
   &lt;parameter name="incremental-processing" value="true"/&gt;
  &lt;/xslt-processor&gt;
  </pre>
  </td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" 
height="1" width="1" src="images/void.gif"></td>
  </tr>
  <tr>
  <td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" 
vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" 
bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img 
border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td>
  </tr>
  </table>
  </div>
    
  
  <p>
  <font color="black" face="verdana,helvetica,sanserif">
  As discussed above, we need the ability to turn incremental processing of our 
XSLT processor both on and off. Even though we are using the same XSLT 
processor implementation, we need to declare an additional component in our 
cocoon.xconf file in order to use the XSLT processor differently. So, in the 
next snippet, we add a new component (as a child element of the root cocoon 
element) to cocoon.xconf. Don't be concerned if you don't see any other 
component declarations like this in the particular cocoon.xconf file you happen 
to be using.
  </font>
  </p>
    
     
  <div align="center">
  <table border="0" cellpadding="0" cellspacing="4">
  <tr>
  <td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" 
vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" 
bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img 
border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td>
  </tr>
  <tr>
  <td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" 
height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
  <pre>
  &lt;component 
      role="org.apache.cocoon.components.xslt.XSLTProcessor/NotIncremental"
      class="org.apache.cocoon.components.xslt.XSLTProcessorImpl"&gt;
    &lt;parameter name="use-store" value="true"/&gt;
    &lt;parameter name="incremental-processing" value="false"/&gt; 
  &lt;/component&gt;
  </pre>
  </td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" 
height="1" width="1" src="images/void.gif"></td>
  </tr>
  <tr>
  <td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" 
vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" 
bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img 
border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td>
  </tr>
  </table>
  </div>
  
      
  <p>
  <font color="black" face="verdana,helvetica,sanserif">
  In the snippet above, the component is identified by the role it plays. Note 
the value for the role attribute: 
"org.apache.cocoon.components.xslt.XSLTProcessor/NotIncremental". We will use 
this value in additional snippets below. Note also that the 
incremental-processing parameter and its value of "false" is also specified in 
this particular snippet. 
    </font>
  </p>
  
  
  
    
  <font face="verdana, helvetica, sans serif" size="+2" 
color="#0086b2">sitemap.xmap</font>
  <hr style="color: #0086b2" size="1">
  
  <p>
  <font color="black" face="verdana,helvetica,sanserif">Next, we need to add 
one more XSLT transformer component to the components declaration section of 
our sitemap.xmap file.</font>
  </p>
  
     
  <div align="center">
  <table border="0" cellpadding="0" cellspacing="4">
  <tr>
  <td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" 
vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" 
bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img 
border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td>
  </tr>
  <tr>
  <td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" 
height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
  <pre>
  &lt;map:components&gt;
  
    &lt;!-- other map:components here --&gt;
    
  &lt;map:transformers&gt;
  
    &lt;!-- other map:transformers here --&gt;
    
    &lt;map:transformer 
      name="xslt-notinc"
      src="org.apache.cocoon.transformation.TraxTransformer"
      logger="sitemap.transformer.xslt"
      pool-max="32" pool-min="8" pool-grow="2"&gt;
      &lt;use-request-parameters&gt;false&lt;/use-request-parameters&gt;
      
&lt;use-browser-capabilities-db&gt;false&lt;/use-browser-capabilities-db&gt;
      &lt;use-deli&gt;false&lt;/use-deli&gt;
      &lt;xslt-processor-role&gt;
  org.apache.cocoon.components.xslt.XSLTProcessor/NotIncremental
      &lt;/xslt-processor-role&gt;
    &lt;/map:transformer&gt;
    
    &lt;!-- other map:transformers here --&gt;
  
  &lt;/map:transformers&gt;
  
  &lt;!-- other map:components here --&gt;
  
  &lt;/map:components&gt;
  </pre>
  </td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" 
height="1" width="1" src="images/void.gif"></td>
  </tr>
  <tr>
  <td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" 
vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" 
bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img 
border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td>
  </tr>
  </table>
  </div>
  
      
  <p>
  <font color="black" face="verdana,helvetica,sanserif">
  In the snippet above, we are using the value for the role attribute, 
specified earlier in the cocoon.xconf snippet, for the value of 
xslt-processor-role element. Note also that we are giving this transformer the 
name "xslt-notinc". Please note that the text node for xslt-processor-role was 
manually broken across several lines for page viewing purposes only. Do not do 
this in your sitemap.xmap file.
    </font>
  </p>
  
  
  <p>
  <font color="black" face="verdana,helvetica,sanserif">Finally, in the 
relevant map:match elements in our sitemap.xmap, we can specify exactly which 
xslt transformer component to use by supplying its name as map:transformer's 
type attribute. Remember that the default xslt transformer, as declared in 
cocoon.xconf, has incremental processing turned on. Because it's the 
<i>default</i> transformer, you don't need to specify its name in 
map:transform's type attribute. In fact, you don't have to supply a type 
attribute at all when you use default components.</font>
  </p>
  
  
  <div align="center">
  <table border="0" cellpadding="0" cellspacing="4">
  <tr>
  <td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" 
vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" 
bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img 
border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td>
  </tr>
  <tr>
  <td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" 
height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
  <pre>
  &lt;map:pipeline&gt;
  
     &lt;!-- incremental processing = false --&gt;
     &lt;map:match pattern="*.pdf"&gt;
      &lt;map:generate src="docs/{1}.xml"/&gt;
      &lt;map:transform type="xslt-notinc" src="stylesheets/page2fo.xsl"/&gt;
      &lt;map:serialize type="fo2pdf"/&gt;
     &lt;/map:match&gt;
     
     &lt;!-- incremental processing = true --&gt;
     &lt;map:match pattern="*.html"&gt;
      &lt;map:generate src="docs/{1}.xml"/&gt;
      &lt;map:transform src="stylesheets/page2html.xsl"/&gt;
      &lt;map:serialize type="html"/&gt;
     &lt;/map:match&gt;
     
  &lt;/map:pipeline&gt;
  </pre>
  </td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" 
height="1" width="1" src="images/void.gif"></td>
  </tr>
  <tr>
  <td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" 
vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" 
bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img 
border="0" hspace="0" vspace="0" height="1" width="1" 
src="images/void.gif"></td>
  </tr>
  </table>
  </div>
  
  
  
    
  <font face="verdana, helvetica, sans serif" size="+2" 
color="#0086b2">Comments</font>
  <hr style="color: #0086b2" size="1">
  
  <p>
  <font color="black" face="verdana,helvetica,sanserif">
  Care to comment on this Snippet? Got another tip? Help keep this Snippet 
relevant by passing along any useful feedback to the <a 
href="mailto:[email protected]";>cocoon users list.</a>
  </font>
  </p>
  
  
  
  
  
  </td>
  </tr>
  </table>
  </td>
  </tr>
  </table>
  <table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr>
  <td bgcolor="#0086b2"><img width="1" src="images/dot.gif" height="1"></td>
  </tr>
  <tr>
  <td align="center"><font size="-1" face="arial,helvetica,sanserif" 
color="#0086b2"><i>Copyright &copy; 1999-2002 The Apache Software Foundation. 
All Rights Reserved.</i></font></td>
  </tr>
  </table>
  </body>
  </html>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to