com.novell.xsl
Class Stylesheet

java.lang.Object
  extended bycom.novell.xsl.Stylesheet
All Implemented Interfaces:
VariableBindings, XPathResetRegistrar

public class Stylesheet
extends Object
implements XPathResetRegistrar, VariableBindings

An XSLT stylesheet.

The following is the basic procedure to programmatically create and use an XSLT stylesheet (see com.novell.xsl.nxsl for a command-line driver):

1. Obtain a DOM tree of the stylesheet. For example, use com.novell.xml.parser.XMLParserFactory.newParser() to create a parser that will return a DOM tree.

2. Construct a Stylesheet object based on the DOM tree. This will construct a "compiled" version of the stylesheet.

3. Obtain a DOM tree of the source document to be transformed. If the source document is serialized and needs to be parsed, use com.novell.xsl.SAXtoDOMStrip to convert from SAX events to a DOM tree and perform whitespace stripping based on the stylesheet. This is more efficient than performing source tree whitespace stripping at processing time.

4. Setup a ResultHandler in the Stylesheet object. If a ResultHandler is not explicitly specified the Stylesheet will use com.novell.xsl.result.DOMResultHandler which will build a DOM tree from the XSLT result document. To obtain the result document as a series of SAX events use com.novell.xsl.result.SAXResultHandler. To serialize the result document use com.novell.xsl.result.DefaultSerializer, com.novell.xsl.result.XMLSerializer, or com.novell.xsl.result.HTMLSerializer. A custom result handler may be used by implementing com.novell.xsl.result.ResultHandler.

5. Transform the source document by calling Stylesheet.process().

By default, errors are reported to System.err but processing continues. This behavior can be changed by installing a custom error handler that implements com.novell.xsl.ErrorHandler. Call Stylesheet.setErrorHandler().

By default xsl:message elements output their content as serialized XML to System.out. This behavior can be changed by installing a custom message handler that implements com.novell.xsl.MessageHandler. Call Stylesheet.setMessageHandler().

Custom character encodings can be implemented by deriving the implementation from com.novell.io.CharEncoder. The custom encoding can then be specified using the encoding attribute on the xsl:output element.

The class com.novell.xsl.parser.StylesheetParser is used to construct the stylesheet from the DOM input tree.

See Also:
ErrorHandler, MessageHandler, ResultHandler, DOMResultHandler, SAXResultHandler, DefaultSerializer, StylesheetParser, CharEncoder, nxsl

Field Summary
static String EXTENSION_FUNCTION_MAGIC
          The start of the URI used to signify extension functions and non-built in extension elements: "http://www.novell.com.nxsl/java/"
static NamespaceName NAMESPACE
          The URI for the XSLT namespace.
static NamespaceName NXSL_NAMESPACE
          The URI for NXSL built-in extension elements: "http://www.novell.com/nxsl"
static String VERSION
          The version number for this processor
static String XSLT_VERSION
          The version of XSLT supported by this Stylesheet ("1.0")
 
Constructor Summary
Stylesheet()
          Constructs an empty XSLT stylesheet with the default XSLT function library (extension functions are available).
Stylesheet(ClassLoader extensionFunctionLoader)
          Constructs an empty XSLT stylesheet with the default XSLT function library (extension functions are available).
Stylesheet(ClassLoader extensionFunctionLoader, Map properties)
          Constructs an empty XSLT stylesheet with the default XSLT function library (extension functions are available).
Stylesheet(Document xslDocument)
          Constructs an XSLT stylesheet from the specified XML document tree.
Stylesheet(Document xslDocument, boolean brokenMode)
          Constructs an XSLT stylesheet from the specified XML document tree.
Stylesheet(Document xslDocument, boolean brokenMode, Map properties)
          Constructs an XSLT stylesheet from the specified XML document tree.
Stylesheet(Document xslDocument, ClassLoader extensionFunctionLoader)
          Constructs an XSLT stylesheet from the specified XML document tree.
