Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.saxon
Class PreparedStylesheet

    java.lang.Object
      net.sf.saxon.PreparedStylesheet

All Implemented Interfaces:
  java.io.Serializable, javax.xml.transform.Templates

    public class PreparedStylesheet

extends java.lang.Object
implements javax.xml.transform.Templates, java.io.Serializable

This PreparedStylesheet class represents a Stylesheet that has been prepared for execution (or "compiled").

See Also:
  Serialized Form

Constructor Summary
`protected` | `PreparedStylesheet(Configuration config, CompilerInfo info)` Constructor - deliberately protected

Method Summary
`static PreparedStylesheet` | `compile(javax.xml.transform.Source source, Configuration config, CompilerInfo info)` Factory method to make a PreparedStylesheet
`void` | `explain(ExpressionPresenter presenter)` Produce an XML representation of the compiled and optimized stylesheet
`PreparedStylesheet` | `getCachedStylesheet(java.lang.String href, java.lang.String baseURI)` Get a "next in chain" stylesheet.
`Configuration` | `getConfiguration()` Get the configuration in which this stylesheet is compiled
`int` | `getErrorCount()` Get the number of errors reported so far
`javax.xml.transform.ErrorListener` | `getErrorListener()` Get the ErrorListener used at compile time for reporting static errors in the stylesheet
`Executable` | `getExecutable()` Get the associated executable
`java.util.Properties` | `getOutputProperties()` Get the properties for xsl:output.
`StyleNodeFactory` | `getStyleNodeFactory()` Get the StyleNodeFactory in use.
`NamePool` | `getTargetNamePool()` Get the name pool in use.
`javax.xml.transform.URIResolver` | `getURIResolver()` Get the URIResolver used at compile time for resolving URIs in xsl:include and xsl:import
`boolean` | `isCompileWithTracing()` Determine whether trace hooks are included in the compiled code.
`static PreparedStylesheet` | `loadCompiledStylesheet(Configuration config, java.io.ObjectInputStream ois)` Load a PreparedStylesheet from a compiled stylesheet stored in a file.
`static PreparedStylesheet` | `loadCompiledStylesheet(Configuration config, java.lang.String fileName)` Load a PreparedStylesheet from a compiled stylesheet stored in a file.
`DocumentImpl` | `loadStylesheetModule(javax.xml.transform.Source styleSource, StyleNodeFactory nodeFactory)` Build the tree representation of a stylesheet module
`javax.xml.transform.Transformer` | `newTransformer()` Make a Transformer from this Templates object.
`protected void` | `prepare(javax.xml.transform.Source styleSource)` Prepare a stylesheet from a Source document
`void` | `putCachedStylesheet(java.lang.String href, java.lang.String baseURI, PreparedStylesheet pss)` Save a "next in chain" stylesheet in compiled form, so that it can be reused repeatedly.
`void` | `reportError(javax.xml.transform.TransformerException err)` Report a compile time error.
`void` | `reportWarning(javax.xml.transform.TransformerException err)` Report a compile time warning.
`void` | `setConfiguration(Configuration config)` Set the configuration in which this stylesheet is compiled.
`protected void` | `setStylesheetDocument(DocumentImpl doc, StyleNodeFactory snFactory)` Create a PreparedStylesheet from a supplied DocumentInfo Note: the document must have been built using the StyleNodeFactory
`void` | `setTargetNamePool(NamePool pool)` Set the name pool

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PreparedStylesheet

    protected PreparedStylesheet(Configuration config,
                                 CompilerInfo info)

  Constructor - deliberately protected

  Parameters:
    `config` - The Configuration set up by the TransformerFactory
    `info` - Compilation options

Method Detail

### compile

    public static PreparedStylesheet compile(javax.xml.transform.Source source,
                                             Configuration config,
                                             CompilerInfo info)
                                      throws javax.xml.transform.TransformerConfigurationException

  Factory method to make a PreparedStylesheet

  Parameters:
    `source` - the source of this principal stylesheet module
    `config` - the Saxon configuration
    `info` - compile-time options for this stylesheet compilation
  Returns:
    the prepared stylesheet
  Throws:
    `javax.xml.transform.TransformerConfigurationException`

