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:
javax.xml.transform.ErrorListener,SourceLoader
public class TransformerFactoryImpl extends javax.xml.transform.sax.SAXTransformerFactory implements SourceLoader, javax.xml.transform.ErrorListener
Implementation of a JAXP1.1 TransformerFactory for Translets.- Author:
- G. Todd Miller, Morten Jorgensen, Santiago Pericas-Geertsen
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAUTO_TRANSLETstatic java.lang.StringDEBUGstatic java.lang.StringDESTINATION_DIRECTORYstatic java.lang.StringENABLE_INLININGstatic java.lang.StringGENERATE_TRANSLETstatic java.lang.StringINDENT_NUMBERstatic java.lang.StringJAR_NAMEstatic java.lang.StringPACKAGE_NAMEstatic java.lang.StringTRANSLET_NAMEstatic java.lang.StringUSE_CLASSPATH
-
Constructor Summary
Constructors Constructor Description TransformerFactoryImpl()javax.xml.transform.sax.TransformerFactory implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiderror(javax.xml.transform.TransformerException e)Receive notification of a recoverable error.voidfatalError(javax.xml.transform.TransformerException e)Receive notification of a non-recoverable error.javax.xml.transform.SourcegetAssociatedStylesheet(javax.xml.transform.Source source, java.lang.String media, java.lang.String title, java.lang.String charset)javax.xml.transform.sax.TransformerFactory implementation.java.lang.ObjectgetAttribute(java.lang.String name)javax.xml.transform.sax.TransformerFactory implementation.javax.xml.transform.ErrorListenergetErrorListener()javax.xml.transform.sax.TransformerFactory implementation.booleangetFeature(java.lang.String name)javax.xml.transform.sax.TransformerFactory implementation.javax.xml.transform.URIResolvergetURIResolver()javax.xml.transform.sax.TransformerFactory implementation.org.xml.sax.InputSourceloadSource(java.lang.String href, java.lang.String context, XSLTC xsltc)This method implements XSLTC's SourceLoader interface.javax.xml.transform.TemplatesnewTemplates(javax.xml.transform.Source source)javax.xml.transform.sax.TransformerFactory implementation.javax.xml.transform.sax.TemplatesHandlernewTemplatesHandler()javax.xml.transform.sax.SAXTransformerFactory implementation.javax.xml.transform.TransformernewTransformer()javax.xml.transform.sax.TransformerFactory implementation.javax.xml.transform.TransformernewTransformer(javax.xml.transform.Source source)javax.xml.transform.sax.TransformerFactory implementation.javax.xml.transform.sax.TransformerHandlernewTransformerHandler()javax.xml.transform.sax.SAXTransformerFactory implementation.javax.xml.transform.sax.TransformerHandlernewTransformerHandler(javax.xml.transform.Source src)javax.xml.transform.sax.SAXTransformerFactory implementation.javax.xml.transform.sax.TransformerHandlernewTransformerHandler(javax.xml.transform.Templates templates)javax.xml.transform.sax.SAXTransformerFactory implementation.org.xml.sax.XMLFilternewXMLFilter(javax.xml.transform.Source src)javax.xml.transform.sax.SAXTransformerFactory implementation.org.xml.sax.XMLFilternewXMLFilter(javax.xml.transform.Templates templates)javax.xml.transform.sax.SAXTransformerFactory implementation.voidsetAttribute(java.lang.String name, java.lang.Object value)javax.xml.transform.sax.TransformerFactory implementation.voidsetErrorListener(javax.xml.transform.ErrorListener listener)javax.xml.transform.sax.TransformerFactory implementation.voidsetFeature(java.lang.String name, boolean value)Set a feature for thisTransformerFactoryandTransformers orTemplates created by this factory.voidsetURIResolver(javax.xml.transform.URIResolver resolver)javax.xml.transform.sax.TransformerFactory implementation.voidwarning(javax.xml.transform.TransformerException e)Receive notification of a warning.
-
-
-
Field Detail
-
TRANSLET_NAME
public static final java.lang.String TRANSLET_NAME
- See Also:
- Constant Field Values
-
DESTINATION_DIRECTORY
public static final java.lang.String DESTINATION_DIRECTORY
- See Also:
- Constant Field Values
-
PACKAGE_NAME
public static final java.lang.String PACKAGE_NAME
- See Also:
- Constant Field Values
-
JAR_NAME
public static final java.lang.String JAR_NAME
- See Also:
- Constant Field Values
-
GENERATE_TRANSLET
public static final java.lang.String GENERATE_TRANSLET
- See Also:
- Constant Field Values
-
AUTO_TRANSLET
public static final java.lang.String AUTO_TRANSLET
- See Also:
- Constant Field Values
-
USE_CLASSPATH
public static final java.lang.String USE_CLASSPATH
- See Also:
- Constant Field Values
-
DEBUG
public static final java.lang.String DEBUG
- See Also:
- Constant Field Values
-
ENABLE_INLINING
public static final java.lang.String ENABLE_INLINING
- See Also:
- Constant Field Values
-
INDENT_NUMBER
public static final java.lang.String INDENT_NUMBER
- See Also:
- Constant Field Values
-
-
Method Detail
-
setErrorListener
public void setErrorListener(javax.xml.transform.ErrorListener listener) throws java.lang.IllegalArgumentExceptionjavax.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:
setErrorListenerin classjavax.xml.transform.TransformerFactory- Parameters:
listener- The error listener to use with the TransformerFactory- Throws:
java.lang.IllegalArgumentException
-
getErrorListener
public javax.xml.transform.ErrorListener getErrorListener()
javax.xml.transform.sax.TransformerFactory implementation. Get the error event handler for the TransformerFactory.- Specified by:
getErrorListenerin classjavax.xml.transform.TransformerFactory- Returns:
- The error listener used with the TransformerFactory
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name) throws java.lang.IllegalArgumentExceptionjavax.xml.transform.sax.TransformerFactory implementation. Returns the value set for a TransformerFactory attribute- Specified by:
getAttributein classjavax.xml.transform.TransformerFactory- Parameters:
name- The attribute name- Returns:
- An object representing the attribute value
- Throws:
java.lang.IllegalArgumentException
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value) throws java.lang.IllegalArgumentExceptionjavax.xml.transform.sax.TransformerFactory implementation. Sets the value for a TransformerFactory attribute.- Specified by:
setAttributein classjavax.xml.transform.TransformerFactory- Parameters:
name- The attribute namevalue- An object representing the attribute value- Throws:
java.lang.IllegalArgumentException
-
setFeature
public void setFeature(java.lang.String name, boolean value) throws javax.xml.transform.TransformerConfigurationExceptionSet a feature for this
TransformerFactoryandTransformers orTemplates created by this factory.Feature names are fully qualified
URIs. Implementations may define their own features. AnTransformerConfigurationExceptionis thrown if thisTransformerFactoryor theTransformers orTemplates it creates cannot support the feature. It is possible for anTransformerFactoryto expose a feature value but be unable to change its state.See
TransformerFactoryfor full documentation of specific features.- Specified by:
setFeaturein classjavax.xml.transform.TransformerFactory- Parameters:
name- Feature name.value- Is feature statetrueorfalse.- Throws:
javax.xml.transform.TransformerConfigurationException- if thisTransformerFactoryor theTransformers orTemplates it creates cannot support this feature.java.lang.NullPointerException- If thenameparameter is null.
-
getFeature
public boolean getFeature(java.lang.String name)
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:
getFeaturein classjavax.xml.transform.TransformerFactory- Parameters:
name- The feature name- Returns:
- 'true' if feature is supported, 'false' if not
-
getURIResolver
public javax.xml.transform.URIResolver 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:
getURIResolverin classjavax.xml.transform.TransformerFactory- Returns:
- The URLResolver used for this TransformerFactory and all Templates and Transformer objects created using this factory
-
setURIResolver
public void setURIResolver(javax.xml.transform.URIResolver resolver)
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:
setURIResolverin classjavax.xml.transform.TransformerFactory- Parameters:
resolver- The URLResolver used for this TransformerFactory and all Templates and Transformer objects created using this factory
-
getAssociatedStylesheet
public javax.xml.transform.Source getAssociatedStylesheet(javax.xml.transform.Source source, java.lang.String media, java.lang.String title, java.lang.String charset) throws javax.xml.transform.TransformerConfigurationExceptionjavax.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:
getAssociatedStylesheetin classjavax.xml.transform.TransformerFactory- 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:
javax.xml.transform.TransformerConfigurationException
-
newTransformer
public javax.xml.transform.Transformer newTransformer() throws javax.xml.transform.TransformerConfigurationExceptionjavax.xml.transform.sax.TransformerFactory implementation. Create a Transformer object that copies the input document to the result.- Specified by:
newTransformerin classjavax.xml.transform.TransformerFactory- Returns:
- A Transformer object that simply copies the source to the result.
- Throws:
javax.xml.transform.TransformerConfigurationException
-
newTransformer
public javax.xml.transform.Transformer newTransformer(javax.xml.transform.Source source) throws javax.xml.transform.TransformerConfigurationExceptionjavax.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:
newTransformerin classjavax.xml.transform.TransformerFactory- Returns:
- A Templates object that can be used to create Transformers.
- Throws:
javax.xml.transform.TransformerConfigurationException
-
newTemplates
public javax.xml.transform.Templates newTemplates(javax.xml.transform.Source source) throws javax.xml.transform.TransformerConfigurationExceptionjavax.xml.transform.sax.TransformerFactory implementation. Process the Source into a Templates object, which is a a compiled representation of the source.- Specified by:
newTemplatesin classjavax.xml.transform.TransformerFactory- Parameters:
source- The input stylesheet - DOMSource not supported!!!- Returns:
- A Templates object that can be used to create Transformers.
- Throws:
javax.xml.transform.TransformerConfigurationException
-
newTemplatesHandler
public javax.xml.transform.sax.TemplatesHandler newTemplatesHandler() throws javax.xml.transform.TransformerConfigurationExceptionjavax.xml.transform.sax.SAXTransformerFactory implementation. Get a TemplatesHandler object that can process SAX ContentHandler events into a Templates object.- Specified by:
newTemplatesHandlerin classjavax.xml.transform.sax.SAXTransformerFactory- Returns:
- A TemplatesHandler object that can handle SAX events
- Throws:
javax.xml.transform.TransformerConfigurationException
-
newTransformerHandler
public javax.xml.transform.sax.TransformerHandler newTransformerHandler() throws javax.xml.transform.TransformerConfigurationExceptionjavax.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:
newTransformerHandlerin classjavax.xml.transform.sax.SAXTransformerFactory- Returns:
- A TransformerHandler object that can handle SAX events
- Throws:
javax.xml.transform.TransformerConfigurationException
-
newTransformerHandler
public javax.xml.transform.sax.TransformerHandler newTransformerHandler(javax.xml.transform.Source src) throws javax.xml.transform.TransformerConfigurationExceptionjavax.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:
newTransformerHandlerin classjavax.xml.transform.sax.SAXTransformerFactory- Parameters:
src- The source of the transformation instructions.- Returns:
- A TransformerHandler object that can handle SAX events
- Throws:
javax.xml.transform.TransformerConfigurationException
-
newTransformerHandler
public javax.xml.transform.sax.TransformerHandler newTransformerHandler(javax.xml.transform.Templates templates) throws javax.xml.transform.TransformerConfigurationExceptionjavax.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:
newTransformerHandlerin classjavax.xml.transform.sax.SAXTransformerFactory- Parameters:
templates- Represents a pre-processed stylesheet- Returns:
- A TransformerHandler object that can handle SAX events
- Throws:
javax.xml.transform.TransformerConfigurationException
-
newXMLFilter
public org.xml.sax.XMLFilter newXMLFilter(javax.xml.transform.Source src) throws javax.xml.transform.TransformerConfigurationExceptionjavax.xml.transform.sax.SAXTransformerFactory implementation. Create an XMLFilter that uses the given source as the transformation instructions.- Specified by:
newXMLFilterin classjavax.xml.transform.sax.SAXTransformerFactory- Parameters:
src- The source of the transformation instructions.- Returns:
- An XMLFilter object, or null if this feature is not supported.
- Throws:
javax.xml.transform.TransformerConfigurationException
-
newXMLFilter
public org.xml.sax.XMLFilter newXMLFilter(javax.xml.transform.Templates templates) throws javax.xml.transform.TransformerConfigurationExceptionjavax.xml.transform.sax.SAXTransformerFactory implementation. Create an XMLFilter that uses the given source as the transformation instructions.- Specified by:
newXMLFilterin classjavax.xml.transform.sax.SAXTransformerFactory- Parameters:
templates- The source of the transformation instructions.- Returns:
- An XMLFilter object, or null if this feature is not supported.
- Throws:
javax.xml.transform.TransformerConfigurationException
-
error
public void error(javax.xml.transform.TransformerException e) throws javax.xml.transform.TransformerExceptionReceive 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:
errorin interfacejavax.xml.transform.ErrorListener- Parameters:
e- The warning information encapsulated in a transformer exception.- Throws:
javax.xml.transform.TransformerException- if the application chooses to discontinue the transformation (always does in our case).
-
fatalError
public void fatalError(javax.xml.transform.TransformerException e) throws javax.xml.transform.TransformerExceptionReceive 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:
fatalErrorin interfacejavax.xml.transform.ErrorListener- Parameters:
e- warning information encapsulated in a transformer exception.- Throws:
javax.xml.transform.TransformerException- if the application chooses to discontinue the transformation (always does in our case).
-
warning
public void warning(javax.xml.transform.TransformerException e) throws javax.xml.transform.TransformerExceptionReceive 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:
warningin interfacejavax.xml.transform.ErrorListener- Parameters:
e- The warning information encapsulated in a transformer exception.- Throws:
javax.xml.transform.TransformerException- if the application chooses to discontinue the transformation (never does in our case).
-
loadSource
public org.xml.sax.InputSource loadSource(java.lang.String href, java.lang.String context, XSLTC xsltc)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:
loadSourcein 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
-
-