Stylesheet(Document xslDocument, ClassLoader extensionFunctionLoader, boolean brokenMode)
          Constructs an XSLT stylesheet from the specified XML document tree.
Stylesheet(Document xslDocument, ClassLoader extensionFunctionLoader, boolean brokenMode, Map properties)
          Constructs an XSLT stylesheet from the specified XML document tree.
Stylesheet(Document xslDocument, ClassLoader extensionFunctionLoader, Map properties)
          Constructs an XSLT stylesheet from the specified XML document tree.
Stylesheet(Document xslDocument, Map properties)
          Constructs an XSLT stylesheet from the specified XML document tree.
Stylesheet(Document xslDocument, String xslURI)
          Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.
Stylesheet(Document xslDocument, String xslURI, boolean brokenMode)
          Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.
Stylesheet(Document xslDocument, String xslURI, boolean brokenMode, Map properties)
          Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.
Stylesheet(Document xslDocument, String xslURI, ClassLoader extensionFunctionLoader)
          Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.
Stylesheet(Document xslDocument, String xslURI, ClassLoader extensionFunctionLoader, boolean brokenMode)
          Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.
Stylesheet(Document xslDocument, String xslURI, ClassLoader extensionFunctionLoader, boolean brokenMode, Map properties)
          Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.
Stylesheet(Document xslDocument, String xslURI, ClassLoader extensionFunctionLoader, Map properties)
          Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.
Stylesheet(Document xslDocument, String xslURI, Map properties)
          Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.
Stylesheet(Map properties)
          Constructs an empty XSLT stylesheet with the default XSLT function library (extension functions are available).
 