### newTransformer

    public javax.xml.transform.Transformer newTransformer()

  Make a Transformer from this Templates object.

  Specified by:
    `newTransformer` in interface `javax.xml.transform.Templates`
  Returns:
    the new Transformer (always a Controller)
  See Also:
    `Controller`

### setConfiguration

    public void setConfiguration(Configuration config)

  Set the configuration in which this stylesheet is compiled. Intended for internal use.

  Parameters:
    `config` - the configuration to be used.

### getConfiguration

    public Configuration getConfiguration()

  Get the configuration in which this stylesheet is compiled

  Returns:
    the configuration in which this stylesheet is compiled

### setTargetNamePool

    public void setTargetNamePool(NamePool pool)

  Set the name pool

  Parameters:
    `pool` - the name pool

### getTargetNamePool

    public NamePool getTargetNamePool()

  Get the name pool in use. This is the namepool used for names that need to be accessible at runtime, notably the names used in XPath expressions in the stylesheet.

  Returns:
    the name pool in use

### getStyleNodeFactory

    public StyleNodeFactory getStyleNodeFactory()

  Get the StyleNodeFactory in use. The StyleNodeFactory determines which subclass of StyleElement to use for each element node in the stylesheet tree.

  Returns:
    the StyleNodeFactory

### prepare

    protected void prepare(javax.xml.transform.Source styleSource)
                    throws javax.xml.transform.TransformerConfigurationException

  Prepare a stylesheet from a Source document

  Parameters:
    `styleSource` - the source document containing the stylesheet
  Throws:
    `javax.xml.transform.TransformerConfigurationException` - if compilation of the stylesheet fails for any reason

### loadStylesheetModule

    public DocumentImpl loadStylesheetModule(javax.xml.transform.Source styleSource,
                                             StyleNodeFactory nodeFactory)
                                      throws XPathException

  Build the tree representation of a stylesheet module

  Parameters:
    `styleSource` - the source of the module
    `nodeFactory` - the StyleNodeFactory used for creating element nodes in the tree
  Returns:
    the root Document node of the tree containing the stylesheet module
  Throws:
    `XPathException` - if XML parsing or tree construction fails

### loadCompiledStylesheet

    public static PreparedStylesheet loadCompiledStylesheet(Configuration config,
                                                            java.lang.String fileName)
                                                     throws java.io.IOException,
                                                            java.lang.ClassNotFoundException

  Load a PreparedStylesheet from a compiled stylesheet stored in a file.

  Parameters:
    `config` - The Configuration. This method changes the NamePool used by this configuration to be the NamePool that was stored with the compiled stylesheet. The method must therefore not be used in a multi-threaded environment where the Configuration (and NamePool) are shared between multiple concurrent transformations.
    `fileName` - The name of the file containing the compiled stylesheet (which is just the Java serialization of a PreparedStylesheet object).
  Returns:
    the PreparedStylesheet, which can be used in JAXP interfaces as the Templates object
  Throws:
    `java.io.IOException`
    `java.lang.ClassNotFoundException`

### loadCompiledStylesheet

    public static PreparedStylesheet loadCompiledStylesheet(Configuration config,
                                                            java.io.ObjectInputStream ois)
                                                     throws java.io.IOException,
                                                            java.lang.ClassNotFoundException

  Load a PreparedStylesheet from a compiled stylesheet stored in a file.

  Parameters:
    `config` - The Configuration. This method changes the NamePool used by this configuration to be the NamePool that was stored with the compiled stylesheet. The method must therefore not be used in a multi-threaded environment where the Configuration (and NamePool) are shared between multiple concurrent transformations.
    `ois` - The ObjectInputStream containing the compiled stylesheet (which is just the Java serialization of a PreparedStylesheet object).
  Returns:
    the PreparedStylesheet, which can be used in JAXP interfaces as the Templates object
  Throws:
    `java.io.IOException`
    `java.lang.ClassNotFoundException`

