Class SAXTransformerFactory
java.lang.Object
javax.xml.transform.TransformerFactory
javax.xml.transform.sax.SAXTransformerFactory
This class extends TransformerFactory to provide SAX-specific
factory methods. It provides two types of ContentHandlers,
one for creating Transformers, the other for creating Templates
objects.
If an application wants to set the ErrorHandler or EntityResolver for an XMLReader used during a transformation, it should use a URIResolver to return the SAXSource which provides (with getXMLReader) a reference to the XMLReader.
- Since:
- 1.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIfTransformerFactory.getFeature(String)returns true when passed this value as an argument, the TransformerFactory returned fromTransformerFactory.newInstance()may be safely cast to a SAXTransformerFactory.static final StringIfTransformerFactory.getFeature(String)returns true when passed this value as an argument, thenewXMLFilter(Source src)andnewXMLFilter(Templates templates)methods are supported. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThe default constructor is protected on purpose. -
Method Summary
Modifier and TypeMethodDescriptionabstract TemplatesHandlerGet a TemplatesHandler object that can process SAX ContentHandler events into a Templates object.abstract TransformerHandlerGet a TransformerHandler object that can process SAX ContentHandler events into a Result.abstract TransformerHandlerGet a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.abstract TransformerHandlernewTransformerHandler(Templates templates) Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the Templates argument.abstract XMLFilternewXMLFilter(Source src) Create an XMLFilter that uses the given Source as the transformation instructions.abstract XMLFilternewXMLFilter(Templates templates) Create an XMLFilter, based on the Templates argument..Methods declared in class TransformerFactory
getAssociatedStylesheet, getAttribute, getErrorListener, getFeature, getURIResolver, newDefaultInstance, newInstance, newInstance, newTemplates, newTransformer, newTransformer, setAttribute, setErrorListener, setFeature, setURIResolverModifier and TypeMethodDescriptionabstract SourcegetAssociatedStylesheet(Source source, String media, String title, String charset) Get the stylesheet specification(s) associated with the XMLSourcedocument via the xml-stylesheet processing instruction that match the given criteria.abstract ObjectgetAttribute(String name) Allows the user to retrieve specific attributes on the underlying implementation.abstract ErrorListenerGet the error event handler for the TransformerFactory.abstract booleangetFeature(String name) Look up the value of a feature.abstract URIResolverGet the object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include.static TransformerFactoryCreates a new instance of theTransformerFactorybuiltin system-default implementation.static TransformerFactoryObtains a new instance of aTransformerFactory.static TransformerFactorynewInstance(String factoryClassName, ClassLoader classLoader) Obtain a new instance of aTransformerFactoryfrom factory class name.abstract TemplatesnewTemplates(Source source) Process the Source into a Templates object, which is a a compiled representation of the source.abstract TransformerCreate a newTransformerthat performs a copy of theSourceto theResult, i.e. the "identity transform".abstract TransformernewTransformer(Source source) Process theSourceinto aTransformerObject.abstract voidsetAttribute(String name, Object value) Allows the user to set specific attributes on the underlying implementation.abstract voidsetErrorListener(ErrorListener listener) Set the error event listener for the TransformerFactory, which is used for the processing of transformation instructions, and not for the transformation itself.abstract voidsetFeature(String name, boolean value) Set a feature for thisTransformerFactoryandTransformers orTemplates created by this factory.abstract voidsetURIResolver(URIResolver resolver) Set an object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
FEATURE
IfTransformerFactory.getFeature(String)returns true when passed this value as an argument, the TransformerFactory returned fromTransformerFactory.newInstance()may be safely cast to a SAXTransformerFactory.- See Also:
-
FEATURE_XMLFILTER
IfTransformerFactory.getFeature(String)returns true when passed this value as an argument, thenewXMLFilter(Source src)andnewXMLFilter(Templates templates)methods are supported.- See Also:
-
-
Constructor Details
-
SAXTransformerFactory
protected SAXTransformerFactory()The default constructor is protected on purpose.
-
-
Method Details
-
newTransformerHandler
public abstract TransformerHandler newTransformerHandler(Source src) throws TransformerConfigurationException Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.- Parameters:
src- The Source of the transformation instructions.- Returns:
- TransformerHandler ready to transform SAX events.
- Throws:
TransformerConfigurationException- If for some reason the TransformerHandler can not be created.
-
newTransformerHandler
public abstract TransformerHandler newTransformerHandler(Templates templates) throws TransformerConfigurationException Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the Templates argument.- Parameters:
templates- The compiled transformation instructions.- Returns:
- TransformerHandler ready to transform SAX events.
- Throws:
TransformerConfigurationException- If for some reason the TransformerHandler can not be created.
-
newTransformerHandler
Get a TransformerHandler object that can process SAX ContentHandler events into a Result. The transformation is defined as an identity (or copy) transformation, for example to copy a series of SAX parse events into a DOM tree.- Returns:
- A non-null reference to a TransformerHandler, that may be used as a ContentHandler for SAX parse events.
- Throws:
TransformerConfigurationException- If for some reason the TransformerHandler cannot be created.
-
newTemplatesHandler
Get a TemplatesHandler object that can process SAX ContentHandler events into a Templates object.- Returns:
- A non-null reference to a TransformerHandler, that may be used as a ContentHandler for SAX parse events.
- Throws:
TransformerConfigurationException- If for some reason the TemplatesHandler cannot be created.
-
newXMLFilter
Create an XMLFilter that uses the given Source as the transformation instructions.- Parameters:
src- The Source of the transformation instructions.- Returns:
- An XMLFilter object, or null if this feature is not supported.
- Throws:
TransformerConfigurationException- If for some reason the TemplatesHandler cannot be created.
-
newXMLFilter
public abstract XMLFilter newXMLFilter(Templates templates) throws TransformerConfigurationException Create an XMLFilter, based on the Templates argument..- Parameters:
templates- The compiled transformation instructions.- Returns:
- An XMLFilter object, or null if this feature is not supported.
- Throws:
TransformerConfigurationException- If for some reason the TemplatesHandler cannot be created.
-