Method Summary
 void clearParameters()
          clear existing stylesheet parameters
 void dump(PrintWriter out)
          Dumps this object to the specified output stream.
 void dump(PrintWriter out, int indent)
          Dumps this object to the specified output stream.
 NamespaceName getAliasedNamespace(NamespaceName alias)
          Return the result namespace given an alias, if any
 String getAliasedPrefix(NamespaceName alias)
          Return the result namespace prefix given an alias, if any
 AttributeSet getAttributeSet(ExpandedQName setName)
          Get an attribute set definition with a particular expanded name
 URL getBaseURI()
          Returns this stylesheet's base URI.
 Context getContext()
          Get the base ExpressionContext used by this Stylesheet
 DecimalFormatSymbols getDecimalFormat(ExpandedQName name)
          Get an xsl:decimal-format declared number-formatting object
 ErrorHandler getErrorHandler()
          Returns the error handler to which this stylesheet reports processing errors and warnings.
 String getID()
          Returns the ID identifying this stylesheet.
 Key getKey(ExpandedQName name)
          Return a key with a given expanded name
 MessageHandler getMessageHandler()
          Returns the message handler for xsl:message output
 ResultHandler getResultHandler()
          Get the result handler that is used for the result tree
 SerializerOptions getSerializerOptions()
          Get the serializer options, if any
 OutputStream getSerializerStream()
          Get the output stream that will be used for serialization of the result tree
 StripList getStripList()
          Returns this stylesheet's whitespace stripping element list
 RuleCollection getTemplateRules()
          Returns this stylesheet's collection of template rules.
 TopLevelVariableTemplate getTopLevelVariable(ExpandedQName name)
          Return a top-level variable given its name
 Expression getVariable(ExpandedQName varName)
          Return an object of type Expression given an ExpandedQName name.
 XmlHook getXmlHook()
          Return any document processing hook set for this instance.
 boolean isLoaded()
          Return true if this stylesheet has been loaded (i.e., load() or loadFromSource() was successfully called).
 void load(Document xslDocument)
          Loads this XSLT stylesheet from the specified XML document tree.
 void loadFromSource(Document xmlDocument, String documentURI)
          Attempt to load this XSLT stylesheet object from a source document containing one or more xml-stylesheet processing instructions.
 void process(Node sourceDocument, URL sourceURI)
          Processes the specified source document with this stylesheet.
 void process(Node sourceDocument, URL sourceURI, boolean alreadyStripped)
          Processes the specified source document with this stylesheet.
 void processStripped(Node sourceDocument, URL sourceURI)
           Processes the specified source document with this stylesheet.
 void registerResetCache(XPathResetCache reset)
          Register an instance of XPathResetCache so it will be called when the source document changes
 void setAttributeSet(AttributeSet attributeSet)
          Set an attribute set created from an xsl:attribute-set element This will handle merging with any existing attribute sets with the same name
 void setBaseURI(String uri)
          Sets this stylesheet's base URI to a URL.
 void setBaseURI(URL baseURI)
          Sets this stylesheet's base URI to the specified URL.
 boolean setBrokenMode(boolean newMode)
          Set this Stylesheet object to use broken but backwards-compatible behavior.
 void setDecimalFormat(ExpandedQName name, DecimalFormatSymbols decimalFormat)
          Set an xsl:decimal-format declared number-formatting object
 void setErrorHandler(ErrorHandler errorHandler)
          Sets the error handler to which this stylesheet reports processing errors and warnings.
 void setID(String id)
          Sets this stylesheet's ID.
 void setKey(Key key)
          Set a Key in the stylesheet
 void setMessageHandler(MessageHandler messageHandler)
          Sets the error handler to which this stylesheet reports processing errors and warnings.
 void setMimeTypes(String[] mimeTypes)
          Set the mime types that will be recognized in xml-stylesheet processing instructions.
 void setNamespaceAlias(NamespaceName alias, NamespaceName resultName, String resultPrefix, int importance)
          Set a namespace alias for a namespace in the result tree
 void setParameter(String paramName, Object value)
          set a stylesheet parameter
 void setParameter(String paramName, String expressionString)
          set a stylesheet parameter
 void setResultHandler(ResultHandler resultHandler)
          Set the result handler for the result tree
 void setSerializerOptions(SerializerOptions serializerOptions, int importance)
          Set serializer options.
 void setSerializerStream(OutputStream serializerStream)
          Set the stream for use by a serializer.
 void setTopLevelVariable(TopLevelVariableTemplate variable)
          Set a top-level variable for this stylesheet Normally, this would only be called by the stylesheet parser.
 XmlHook setXmlHook(XmlHook hook)
          Set a processing hook for processing XML documents loaded via xsl:include, xsl:import, or the XSLT document() function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACE

public static final NamespaceName NAMESPACE
The URI for the XSLT namespace. ("http://www.w3.org/1999/XSL/Transform")


VERSION

public static final String VERSION
The version number for this processor

See Also:
Constant Field Values

NXSL_NAMESPACE

public static final NamespaceName NXSL_NAMESPACE
The URI for NXSL built-in extension elements: "http://www.novell.com/nxsl"


EXTENSION_FUNCTION_MAGIC

public static final String EXTENSION_FUNCTION_MAGIC
The start of the URI used to signify extension functions and non-built in extension elements: "http://www.novell.com.nxsl/java/"

See Also:
Constant Field Values

XSLT_VERSION

public static final String XSLT_VERSION
The version of XSLT supported by this Stylesheet ("1.0")

See Also:
Constant Field Values
Constructor Detail

Stylesheet

public Stylesheet()
Constructs an empty XSLT stylesheet with the default XSLT function library (extension functions are available). Call load() to "compile" a stylesheet document.

See Also:
load(org.w3c.dom.Document), setBaseURI(java.net.URL)

Stylesheet

public Stylesheet(Map properties)
Constructs an empty XSLT stylesheet with the default XSLT function library (extension functions are available). Call load() to "compile" a stylesheet document.

Parameters:
properties - Map containing extended properties
See Also:
load(org.w3c.dom.Document), setBaseURI(java.net.URL)

Stylesheet