### setStylesheetDocument

    protected void setStylesheetDocument(DocumentImpl doc,
                                         StyleNodeFactory snFactory)
                                  throws XPathException

  Create a PreparedStylesheet from a supplied DocumentInfo Note: the document must have been built using the StyleNodeFactory

  Parameters:
    `doc` - the document containing the stylesheet module
    `snFactory` - the StyleNodeFactory used to build the tree
  Throws:
    `XPathException` - if the document supplied is not a stylesheet

### getExecutable

    public Executable getExecutable()

  Get the associated executable

  Returns:
    the Executable for this stylesheet

### isCompileWithTracing

    public boolean isCompileWithTracing()

  Determine whether trace hooks are included in the compiled code.

  Returns:
    true if trace hooks are included, false if not.
  Since:
    8.9

### getOutputProperties

    public java.util.Properties getOutputProperties()

  Get the properties for xsl:output. JAXP method. The object returned will be a clone of the internal values, and thus it can be mutated without mutating the Templates object, and then handed in to the process method.

  In Saxon, the properties object is a new, empty, Properties object that is backed by the live properties to supply default values for missing properties. This means that the property values must be read using the getProperty() method. Calling the get() method on the underlying Hashtable will return null.

  In Saxon 8.x, this method gets the output properties for the unnamed output format in the stylesheet.

  Specified by:
    `getOutputProperties` in interface `javax.xml.transform.Templates`
  Returns:
    A Properties object reflecting the output properties defined for the default (unnamed) output format in the stylesheet. It may be mutated and supplied to the setOutputProperties() method of the Transformer, without affecting other transformations that use the same stylesheet.
  See Also:
    `Transformer.setOutputProperties(java.util.Properties)`

### reportError

    public void reportError(javax.xml.transform.TransformerException err)
                     throws javax.xml.transform.TransformerException

  Report a compile time error. This calls the errorListener to output details of the error, and increments an error count.

  Parameters:
    `err` - the exception containing details of the error
  Throws:
    `javax.xml.transform.TransformerException` - if the ErrorListener decides that the error should be reported

### getErrorCount

    public int getErrorCount()

  Get the number of errors reported so far

  Returns:
    the number of errors reported

### reportWarning

    public void reportWarning(javax.xml.transform.TransformerException err)

  Report a compile time warning. This calls the errorListener to output details of the warning.

  Parameters:
    `err` - an exception holding details of the warning condition to be reported

### getCachedStylesheet

    public PreparedStylesheet getCachedStylesheet(java.lang.String href,
                                                  java.lang.String baseURI)

  Get a "next in chain" stylesheet. This method is intended for internal use.

  Parameters:
    `href` - the relative URI of the next-in-chain stylesheet
    `baseURI` - the baseURI against which this relativeURI is to be resolved
  Returns:
    the cached stylesheet if present in the cache, or null if not

### putCachedStylesheet

    public void putCachedStylesheet(java.lang.String href,
                                    java.lang.String baseURI,
                                    PreparedStylesheet pss)

  Save a "next in chain" stylesheet in compiled form, so that it can be reused repeatedly. This method is intended for internal use.

  Parameters:
    `href` - the relative URI of the stylesheet
    `baseURI` - the base URI against which the relative URI is resolved
    `pss` - the prepared stylesheet object to be cached

### getURIResolver

    public javax.xml.transform.URIResolver getURIResolver()

  Get the URIResolver used at compile time for resolving URIs in xsl:include and xsl:import

  Returns:
    the compile-time URIResolver

### getErrorListener

    public javax.xml.transform.ErrorListener getErrorListener()

  Get the ErrorListener used at compile time for reporting static errors in the stylesheet

  Returns:
    the compile time ErrorListener

### explain

    public void explain(ExpressionPresenter presenter)

  Produce an XML representation of the compiled and optimized stylesheet

  Parameters:
    `presenter` - defines the destination and format of the output

Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) Saxonica Limited. All rights reserved.