net.sf.saxon
Class PreparedStyleSheet

java.lang.Object
  extended bynet.sf.saxon.PreparedStyleSheet
All Implemented Interfaces:
Serializable, Templates

public class PreparedStyleSheet
extends Object
implements Templates, 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)
          Constructor: deliberately protected
 
Method Summary
 Configuration getConfiguration()
           
 int getErrorCount()
          Get the number of errors reported so far
 Executable getExecutable()
          Get the associated executable
 Properties getOutputProperties()
          Get the properties for xsl:output.
 StyleNodeFactory getStyleNodeFactory()
          Get the StyleNodeFactory in use.
 NamePool getTargetNamePool()
          Get the name pool in use.
static DocumentImpl loadStylesheetModule(Source styleSource, Configuration config, NamePool localNamePool, StyleNodeFactory nodeFactory)
          Build the tree representation of a stylesheet module
 Transformer newTransformer()
          Make a Transformer from this Templates object.
protected  void prepare(Source styleSource)
          Prepare a stylesheet from a Source document
 void reportError(TransformerException err)
          Report a compile time error.
 void reportWarning(TransformerException err)
          Report a compile time warning.
 void setConfiguration(Configuration config)
           
protected  void setStyleSheetDocument(DocumentImpl doc, StyleNodeFactory snFactory)
          Create a PreparedStyleSheet from a supplied DocumentInfo Note: the document must have been built using the StyleNodeFactory
 
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)
Constructor: deliberately protected

Parameters:
config - The Configuration set up by the TransformerFactory
Method Detail

newTransformer

public Transformer newTransformer()
Make a Transformer from this Templates object.

Specified by:
newTransformer in interface Templates
Returns:
the new Transformer (always a Controller)
See Also:
Controller

setConfiguration

public void setConfiguration(Configuration config)

getConfiguration

public Configuration getConfiguration()

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. A different (local) namepool is used for compile-time-only names in the stylesheet itself.

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(Source styleSource)
                throws TransformerConfigurationException
Prepare a stylesheet from a Source document

Parameters:
styleSource - the source document containing the stylesheet
Throws:
TransformerConfigurationException - if compilation of the stylesheet fails for any reason

loadStylesheetModule

public static DocumentImpl loadStylesheetModule(Source styleSource,
                                                Configuration config,
                                                NamePool localNamePool,
                                                StyleNodeFactory nodeFactory)
                                         throws TransformerConfigurationException
Build the tree representation of a stylesheet module

Parameters:
styleSource - the source of the module
config - the Configuration of the transformation factory
localNamePool - the namepool used during compilation
nodeFactory - the StyleNodeFactory used for creating element nodes in the tree
Returns:
the root Document node of the tree containing the stylesheet module
Throws:
TransformerConfigurationException - if XML parsing or tree construction fails

setStyleSheetDocument

protected void setStyleSheetDocument(DocumentImpl doc,
                                     StyleNodeFactory snFactory)
                              throws TransformerConfigurationException
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:
TransformerConfigurationException - if the document supplied is not a stylesheet

getExecutable

public Executable getExecutable()
Get the associated executable

Returns:
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 7.x, this method gets the output properties for the unnamed output format in the stylesheet.

Specified by:
getOutputProperties in interface 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(TransformerException err)
                 throws 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:
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(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