public Stylesheet(ClassLoader extensionFunctionLoader)
Constructs an empty XSLT stylesheet with the default XSLT function library (extension functions are available). Call load() to "compile" a stylesheet document.

Parameters:
extensionFunctionLoader - ClassLoader to use for loading extension functions.
See Also:
load(org.w3c.dom.Document), setBaseURI(java.net.URL)

Stylesheet

public Stylesheet(ClassLoader extensionFunctionLoader,
                  Map properties)
Constructs an empty XSLT stylesheet with the default XSLT function library (extension functions are available). Call load() to "compile" a stylesheet document.

Parameters:
extensionFunctionLoader - ClassLoader to use for loading extension functions.
properties - Map containing extended properties
See Also:
load(org.w3c.dom.Document), setBaseURI(java.net.URL)

Stylesheet

public Stylesheet(Document xslDocument)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree. The XSLT stylesheet's base URI is assumed to be unknown and is set to null. Note that a valid, non-null base URI is needed to properly resolve relative URIs in the stylesheet.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  Map properties)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree. The XSLT stylesheet's base URI is assumed to be unknown and is set to null. Note that a valid, non-null base URI is needed to properly resolve relative URIs in the stylesheet.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
properties - Map containing extended properties
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  boolean brokenMode)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree. The XSLT stylesheet's base URI is assumed to be unknown and is set to null. Note that a valid, non-null base URI is needed to properly resolve relative URIs in the stylesheet.

This overload allows broken but backwards-compatible behavior to be specified.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
brokenMode - if true then use broken but backwards-compatible behavior
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  boolean brokenMode,
                  Map properties)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree. The XSLT stylesheet's base URI is assumed to be unknown and is set to null. Note that a valid, non-null base URI is needed to properly resolve relative URIs in the stylesheet.

This overload allows broken but backwards-compatible behavior to be specified.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
brokenMode - if true then use broken but backwards-compatible behavior
properties - Map containing extended properties
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  ClassLoader extensionFunctionLoader)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree. The XSLT stylesheet's base URI is assumed to be unknown and is set to null. Note that a valid, non-null base URI is needed to properly resolve relative URIs in the stylesheet.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
extensionFunctionLoader - ClassLoader to use for loading extension functions.
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  ClassLoader extensionFunctionLoader,
                  Map properties)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree. The XSLT stylesheet's base URI is assumed to be unknown and is set to null. Note that a valid, non-null base URI is needed to properly resolve relative URIs in the stylesheet.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
extensionFunctionLoader - ClassLoader to use for loading extension functions.
properties - Map containing extended properties
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  ClassLoader extensionFunctionLoader,
                  boolean brokenMode)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree. The XSLT stylesheet's base URI is assumed to be unknown and is set to null. Note that a valid, non-null base URI is needed to properly resolve relative URIs in the stylesheet.

This overload allows broken but backwards-compatible behavior to be specified.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
extensionFunctionLoader - ClassLoader to use for loading extension functions.
brokenMode - if true then use broken but backwards-compatible behavior
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  ClassLoader extensionFunctionLoader,
                  boolean brokenMode,
                  Map properties)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree. The XSLT stylesheet's base URI is assumed to be unknown and is set to null. Note that a valid, non-null base URI is needed to properly resolve relative URIs in the stylesheet.

This overload allows broken but backwards-compatible behavior to be specified.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
extensionFunctionLoader - ClassLoader to use for loading extension functions.
brokenMode - if true then use broken but backwards-compatible behavior
properties - Map containing extended properties
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  String xslURI)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
xslURI - the XSLT document's URI
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), setBaseURI(String), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  String xslURI,
                  Map properties)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
xslURI - the XSLT document's URI
properties - Map containing extended properties
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), setBaseURI(String), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  String xslURI,
                  boolean brokenMode)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.

