Class TransformerFactoryImpl
public class TransformerFactoryImpl extends SAXTransformerFactory
-
Field Summary
Fields Modifier and Type Field Description static StringFEATURE_INCREMENTALStatic string to be used for incremental featurestatic StringFEATURE_OPTIMIZEStatic string to be used for optimize featurestatic StringFEATURE_SOURCE_LOCATIONStatic string to be used for source_location featurestatic StringXSLT_PROPERTIESThe path/filename of the property file: XSLTInfo.properties Maintenance note: see alsoorg.apache.xpath.functions.FuncSystemProperty.XSLT_PROPERTIESFields inherited from class javax.xml.transform.sax.SAXTransformerFactory
FEATURE, FEATURE_XMLFILTER -
Constructor Summary
Constructors Constructor Description TransformerFactoryImpl()Constructor TransformerFactoryImpl -
Method Summary
Modifier and Type Method Description SourcegetAssociatedStylesheet(Source source, String media, String title, 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.ObjectgetAttribute(String name)Allows the user to retrieve specific attributes on the underlying implementation.ErrorListenergetErrorListener()Get the error listener in effect for the TransformerFactory.booleangetFeature(String name)Look up the value of a feature.URIResolvergetURIResolver()Get the object that will be used to resolve URIs used in xsl:import, etc.booleanisSecureProcessing()Return the state of the secure processing feature.TemplatesnewTemplates(Source source)Process the source into a Templates object, which is likely a compiled representation of the source.TemplatesHandlernewTemplatesHandler()Create a new Transformer object that performs a copy of the source to the result.TransformernewTransformer()Create a new Transformer object that performs a copy of the source to the result.TransformernewTransformer(Source source)Process the source into a Transformer object.TransformerHandlernewTransformerHandler()Get a TransformerHandler object that can process SAX ContentHandler events into a Result.TransformerHandlernewTransformerHandler(Source src)Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.TransformerHandlernewTransformerHandler(Templates templates)Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the Templates argument.XMLFilternewXMLFilter(Source src)Create an XMLFilter that uses the given source as the transformation instructions.XMLFilternewXMLFilter(Templates templates)Create an XMLFilter that uses the given source as the transformation instructions.TemplatesprocessFromNode(Node node)voidsetAttribute(String name, Object value)Allows the user to set specific attributes on the underlying implementation.voidsetErrorListener(ErrorListener listener)Set an error listener for the TransformerFactory.voidsetFeature(String name, boolean value)Set a feature for thisTransformerFactoryandTransformers orTemplates created by this factory.voidsetURIResolver(URIResolver resolver)Set an object that will be used to resolve URIs used in xsl:import, etc.Methods inherited from class javax.xml.transform.TransformerFactory
newInstance, newInstance
-
Field Details
-
XSLT_PROPERTIES
The path/filename of the property file: XSLTInfo.properties Maintenance note: see alsoorg.apache.xpath.functions.FuncSystemProperty.XSLT_PROPERTIES- See Also:
- Constant Field Values
-
FEATURE_INCREMENTAL
Static string to be used for incremental feature- See Also:
- Constant Field Values
-
FEATURE_OPTIMIZE
Static string to be used for optimize feature- See Also:
- Constant Field Values
-
FEATURE_SOURCE_LOCATION
Static string to be used for source_location feature- See Also:
- Constant Field Values
-
-
Constructor Details
-
TransformerFactoryImpl
public TransformerFactoryImpl()Constructor TransformerFactoryImpl
-
-
Method Details
-
processFromNode
-
getAssociatedStylesheet
public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationExceptionGet 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.
- Specified by:
getAssociatedStylesheetin classTransformerFactory- Parameters:
source- The XML source that is to be searched.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 capable of being used to create a Templates object.
- Throws:
TransformerConfigurationException- See Also:
- Associating Style Sheets with XML documents Version 1.0
-
newTemplatesHandler
Create a new Transformer object that performs a copy of the source to the result.- Specified by:
newTemplatesHandlerin classSAXTransformerFactory- Returns:
- A Transformer object that may be used to perform a transformation in a single thread, never null.
- Throws:
TransformerConfigurationException- May throw this during the parse when it is constructing the Templates object and fails.
-
setFeature
Set 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 classTransformerFactory- Parameters:
name- Feature name.value- Is feature statetrueorfalse.- Throws:
TransformerConfigurationException- if thisTransformerFactoryor theTransformers orTemplates it creates cannot support this feature.NullPointerException- If thenameparameter is null.
-
getFeature
Look up the value of a feature.The feature name is any fully-qualified URI. It is possible for an TransformerFactory 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.
- Specified by:
getFeaturein classTransformerFactory- Parameters:
name- The feature name, which is a fully-qualified URI.- Returns:
- The current state of the feature (true or false).
-
setAttribute
Allows the user to set specific attributes on the underlying implementation.- Specified by:
setAttributein classTransformerFactory- Parameters:
name- The name of the attribute.value- The value of the attribute; Boolean or String="true"|"false"- Throws:
IllegalArgumentException- thrown if the underlying implementation doesn't recognize the attribute.
-
getAttribute
Allows the user to retrieve specific attributes on the underlying implementation.- Specified by:
getAttributein classTransformerFactory- Parameters:
name- The name of the attribute.- Returns:
- value The value of the attribute.
- Throws:
IllegalArgumentException- thrown if the underlying implementation doesn't recognize the attribute.
-
newXMLFilter
Create an XMLFilter that uses the given source as the transformation instructions.- Specified by:
newXMLFilterin classSAXTransformerFactory- Parameters:
src- The source of the transformation instructions.- Returns:
- An XMLFilter object, or null if this feature is not supported.
- Throws:
TransformerConfigurationException
-
newXMLFilter
Create an XMLFilter that uses the given source as the transformation instructions.- Specified by:
newXMLFilterin classSAXTransformerFactory- Parameters:
templates- non-null reference to Templates object.- Returns:
- An XMLFilter object, or null if this feature is not supported.
- Throws:
TransformerConfigurationException
-
newTransformerHandler
public TransformerHandler newTransformerHandler(Source src) throws TransformerConfigurationExceptionGet a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.- Specified by:
newTransformerHandlerin classSAXTransformerFactory- Parameters:
src- The source of the transformation instructions.- Returns:
- TransformerHandler ready to transform SAX events.
- Throws:
TransformerConfigurationException
-
newTransformerHandler
public TransformerHandler newTransformerHandler(Templates templates) throws TransformerConfigurationExceptionGet a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the Templates argument.- Specified by:
newTransformerHandlerin classSAXTransformerFactory- Parameters:
templates- The source of the transformation instructions.- Returns:
- TransformerHandler ready to transform SAX events.
- Throws:
TransformerConfigurationException
-
newTransformerHandler
Get a TransformerHandler object that can process SAX ContentHandler events into a Result.- Specified by:
newTransformerHandlerin classSAXTransformerFactory- Returns:
- TransformerHandler ready to transform SAX events.
- Throws:
TransformerConfigurationException
-
newTransformer
Process the source into a Transformer object. Care must be given to know that this object can not be used concurrently in multiple threads.- Specified by:
newTransformerin classTransformerFactory- Parameters:
source- An object that holds a URL, input stream, etc.- Returns:
- A Transformer object capable of being used for transformation purposes in a single thread.
- Throws:
TransformerConfigurationException- May throw this during the parse when it is constructing the Templates object and fails.- See Also:
- XSL Transformations (XSLT) Version 1.0
-
newTransformer
Create a new Transformer object that performs a copy of the source to the result.- Specified by:
newTransformerin classTransformerFactory- Returns:
- A Transformer object capable of being used for transformation purposes in a single thread.
- Throws:
TransformerConfigurationException- May throw this during the parse when it is constructing the Templates object and it fails.
-
newTemplates
Process the source into a Templates object, which is likely a compiled representation of the source. This Templates object may then be used concurrently across multiple threads. Creating a Templates object allows the TransformerFactory to do detailed performance optimization of transformation instructions, without penalizing runtime transformation.- Specified by:
newTemplatesin classTransformerFactory- Parameters:
source- An object that holds a URL, input stream, etc.- Returns:
- A Templates object capable of being used for transformation purposes.
- Throws:
TransformerConfigurationException- May throw this during the parse when it is constructing the Templates object and fails.
-
setURIResolver
Set an object that will be used to resolve URIs used in xsl:import, etc. This will be used as the default for the transformation.- Specified by:
setURIResolverin classTransformerFactory- Parameters:
resolver- An object that implements the URIResolver interface, or null.
-
getURIResolver
Get the object that will be used to resolve URIs used in xsl:import, etc. This will be used as the default for the transformation.- Specified by:
getURIResolverin classTransformerFactory- Returns:
- The URIResolver that was set with setURIResolver.
-
getErrorListener
Get the error listener in effect for the TransformerFactory.- Specified by:
getErrorListenerin classTransformerFactory- Returns:
- A non-null reference to an error listener.
-
setErrorListener
Set an error listener for the TransformerFactory.- Specified by:
setErrorListenerin classTransformerFactory- Parameters:
listener- Must be a non-null reference to an ErrorListener.- Throws:
IllegalArgumentException- if the listener argument is null.
-
isSecureProcessing
public boolean isSecureProcessing()Return the state of the secure processing feature.- Returns:
- state of the secure processing feature.
-