com.jclark.xsl.trax

Class TransformerFactoryImpl

public class TransformerFactoryImpl extends SAXTransformerFactory

An implementation of the TrAX TransformerFactory class and SAXTransformerFactory classes.
   import java.io.*;
   import javax.xml.transform.*;
   ...
   System.setProperty("javax.xml.transform.TransformerFactory",
                      "jd.xml.xslt.trax.TransformerFactoryImpl");
   TransformerFactory tfactory = TransformerFactory.newInstance();

   Source stylesheetSource = ...
   Transformer transformer = tfactory.newTransformer(stylesheetSource);
   transformer.transform(...);
 
Method Summary
SourcegetAssociatedStylesheet(Source source, String media, String title, String charset)
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.
ObjectgetAttribute(String name)
Throws an IllegalArgumentException since attributes are not supported.
ErrorListenergetErrorListener()
Get the error event handler for the TransformerFactory.
booleangetFeature(String name)
Look up the value of a feature.
XMLReadergetReader(Source source)
URIResolvergetURIResolver()
Return the URIResolver that was set with setURIResolver. the object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include.
TemplatesnewTemplates(Source source)
Process the Source into a Templates object, which is a a compiled representation of the source.
TemplatesHandlernewTemplatesHandler()
Get a TemplatesHandler object that can process SAX ContentHandler events into a Templates object.
TransformernewTransformer(Source source)
Process the Source into a Transformer object.
TransformernewTransformer()
Create a new Transformer object that performs a copy of the source to the result.
TransformerHandlernewTransformerHandler()
TransformerHandlernewTransformerHandler(Source source)
TransformerHandlernewTransformerHandler(Templates templates)
XMLFilternewXMLFilter(Source source)
XMLFilternewXMLFilter(Templates templates)
voidsetAttribute(String name, Object value)
Throws an IllegalArgumentException since attributes are not supported.
voidsetErrorListener(ErrorListener listener)
Set the error event listener for the TransformerFactory, which is used for the processing of transformation instructions,
voidsetFeature(String name, boolean value)
voidsetURIResolver(URIResolver uriResolver)
Set the URIResolver.

Method Detail

getAssociatedStylesheet

public Source getAssociatedStylesheet(Source source, String media, String title, String charset)
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. Note that it is possible to return several stylesheets, in which case they are applied as if they were a list of imports or cascades.

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.

getAttribute

public Object getAttribute(String name)
Throws an IllegalArgumentException since attributes are not supported.

getErrorListener

public ErrorListener getErrorListener()
Get the error event handler for the TransformerFactory.

Returns: The current error handler, which should never be null.

getFeature

public boolean getFeature(String name)
Look up the value of a feature.

The feature name is any absolute URI.

Parameters: name The feature name, which is an absolute URI.

Returns: The current state of the feature (true or false).

getReader

public XMLReader getReader(Source source)

getURIResolver

public URIResolver getURIResolver()
Return the URIResolver that was set with setURIResolver. the object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include.

newTemplates

public Templates newTemplates(Source source)
Process the Source into a Templates object, which is a a compiled representation of the source.

newTemplatesHandler

public TemplatesHandler newTemplatesHandler()
Get a TemplatesHandler object that can process SAX ContentHandler events into a Templates object.

Returns: A non-null reference to a TemplatesHandler, that may be used as a ContentHandler for SAX parse events.

Throws: TransformerConfigurationException - If for some reason the TemplatesHandler cannot be created.

newTransformer

public Transformer newTransformer(Source source)
Process the Source into a Transformer object.

newTransformer

public Transformer newTransformer()
Create a new Transformer object that performs a copy of the source to the result.

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.

newTransformerHandler

public TransformerHandler newTransformerHandler()

newTransformerHandler

public TransformerHandler newTransformerHandler(Source source)

newTransformerHandler

public TransformerHandler newTransformerHandler(Templates templates)

newXMLFilter

public XMLFilter newXMLFilter(Source source)

newXMLFilter

public XMLFilter newXMLFilter(Templates templates)

setAttribute

public void setAttribute(String name, Object value)
Throws an IllegalArgumentException since attributes are not supported.

setErrorListener

public void setErrorListener(ErrorListener listener)
Set the error event listener for the TransformerFactory, which is used for the processing of transformation instructions,

setFeature

public void setFeature(String name, boolean value)

setURIResolver

public void setURIResolver(URIResolver uriResolver)
Set the URIResolver.