This overload allows broken but backwards-compatible behavior to be specified.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
xslURI - the XSLT document's URI
brokenMode - if true then use broken but backwards-compatible behavior
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), setBaseURI(String), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  String xslURI,
                  boolean brokenMode,
                  Map properties)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.

This overload allows broken but backwards-compatible behavior to be specified.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
xslURI - the XSLT document's URI
brokenMode - if true then use broken but backwards-compatible behavior
properties - Map containing extended properties
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), setBaseURI(String), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  String xslURI,
                  ClassLoader extensionFunctionLoader)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
xslURI - the XSLT document's URI
extensionFunctionLoader - ClassLoader to use for loading extension functions.
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), setBaseURI(String), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  String xslURI,
                  ClassLoader extensionFunctionLoader,
                  Map properties)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
xslURI - the XSLT document's URI
extensionFunctionLoader - ClassLoader to use for loading extension functions.
properties - Map containing extended properties
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), setBaseURI(String), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  String xslURI,
                  ClassLoader extensionFunctionLoader,
                  boolean brokenMode)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.

This overload allows broken but backwards-compatible behavior to be specified.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
xslURI - the XSLT document's URI
extensionFunctionLoader - ClassLoader to use for loading extension functions.
brokenMode - if true then use broken but backwards-compatible behavior
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), setBaseURI(String), load(org.w3c.dom.Document)

Stylesheet

public Stylesheet(Document xslDocument,
                  String xslURI,
                  ClassLoader extensionFunctionLoader,
                  boolean brokenMode,
                  Map properties)
           throws XSLException
Constructs an XSLT stylesheet from the specified XML document tree; the specified filename is used to resolve resolve relative URIs in the stylesheet.

This overload allows broken but backwards-compatible behavior to be specified.

Parameters:
xslDocument - the XML document tree for the XSLT stylesheet
xslURI - the XSLT document's URI
extensionFunctionLoader - ClassLoader to use for loading extension functions.
brokenMode - if true then use broken but backwards-compatible behavior
properties - Map containing extended properties
Throws:
XSLException - if a fatal parsing error occurs
See Also:
Stylesheet(), setBaseURI(String), load(org.w3c.dom.Document)
Method Detail

getContext

public Context getContext()
Get the base ExpressionContext used by this Stylesheet

Returns:
The base ExpressionContext used by this Stylesheet

setBrokenMode

public boolean setBrokenMode(boolean newMode)
Set this Stylesheet object to use broken but backwards-compatible behavior. Note that this must be called before load(), loadFromSource(), or process() are called. Note further that the Stylesheet constructors that have XML document arguments call load(); therefore the version of the constructor that allows the setting of broken mode must be called rather than this method if broken mode is desired.

Parameters:
newMode - the new broken mode (if true, then broken but backwards-compatible behavior is used).
Returns:
the setting of broken mode before the call

setResultHandler

public void setResultHandler(ResultHandler resultHandler)
Set the result handler for the result tree

Parameters:
resultHandler - The result handler to use.

getResultHandler

public ResultHandler getResultHandler()
Get the result handler that is used for the result tree

Returns:
The result handler that is used for the result tree. This may be null if the setResultHandler() has not been called, and process() has not been called.

setSerializerStream

public void setSerializerStream(OutputStream serializerStream)
Set the stream for use by a serializer. This will only be used if an xsl:output element appears in the stylesheet, or if a ResultHandler is specified (see setResultHandler()) that implements com.novell.xsl.result.Serializer.

Parameters:
serializerStream - The output stream to use for serialization

getSerializerStream

public OutputStream getSerializerStream()
Get the output stream that will be used for serialization of the result tree

Returns:
The output stream for use in serializing the result tree.

setParameter

public void setParameter(String paramName,
                         String expressionString)
set a stylesheet parameter

Parameters:
paramName - The QName of the parameter to set
expressionString - A String containing an XPath expression The expression will be evaluation just before source document processing begins

setParameter

public void setParameter(String paramName,
                         Object value)
