Package org.apache.xalan.xsltc.trax
Class TransformerFactoryImpl
java.lang.Object
javax.xml.transform.TransformerFactory
javax.xml.transform.sax.SAXTransformerFactory
org.apache.xalan.xsltc.trax.TransformerFactoryImpl
- All Implemented Interfaces:
ErrorListener
,SourceLoader
public class TransformerFactoryImpl
extends SAXTransformerFactory
implements SourceLoader, ErrorListener
Implementation of a JAXP1.1 TransformerFactory for Translets.
- Author:
- G. Todd Miller, Morten Jorgensen, Santiago Pericas-Geertsen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class javax.xml.transform.sax.SAXTransformerFactory
FEATURE, FEATURE_XMLFILTER
-
Constructor Summary
ConstructorsConstructorDescriptionjavax.xml.transform.sax.TransformerFactory implementation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Receive notification of a recoverable error.void
Receive notification of a non-recoverable error.getAssociatedStylesheet
(Source source, String media, String title, String charset) javax.xml.transform.sax.TransformerFactory implementation.getAttribute
(String name) javax.xml.transform.sax.TransformerFactory implementation.javax.xml.transform.sax.TransformerFactory implementation.boolean
getFeature
(String name) javax.xml.transform.sax.TransformerFactory implementation.javax.xml.transform.sax.TransformerFactory implementation.loadSource
(String href, String context, XSLTC xsltc) This method implements XSLTC's SourceLoader interface.newTemplates
(Source source) javax.xml.transform.sax.TransformerFactory implementation.javax.xml.transform.sax.SAXTransformerFactory implementation.javax.xml.transform.sax.TransformerFactory implementation.newTransformer
(Source source) javax.xml.transform.sax.TransformerFactory implementation.javax.xml.transform.sax.SAXTransformerFactory implementation.javax.xml.transform.sax.SAXTransformerFactory implementation.newTransformerHandler
(Templates templates) javax.xml.transform.sax.SAXTransformerFactory implementation.newXMLFilter
(Source src) javax.xml.transform.sax.SAXTransformerFactory implementation.newXMLFilter
(Templates templates) javax.xml.transform.sax.SAXTransformerFactory implementation.void
setAttribute
(String name, Object value) javax.xml.transform.sax.TransformerFactory implementation.void
setErrorListener
(ErrorListener listener) javax.xml.transform.sax.TransformerFactory implementation.void
setFeature
(String name, boolean value) Set a feature for thisTransformerFactory
andTransformer
s orTemplate
s created by this factory.void
setURIResolver
(URIResolver resolver) javax.xml.transform.sax.TransformerFactory implementation.void
Receive notification of a warning.Methods inherited from class javax.xml.transform.TransformerFactory
newDefaultInstance, newInstance, newInstance
-
Field Details
-
TRANSLET_NAME
- See Also:
-
DESTINATION_DIRECTORY
- See Also:
-
PACKAGE_NAME
- See Also:
-
JAR_NAME
- See Also:
-
GENERATE_TRANSLET
- See Also:
-
AUTO_TRANSLET
- See Also:
-
USE_CLASSPATH
- See Also:
-
DEBUG
- See Also:
-
ENABLE_INLINING
- See Also:
-
INDENT_NUMBER
- See Also:
-
-
Constructor Details
-
TransformerFactoryImpl
public TransformerFactoryImpl()javax.xml.transform.sax.TransformerFactory implementation.
-
-
Method Details
-
setErrorListener
javax.xml.transform.sax.TransformerFactory implementation. Set the error event listener for the TransformerFactory, which is used for the processing of transformation instructions, and not for the transformation itself.- Specified by:
setErrorListener
in classTransformerFactory
- Parameters:
listener
- The error listener to use with the TransformerFactory- Throws:
IllegalArgumentException
-
getErrorListener
javax.xml.transform.sax.TransformerFactory implementation. Get the error event handler for the TransformerFactory.- Specified by:
getErrorListener
in classTransformerFactory
- Returns:
- The error listener used with the TransformerFactory
-
getAttribute
javax.xml.transform.sax.TransformerFactory implementation. Returns the value set for a TransformerFactory attribute- Specified by:
getAttribute
in classTransformerFactory
- Parameters:
name
- The attribute name- Returns:
- An object representing the attribute value
- Throws:
IllegalArgumentException
-
setAttribute
javax.xml.transform.sax.TransformerFactory implementation. Sets the value for a TransformerFactory attribute.- Specified by:
setAttribute
in classTransformerFactory
- Parameters:
name
- The attribute namevalue
- An object representing the attribute value- Throws:
IllegalArgumentException
-
setFeature
Set a feature for this
TransformerFactory
andTransformer
s orTemplate
s created by this factory.Feature names are fully qualified
URI
s. Implementations may define their own features. AnTransformerConfigurationException
is thrown if thisTransformerFactory
or theTransformer
s orTemplate
s it creates cannot support the feature. It is possible for anTransformerFactory
to expose a feature value but be unable to change its state.See
TransformerFactory
for full documentation of specific features.- Specified by:
setFeature
in classTransformerFactory
- Parameters:
name
- Feature name.value
- Is feature statetrue
orfalse
.- Throws:
TransformerConfigurationException
- if thisTransformerFactory
or theTransformer
s orTemplate
s it creates cannot support this feature.NullPointerException
- If thename
parameter is null.
-
getFeature
javax.xml.transform.sax.TransformerFactory implementation. Look up the value of a feature (to see if it is supported). This method must be updated as the various methods and features of this class are implemented.- Specified by:
getFeature
in classTransformerFactory
- Parameters:
name
- The feature name- Returns:
- 'true' if feature is supported, 'false' if not
-
getURIResolver
javax.xml.transform.sax.TransformerFactory implementation. Get the object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include.- Specified by:
getURIResolver
in classTransformerFactory
- Returns:
- The URLResolver used for this TransformerFactory and all Templates and Transformer objects created using this factory
-
setURIResolver
javax.xml.transform.sax.TransformerFactory implementation. Set the object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include. Note that this does not affect Templates and Transformers that are already created with this factory.- Specified by:
setURIResolver
in classTransformerFactory
- Parameters:
resolver
- The URLResolver used for this TransformerFactory and all Templates and Transformer objects created using this factory
-
getAssociatedStylesheet
public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException javax.xml.transform.sax.TransformerFactory implementation. Get the stylesheet specification(s) associated via the xml-stylesheet processing instruction (see http://www.w3.org/TR/xml-stylesheet/) with the document document specified in the source parameter, and that match the given criteria.- Specified by:
getAssociatedStylesheet
in classTransformerFactory
- Parameters:
source
- The XML source document.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.- Returns:
- A Source object suitable for passing to the TransformerFactory.
- Throws:
TransformerConfigurationException
-
newTransformer
javax.xml.transform.sax.TransformerFactory implementation. Create a Transformer object that copies the input document to the result.- Specified by:
newTransformer
in classTransformerFactory
- Returns:
- A Transformer object that simply copies the source to the result.
- Throws:
TransformerConfigurationException
-
newTransformer
javax.xml.transform.sax.TransformerFactory implementation. Process the Source into a Templates object, which is a a compiled representation of the source. Note that this method should not be used with XSLTC, as the time-consuming compilation is done for each and every transformation.- Specified by:
newTransformer
in classTransformerFactory
- Returns:
- A Templates object that can be used to create Transformers.
- Throws:
TransformerConfigurationException
-
newTemplates
javax.xml.transform.sax.TransformerFactory implementation. Process the Source into a Templates object, which is a a compiled representation of the source.- Specified by:
newTemplates
in classTransformerFactory
- Parameters:
source
- The input stylesheet - DOMSource not supported!!!- Returns:
- A Templates object that can be used to create Transformers.
- Throws:
TransformerConfigurationException
-
newTemplatesHandler
javax.xml.transform.sax.SAXTransformerFactory implementation. Get a TemplatesHandler object that can process SAX ContentHandler events into a Templates object.- Specified by:
newTemplatesHandler
in classSAXTransformerFactory
- Returns:
- A TemplatesHandler object that can handle SAX events
- Throws:
TransformerConfigurationException
-
newTransformerHandler
javax.xml.transform.sax.SAXTransformerFactory implementation. Get a TransformerHandler object that can process SAX ContentHandler events into a Result. This method will return a pure copy transformer.- Specified by:
newTransformerHandler
in classSAXTransformerFactory
- Returns:
- A TransformerHandler object that can handle SAX events
- Throws:
TransformerConfigurationException
-
newTransformerHandler
public TransformerHandler newTransformerHandler(Source src) throws TransformerConfigurationException javax.xml.transform.sax.SAXTransformerFactory implementation. Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.- Specified by:
newTransformerHandler
in classSAXTransformerFactory
- Parameters:
src
- The source of the transformation instructions.- Returns:
- A TransformerHandler object that can handle SAX events
- Throws:
TransformerConfigurationException
-
newTransformerHandler
public TransformerHandler newTransformerHandler(Templates templates) throws TransformerConfigurationException javax.xml.transform.sax.SAXTransformerFactory implementation. Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.- Specified by:
newTransformerHandler
in classSAXTransformerFactory
- Parameters:
templates
- Represents a pre-processed stylesheet- Returns:
- A TransformerHandler object that can handle SAX events
- Throws:
TransformerConfigurationException
-
newXMLFilter
javax.xml.transform.sax.SAXTransformerFactory implementation. Create an XMLFilter that uses the given source as the transformation instructions.- Specified by:
newXMLFilter
in classSAXTransformerFactory
- Parameters:
src
- The source of the transformation instructions.- Returns:
- An XMLFilter object, or null if this feature is not supported.
- Throws:
TransformerConfigurationException
-
newXMLFilter
javax.xml.transform.sax.SAXTransformerFactory implementation. Create an XMLFilter that uses the given source as the transformation instructions.- Specified by:
newXMLFilter
in classSAXTransformerFactory
- Parameters:
templates
- The source of the transformation instructions.- Returns:
- An XMLFilter object, or null if this feature is not supported.
- Throws:
TransformerConfigurationException
-
error
Receive notification of a recoverable error. The transformer must continue to provide normal parsing events after invoking this method. It should still be possible for the application to process the document through to the end.- Specified by:
error
in interfaceErrorListener
- Parameters:
e
- The warning information encapsulated in a transformer exception.- Throws:
TransformerException
- if the application chooses to discontinue the transformation (always does in our case).
-
fatalError
Receive notification of a non-recoverable error. The application must assume that the transformation cannot continue after the Transformer has invoked this method, and should continue (if at all) only to collect addition error messages. In fact, Transformers are free to stop reporting events once this method has been invoked.- Specified by:
fatalError
in interfaceErrorListener
- Parameters:
e
- warning information encapsulated in a transformer exception.- Throws:
TransformerException
- if the application chooses to discontinue the transformation (always does in our case).
-
warning
Receive notification of a warning. Transformers can use this method to report conditions that are not errors or fatal errors. The default behaviour is to take no action. After invoking this method, the Transformer must continue with the transformation. It should still be possible for the application to process the document through to the end.- Specified by:
warning
in interfaceErrorListener
- Parameters:
e
- The warning information encapsulated in a transformer exception.- Throws:
TransformerException
- if the application chooses to discontinue the transformation (never does in our case).
-
loadSource
This method implements XSLTC's SourceLoader interface. It is used to glue a TrAX URIResolver to the XSLTC compiler's Input and Import classes.- Specified by:
loadSource
in interfaceSourceLoader
- Parameters:
href
- The URI of the document to loadcontext
- The URI of the currently loaded documentxsltc
- The compiler that resuests the document- Returns:
- An InputSource with the loaded document
-