dleslie     00/04/24 10:02:59

  Modified:    xdocs/sources/xalan usagepatterns.xml
  Log:
  Bugzilla Bug 168.
  Added  info on using StylesheetRoot process method with
  XSLTProcessor param to include a stylesheet param setting.
  
  Revision  Changes    Path
  1.8       +18 -2     xml-xalan/xdocs/sources/xalan/usagepatterns.xml
  
  Index: usagepatterns.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/xdocs/sources/xalan/usagepatterns.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- usagepatterns.xml 2000/03/16 18:59:33     1.7
  +++ usagepatterns.xml 2000/04/24 17:02:59     1.8
  @@ -123,8 +123,10 @@
   <p>An XSL stylesheet can include parameters that get set at run time when a 
transformation takes place. When we generate the HTML documents that make up 
the Xalan doc set, for example, we send the stylesheet an id parameter along 
with each XML source document. The id identifies that document and enables the 
stylesheet to integrate it into the overall doc set.</p>
   <p>To set a stylesheet parameter, use the XSLTProcessor 
setStylesheetParam(String key, String expression) method, where key is the 
parameter name and expression is an XPath expression. If the parameter is a 
String, enclose it in single quotes to make it a String expression.</p>
   <p>You can also use setStylesheetParam(String key, XObject value). This 
option is useful when you are working with the XPath API. For example, you 
could use the XObject returned by an Xpath function to set a parameter.</p>
  -<p>From the <link idref="commandline">command line</link>, include a -param 
argument. For example:</p>
  +<p>You can include a -param argument when you call the <link 
idref="commandline">command line utility</link>.For example:</p>
   <p><code>java org.apache.xalan.xslt.Process -in foo.xml -xsl foo.xsl -param 
'boo'</code></p>
  +<p>The <link idref="samples" 
anchor="usestylesheetparam">UseStylesheetParam</link> sample application also 
uses a command-line parameter.</p>
  +<p>For information about using stylesheet parameters with a compiled 
stylesheet, see the next section.</p>
   </s2><anchor name="compiled"/>
   <s2 title="Compiling stylesheets">
   <p>A <resource-ref idref="StylesheetRootDoc"/> object is a binary 
representation of a stylesheet that adds efficiency to the performance of 
repeated transformations and supports thread-safe concurrent access by multiple 
clients. If, for example, you are setting up a servlet to perform 
transformations, you can improve performance by compiling any stylesheets the 
servlet repeatedly uses.</p>
  @@ -146,7 +148,21 @@
   StylesheetRoot style = processor.processStylesheet(new 
XSLTInputSource("foo.xsl"));
   ...
   style.process(new XSLTInputSource("foo.xml"), new 
XSLTResultTarget("foo.out"));</source>
  -<p>You should use the StylesheetRoot process() method if you are using a 
StylesheetRoot object to transform multiple XML sources.</p>
  +<p>You should use the StylesheetRoot process(XSLTInputSource xmlIn, 
XSLTResultTarget xmlOut) method if you are using a StylesheetRoot object to 
transform multiple XML sources. The StylesheetRoot creates a new XSLTProcessor 
instance for each transformation.</p>
  +<p>If you are using a compiled stylesheet to perform a transformation that 
includes a stylesheet parameter, use the version of the process() method that 
includes a parameter for the XSLTProcessor with which you have set the 
stylesheet parameter. Otherwise the parameter setting is not used. Keep in mind 
that you must reset the XSLTProcessor object if you want to use it in another 
transformation. For example:</p>
  +<source>import org.apache.xalan.xslt.*;
  +...
  +XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
  +processor.setStylesheetParam("param1", "'boo'");
  +StylesheetRoot style = processor.processStylesheet
  +                                       (new XSLTInputSource("foo.xsl"));
  +style.process (processor, new XSLTInputSource("foo.xml"),  
  +                          new XSLTResultTarget("foo.out"));
  +processor.reset();
  +processor.setStylesheetParam("param1", "'foobar'");
  +style.process (processor, new XSLTInputSource("bar.xml"),  
  +                          new XSLTResultTarget("bar.out"));
  +</source>
   <p>If you want to use the XSLTProcessor as a SAX document handler, you must 
provide the processor a compiled stylesheet. See <link anchor="sax">Generating 
and Responding to SAX events</link>.</p>
   </s2><anchor name="dom-in"/>
   <s2 title="Processing DOM input">
  
  
  

Reply via email to