set a stylesheet parameter

Parameters:
paramName - The QName of the parameter to set
value - The object containing the parameter value.

clearParameters

public void clearParameters()
clear existing stylesheet parameters


setXmlHook

public XmlHook setXmlHook(XmlHook hook)
Set a processing hook for processing XML documents loaded via xsl:include, xsl:import, or the XSLT document() function.

Parameters:
hook - interface to call upon document load (may be null).
Returns:
the previous hook set (if any)

getXmlHook

public XmlHook getXmlHook()
Return any document processing hook set for this instance.

Returns:
XmlHook interface (may be null)

getBaseURI

public URL getBaseURI()
Returns this stylesheet's base URI.

Returns:
this stylesheet's base URI, or null if the base URI is unknown

setBaseURI

public void setBaseURI(URL baseURI)
Sets this stylesheet's base URI to the specified URL.

The XSLT processor needs a non-null base URI in order to properly resolve relative URIs in the stylesheet (such as the href= attribute in xsl:import). The base URI is initially set to null.

Parameters:
baseURI - this stylesheet's base URI, or null if the base URI is unknown

setBaseURI

public void setBaseURI(String uri)
                throws MalformedURLException
Sets this stylesheet's base URI to a URL. If the passed URI is a relative URI it is resolved using the file: scheme and the current directory "." The XSLT processor needs a non-null base URI in order to properly resolve relative URIs in the stylesheet (such as the href= attribute in xsl:import). The base URI is initially set to null.

Parameters:
uri - the uri string from which the base URI is to be constructed
Throws:
MalformedURLException - if a URL cannot be formed from the specified filename

getID

public String getID()
Returns the ID identifying this stylesheet.

Returns:
this stylesheet's ID, or null if it has no ID

setID

public void setID(String id)
Sets this stylesheet's ID. The ID is initially null.

Parameters:
id - the ID for this stylesheet

getTemplateRules

public RuleCollection getTemplateRules()
Returns this stylesheet's collection of template rules.

Returns:
this stylesheet's collection of template rules

getStripList

public StripList getStripList()
Returns this stylesheet's whitespace stripping element list

Returns:
This stylesheet's whitespace stripping element list

getErrorHandler

public ErrorHandler getErrorHandler()
Returns the error handler to which this stylesheet reports processing errors and warnings.

Returns:
the error handler to which this stylesheet reports processing errors and warnings

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)
Sets the error handler to which this stylesheet reports processing errors and warnings.

Parameters:
errorHandler - the error handler to which this stylesheet reports processing errors and warnings
Throws:
IllegalArgumentException - if errorHandler is null

getMessageHandler

public MessageHandler getMessageHandler()
Returns the message handler for xsl:message output

Returns:
The message handler for xsl:message output

setMessageHandler

public void setMessageHandler(MessageHandler messageHandler)
Sets the error handler to which this stylesheet reports processing errors and warnings.

Parameters:
messageHandler - the message handler to which this stylesheet reports xsl:message output
Throws:
IllegalArgumentException - if messageHandler is null

getSerializerOptions

public SerializerOptions getSerializerOptions()
Get the serializer options, if any

Returns:
A SerializerOptions object, or null if no options have been set.

setSerializerOptions

public void setSerializerOptions(SerializerOptions serializerOptions,
                                 int importance)
Set serializer options.

Parameters:
serializerOptions - A SerializerOptions object with any serializer options desired.
importance - The import precedence associated with the options (higher numbers more important)

setTopLevelVariable

public void setTopLevelVariable(TopLevelVariableTemplate variable)
                         throws XSLException
Set a top-level variable for this stylesheet Normally, this would only be called by the stylesheet parser.

Parameters:
variable - The variable for this stylesheet
Throws:
XSLException

getTopLevelVariable

public TopLevelVariableTemplate getTopLevelVariable(ExpandedQName name)
Return a top-level variable given its name

Returns:
The top level variable, or null if none found by passed name

