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()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
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.
-