org.apache.xalan.processor
Class StylesheetProcessor

java.lang.Object
  |
  +--org.apache.trax.Processor
        |
        +--org.apache.xalan.processor.StylesheetProcessor
Direct Known Subclasses:
CompilingStylesheetProcessor

public class StylesheetProcessor
extends Processor

The StylesheetProcessor, which implements the TRaX Processor interface, processes XSLT stylesheets into a Templates object (a StylesheetRoot).


Field Summary
static java.lang.String XSLT_PROPERTIES
           
 
Fields inherited from class org.apache.trax.Processor
PropertiesResource
 
Constructor Summary
StylesheetProcessor()
           
 
Method Summary
 InputSource[] getAssociatedStylesheets(InputSource source, java.lang.String media, java.lang.String title, java.lang.String charset)
          Get InputSource specification(s) that are associated with the given document specified in the source param, via the xml-stylesheet processing instruction (see http://www.w3.org/TR/xml-stylesheet/), and that matches the given criteria.
 boolean getFeature(java.lang.String name)
          Look up the value of a feature.
 TemplatesBuilder getTemplatesBuilder()
          Get a TemplatesBuilder object that can process SAX events into a Templates object, if the processor supports the "http://xml.org/trax/features/sax/input" feature.
 Templates process(InputSource source)
          Process the source into a templates object.
 Templates processFromNode(Node node)
          Process the stylesheet from a DOM tree, if the processor supports the "http://xml.org/trax/features/dom/input" feature.
 Templates processFromNode(Node node, java.lang.String systemID)
          Process the stylesheet from a DOM tree, if the processor supports the "http://xml.org/trax/features/dom/input" feature.
 Templates processMultiple(InputSource[] source)
          Process a series of inputs, treating them in import or cascade order.
 
Methods inherited from class org.apache.trax.Processor
getEntityResolver, getErrorHandler, getURIResolver, getXMLReader, newInstance, setEntityResolver, setErrorHandler, setFeature, setPlatformDefaultProcessor, setURIResolver, setXMLReader
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XSLT_PROPERTIES

public static java.lang.String XSLT_PROPERTIES
Constructor Detail

StylesheetProcessor

public StylesheetProcessor()
Method Detail

process

public Templates process(InputSource source)
                  throws ProcessorException,
                         SAXException,
                         java.io.IOException
Process the source into a templates object.
Parameters:
source - An object that holds a URL, input stream, etc.
Overrides:
process in class Processor

processFromNode

public Templates processFromNode(Node node)
                          throws ProcessorException
Process the stylesheet from a DOM tree, if the processor supports the "http://xml.org/trax/features/dom/input" feature.
Parameters:
node - A DOM tree which must contain valid transform instructions that this processor understands.
Overrides:
processFromNode in class Processor

processFromNode

public Templates processFromNode(Node node,
                                 java.lang.String systemID)
                          throws ProcessorException
Process the stylesheet from a DOM tree, if the processor supports the "http://xml.org/trax/features/dom/input" feature.
Parameters:
node - A DOM tree which must contain valid transform instructions that this processor understands.
systemID - The systemID from where xsl:includes and xsl:imports should be resolved from.
Overrides:
processFromNode in class Processor

processMultiple

public Templates processMultiple(InputSource[] source)
                          throws ProcessorException
Process a series of inputs, treating them in import or cascade order. This is mainly for support of the getAssociatedStylesheets method, but may be useful for other purposes.
Parameters:
sources - An array of SAX InputSource objects.
Overrides:
processMultiple in class Processor

getAssociatedStylesheets

public InputSource[] getAssociatedStylesheets(InputSource source,
                                              java.lang.String media,
                                              java.lang.String title,
                                              java.lang.String charset)
                                       throws ProcessorException
Get InputSource specification(s) that are associated with the given document specified in the source param, via the xml-stylesheet processing instruction (see http://www.w3.org/TR/xml-stylesheet/), and that matches the given criteria. Note that it is possible to return several stylesheets that match the criteria, in which case they are applied as if they were a list of imports or cascades.

Note that DOM2 has it's own mechanism for discovering stylesheets. Therefore, there isn't a DOM version of this method.

Parameters:
media - The media attribute to be matched. May be null, in which case the prefered templates will be used (i.e. alternate = no).
title - The value of the title attribute to match. May be null.
charset - The value of the charset attribute to match. May be null.
Overrides:
getAssociatedStylesheets in class Processor

getTemplatesBuilder

public TemplatesBuilder getTemplatesBuilder()
                                     throws ProcessorException
Get a TemplatesBuilder object that can process SAX events into a Templates object, if the processor supports the "http://xml.org/trax/features/sax/input" feature.

Open issues:

Should Processor derive from org.xml.sax.ContentHandler?

Instead of requesting an object from the Processor class, should the Processor class simply derive from org.xml.sax.ContentHandler?
Returns:
A TemplatesBuilder object, or null if not supported.
Throws:
May - throw a ProcessorException if a StylesheetHandler can not be constructed for some reason.
Overrides:
getTemplatesBuilder in class Processor

getFeature

public boolean getFeature(java.lang.String name)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Look up the value of a feature.

The feature name is any fully-qualified URI. It is possible for an Processor to recognize a feature name but to be unable to return its value; this is especially true in the case of an adapter for a SAX1 Parser, which has no way of knowing whether the underlying parser is validating, for example.

Open issues:

Should getFeature be changed to hasFeature?

Keith Visco writes: Should getFeature be changed to hasFeature? It returns a boolean which indicated whether the "state" of feature is "true or false". I assume this means whether or not a feature is supported? I know SAX is using "getFeature", but to me "hasFeature" is cleaner.
Parameters:
name - The feature name, which is a fully-qualified URI.
Returns:
The current state of the feature (true or false).
Throws:
SAXNotRecognizedException - When the Processor does not recognize the feature name.
SAXNotSupportedException - When the Processor recognizes the feature name but cannot determine its value at this time.
Overrides:
getFeature in class Processor


Copyright © 2000 Apache XML Project. All Rights Reserved.