setDecimalFormat

public void setDecimalFormat(ExpandedQName name,
                             DecimalFormatSymbols decimalFormat)
Set an xsl:decimal-format declared number-formatting object

Parameters:
name - The expanded name of the decimal-format object (null indicates the default decimal-format object)
decimalFormat - The DecimalFormatSymbols object containing the decimal-format attributes.

getDecimalFormat

public DecimalFormatSymbols getDecimalFormat(ExpandedQName name)
Get an xsl:decimal-format declared number-formatting object

Parameters:
name - The expanded name of the decimal-format object (null indicates the default decimal-format)
Returns:
The DecimalFormatSymbols object containing the decimal-format attributes.

setKey

public void setKey(Key key)
Set a Key in the stylesheet

Parameters:
key - The Key to add

getKey

public Key getKey(ExpandedQName name)
Return a key with a given expanded name

Parameters:
name - The expanded name of the Key
Returns:
The Key, if found, null otherwise

setAttributeSet

public void setAttributeSet(AttributeSet attributeSet)
                     throws XSLException
Set an attribute set created from an xsl:attribute-set element This will handle merging with any existing attribute sets with the same name

Parameters:
attributeSet - The AttributeSet object
Throws:
XSLException

getAttributeSet

public AttributeSet getAttributeSet(ExpandedQName setName)
Get an attribute set definition with a particular expanded name

Parameters:
setName - The expanded name of the attribute set to retrieve

setNamespaceAlias

public void setNamespaceAlias(NamespaceName alias,
                              NamespaceName resultName,
                              String resultPrefix,
                              int importance)
Set a namespace alias for a namespace in the result tree

Parameters:
alias - The namespace name used in the stylesheet
resultName - The namespace name which replaces the alias in the result tree
resultPrefix - The prefix to use in the result tree (typically the same prefix as used in the stylesheet)
importance - The import precedence of the declaring xsl:namespace-alias element

getAliasedNamespace

public NamespaceName getAliasedNamespace(NamespaceName alias)
Return the result namespace given an alias, if any

Parameters:
alias - The namespace alias used in the stylesheet
Returns:
The result tree namespace, or null if no namespace is mapped to the passed alias

getAliasedPrefix

public String getAliasedPrefix(NamespaceName alias)
Return the result namespace prefix given an alias, if any

Parameters:
alias - The namespace alias used in the stylesheet
Returns:
The prefix to use in the result tree, or null if passed alias not mapped to a result tree namespace

setMimeTypes

public void setMimeTypes(String[] mimeTypes)
Set the mime types that will be recognized in xml-stylesheet processing instructions. By default, only "text/xml" and "application/xml" are recognized. Passing in an array of strings, each of which contains a mime type string allows the application to customize this behavior.

Parameters:
mimeTypes - An array of strings, each of which is a mime type ("text/xml", etc.)

load

public void load(Document xslDocument)
          throws XSLTParserException
Loads this XSLT stylesheet from the specified XML document tree. A given stylesheet object can only be loaded once.

Parameters:
xslDocument - an XML document tree representing an XSLT stylesheet
Throws:
XSLTParserException - if a fatal parsing error occurs or this stylesheet has already been loaded

loadFromSource

public void loadFromSource(Document xmlDocument,
                           String documentURI)
                    throws XSLTParserException
Attempt to load this XSLT stylesheet object from a source document containing one or more xml-stylesheet processing instructions.

This method will not use stylesheets that are specified as alternates.

Parameters:
xmlDocument - The xmlDocument from which the xml-stylesheet processing instructions will be obtained.
documentURI - The base URI of the passed XML document, if known (may be null).
Throws:
XSLTParserException

isLoaded

public boolean isLoaded()
Return true if this stylesheet has been loaded (i.e., load() or loadFromSource() was successfully called). This is necessary because the error handler may not throw an exception if load() or loadFromSource() fails.

Returns:
true if this stylesheet has been loaded.

