com.jclark.xsl.trax

Class TransformerFactoryImpl


public class TransformerFactoryImpl
extends SAXTransformerFactory

An implementation of the TrAX TransformerFactory class and SAXTransformerFactory classes. The following code fragment illustrates how to invoke jd.xslt from TrAX:
   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

Source
getAssociatedStylesheet(Source source, java.lang.String media, java.lang.String title, java.lang.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.
Object
getAttribute(String name)
Throws an IllegalArgumentException since attributes are not supported.
ErrorListener
getErrorListener()
Get the error event handler for the TransformerFactory.
boolean
getFeature(String name)
Look up the value of a feature.
XMLReader
getReader(Source source)
URIResolver
getURIResolver()
Return the URIResolver that was set with setURIResolver.
Templates
newTemplates(Source source)
Process the Source into a Templates object, which is a a compiled representation of the source.
TemplatesHandler
newTemplatesHandler()
Get a TemplatesHandler object that can process SAX ContentHandler events into a Templates object.
Transformer
newTransformer()
Create a new Transformer object that performs a copy of the source to the result.
Transformer
newTransformer(Source source)
Process the Source into a Transformer object.
TransformerHandler
newTransformerHandler()
TransformerHandler
newTransformerHandler(Source source)
TransformerHandler
newTransformerHandler(Templates templates)
XMLFilter
newXMLFilter(Source source)
Return null since XMLFilters are not yet supported.
XMLFilter
newXMLFilter(Templates templates)
Return null since XMLFilters are not yet supported.
void
setAttribute(String name, Object value)
Throws an IllegalArgumentException since attributes are not supported.
void
setErrorListener(ErrorListener listener)
Set the error event listener for the TransformerFactory, which is used for the processing of transformation instructions,
void
setFeature(String name, boolean value)
void
setURIResolver(URIResolver uriResolver)
Set the URIResolver.

Method Details

getAssociatedStylesheet

public Source getAssociatedStylesheet(Source source,
                                      java.lang.String media,
                                      java.lang.String title,
                                      java.lang.String charset)
            throws TransformerConfigurationException
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.

getAttribute

public Object getAttribute(String name)
            throws IllegalArgumentException
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)
            throws Exception

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)
            throws TransformerConfigurationException
Process the Source into a Templates object, which is a a compiled representation of the source.

newTemplatesHandler

public TemplatesHandler newTemplatesHandler()
            throws TransformerConfigurationException
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.

newTransformer

public Transformer newTransformer()
            throws TransformerConfigurationException
Create a new Transformer object that performs a copy of the source to the result.
Parameters:
Returns:
A Transformer object that may be used to perform a transformation in a single thread, never null.

newTransformer

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

newTransformerHandler

public TransformerHandler newTransformerHandler()
            throws TransformerConfigurationException

newTransformerHandler

public TransformerHandler newTransformerHandler(Source source)
            throws TransformerConfigurationException

newTransformerHandler

public TransformerHandler newTransformerHandler(Templates templates)
            throws TransformerConfigurationException

newXMLFilter

public XMLFilter newXMLFilter(Source source)
Return null since XMLFilters are not yet supported.

newXMLFilter

public XMLFilter newXMLFilter(Templates templates)
Return null since XMLFilters are not yet supported.

setAttribute

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

setErrorListener

public void setErrorListener(ErrorListener listener)
            throws IllegalArgumentException
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)
            throws TransformerConfigurationException

setURIResolver

public void setURIResolver(URIResolver uriResolver)
Set the URIResolver.