public class PreparedStylesheet
extends java.lang.Object
implements Templates, Serializable
compile
public static PreparedStylesheet compile(Source source,
Configuration config,
CompilerInfo info)
throws TransformerConfigurationException
Factory method to make a PreparedStylesheet
source
- the source of this principal stylesheet moduleconfig
- the Saxon configurationinfo
- compile-time options for this stylesheet compilation
explain
public void explain(ExpressionPresenter presenter)
Produce an XML representation of the compiled and optimized stylesheet
presenter
- defines the destination and format of the output
getCachedStylesheet
public PreparedStylesheet getCachedStylesheet(String href,
String baseURI)
Get a "next in chain" stylesheet. This method is intended for internal use.
href
- the relative URI of the next-in-chain stylesheetbaseURI
- the baseURI against which this relativeURI is to be resolved
- the cached stylesheet if present in the cache, or null if not
getConfiguration
public Configuration getConfiguration()
Get the configuration in which this stylesheet is compiled
- the configuration in which this stylesheet is compiled
getErrorCount
public int getErrorCount()
Get the number of errors reported so far
- the number of errors reported
getErrorListener
public ErrorListener getErrorListener()
Get the ErrorListener used at compile time for reporting static errors in the stylesheet
- the compile time ErrorListener
getExecutable
public Executable getExecutable()
Get the associated executable
- the Executable for this stylesheet
getOutputProperties
public 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.
- 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.
javax.xml.transform.Transformer.setOutputProperties
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.
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.
getURIResolver
public URIResolver getURIResolver()
Get the URIResolver used at compile time for resolving URIs in xsl:include and xsl:import
- the compile-time URIResolver
isCompileWithTracing
public boolean isCompileWithTracing()
Determine whether trace hooks are included in the compiled code.
- true if trace hooks are included, false if not.
loadCompiledStylesheet
public static PreparedStylesheet loadCompiledStylesheet(Configuration config,
ObjectInputStream ois)
throws IOException,
ClassNotFoundException
Load a PreparedStylesheet from a compiled stylesheet stored in a file.
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).
- the PreparedStylesheet, which can be used in JAXP interfaces as the Templates object
loadCompiledStylesheet
public static PreparedStylesheet loadCompiledStylesheet(Configuration config,
String fileName)
throws IOException,
ClassNotFoundException
Load a PreparedStylesheet from a compiled stylesheet stored in a file.
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).
- the PreparedStylesheet, which can be used in JAXP interfaces as the Templates object
loadStylesheetModule
public static DocumentImpl loadStylesheetModule(Source styleSource,
Configuration config,
NamePool localNamePool,
StyleNodeFactory nodeFactory)
throws XPathException
Build the tree representation of a stylesheet module
styleSource
- the source of the moduleconfig
- the Configuration of the transformation factorylocalNamePool
- the namepool used during compilationnodeFactory
- the StyleNodeFactory used for creating
element nodes in the tree
- the root Document node of the tree containing the stylesheet
module
newTransformer
public Transformer newTransformer()
Make a Transformer from this Templates object.
- the new Transformer (always a Controller)
prepare
protected void prepare(Source styleSource)
throws TransformerConfigurationException
Prepare a stylesheet from a Source document
styleSource
- the source document containing the stylesheet
putCachedStylesheet
public void putCachedStylesheet(String href,
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.
href
- the relative URI of the stylesheetbaseURI
- the base URI against which the relative URI is resolvedpss
- the prepared stylesheet object to be cached
reportError
public void reportError(TransformerException err)
throws TransformerException
Report a compile time error. This calls the errorListener to output details
of the error, and increments an error count.
err
- the exception containing details of the error
reportWarning
public void reportWarning(TransformerException err)
Report a compile time warning. This calls the errorListener to output details
of the warning.
err
- an exception holding details of the warning condition to be
reported
setConfiguration
public void setConfiguration(Configuration config)
Set the configuration in which this stylesheet is compiled.
Intended for internal use.
config
- the configuration to be used.
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
doc
- the document containing the stylesheet modulesnFactory
- the StyleNodeFactory used to build the tree
setTargetNamePool
public void setTargetNamePool(NamePool pool)
Set the name pool