processStripped

public void processStripped(Node sourceDocument,
                            URL sourceURI)
                     throws XSLException

Processes the specified source document with this stylesheet. This stylesheet remains unaffected by the processing, so it can be reused to process additional source documents. This method should only be used if the passed source document has already been whitespace-stripped (for example, by using SAXtoDOMStrip).

Parameters:
sourceDocument - the source document to be processed. Note that this may be either a Document or DocumentFragment since XSLT relaxes the restrictions on the source tree when the document is created by means other than parsing a well-formed XML document. The result of the processing depends on what type of result handler is set using setResultHandler(). If no result handler is set explicitly, then a DOMResultHandler is used. The resulting document can be retrieved by calling ((DOMResultHandler)stylesheet.getResultHandler()).getDocument();
sourceURI - the source document base URI, if it exists
Throws:
XSLException - if a fatal error occurs during processing or if processing terminated early. The error condition can be checked by calling XSLException.isError()
See Also:
load(org.w3c.dom.Document)

process

public void process(Node sourceDocument,
                    URL sourceURI)
             throws XSLException
Processes the specified source document with this stylesheet. This stylesheet remains unaffected by the processing, so it can be reused to process additional source documents. This method will always perform runtime whitespace stripping.

Parameters:
sourceDocument - the source document to be processed. Note that this may be either a Document or DocumentFragment since XSLT relaxes the restrictions on the source tree when the document is created by means other than parsing a well-formed XML document. The result of the processing depends on what type of result handler is set using setResultHandler(). If no result handler is set explicitly, then a DOMResultHandler is used. The resulting document can be retrieved by calling ((DOMResultHandler)stylesheet.getResultHandler()).getDocument();
sourceURI - the source document base url, if it exists
Throws:
XSLException - if a fatal error occurs during processing or if processing terminated early. The error condition can be checked by calling XSLException.isError()
See Also:
load(org.w3c.dom.Document)

process

public void process(Node sourceDocument,
                    URL sourceURI,
                    boolean alreadyStripped)
             throws XSLException
Processes the specified source document with this stylesheet. This stylesheet remains unaffected by the processing, so it can be reused to process additional source documents.

Parameters:
sourceDocument - the source document to be processed. Note that this may be either a Document or DocumentFragment since XSLT relaxes the restrictions on the source tree when the document is created by means other than parsing a well-formed XML document. The result of the processing depends on what type of result handler is set using setResultHandler(). If no result handler is set explicitly, then a DOMResultHandler is used. The resulting document can be retrieved by calling ((DOMResultHandler)stylesheet.getResultHandler()).getDocument();
sourceURI - the source document base url, if it exists
alreadyStripped - If true, no runtime whitespace stripping will occur, which is faster
Throws:
XSLException - if a fatal error occurs during processing or if processing terminated early. The error condition can be checked by calling XSLException.isError()
See Also:
load(org.w3c.dom.Document)

dump

public void dump(PrintWriter out)
Dumps this object to the specified output stream.

Parameters:
out - the output stream o write to

dump

public void dump(PrintWriter out,
                 int indent)
Dumps this object to the specified output stream.

Parameters:
out - the output stream to write to
indent - number of tabs to indent

registerResetCache

public void registerResetCache(XPathResetCache reset)
Register an instance of XPathResetCache so it will be called when the source document changes

Specified by:
registerResetCache in interface XPathResetRegistrar
Parameters:
reset - The object implementing XPathResetCache

getVariable

public Expression getVariable(ExpandedQName varName)
Return an object of type Expression given an ExpandedQName name. Note that this will always return non-null because if a name is not bound, it is assumed to be a top-level variable whose definition has not yet been encountered. The parser will fixup the top level variable placeholders after the last node in the stylesheet tree is encountered.

Specified by:
getVariable in interface VariableBindings
Parameters:
varName - The name of the variable
Returns:
Expression object bound to passed name.