org.apache.xalan.xsltc.trax

Class SmartTransformerFactoryImpl


public class SmartTransformerFactoryImpl
extends SAXTransformerFactory

Implementation of a transformer factory that uses an XSLTC transformer factory for the creation of Templates objects and uses the Xalan processor transformer factory for the creation of Transformer objects.

Author:
G. Todd Miller

Field Summary

Fields inherited from class javax.xml.transform.sax.SAXTransformerFactory

FEATURE, FEATURE_XMLFILTER

Constructor Summary

SmartTransformerFactoryImpl()
implementation of the SmartTransformerFactory.

Method Summary

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.
Object
getAttribute(String name)
Allows the user to retrieve specific attributes on the underlying implementation.
ErrorListener
getErrorListener()
Get the error event handler for the TransformerFactory.
boolean
getFeature(String name)
javax.xml.transform.sax.TransformerFactory implementation.
URIResolver
getURIResolver()
Get the object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include.
Templates
newTemplates(Source source)
Create a Templates object that from the input stylesheet Uses the org.apache.xalan.xsltc.trax.TransformerFactory.
TemplatesHandler
newTemplatesHandler()
Get a TemplatesHandler object that can process SAX ContentHandler events into a Templates object.
Transformer
newTransformer()
Create a Transformer object that copies the input document to the result.
Transformer
newTransformer(Source source)
Create a Transformer object that from the input stylesheet Uses the org.apache.xalan.processor.TransformerFactory.
TransformerHandler
newTransformerHandler()
Get a TransformerHandler object that can process SAX ContentHandler events based on a copy transformer.
TransformerHandler
newTransformerHandler(Source src)
Get a TransformerHandler object that can process SAX ContentHandler events based on a transformer specified by the stylesheet Source.
TransformerHandler
newTransformerHandler(Templates templates)
Get a TransformerHandler object that can process SAX ContentHandler events based on a transformer specified by the stylesheet Source.
XMLFilter
newXMLFilter(Source src)
Create an XMLFilter that uses the given source as the transformation instructions.
XMLFilter
newXMLFilter(Templates templates)
Create an XMLFilter, based on the Templates argument..
void
setAttribute(String name, Object value)
Allows the user to set specific attributes on the underlying implementation.
void
setErrorListener(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.
void
setURIResolver(URIResolver resolver)
Set an object that is used by default during the transformation to resolve URIs used in xsl:import, or xsl:include.

Methods inherited from class javax.xml.transform.sax.SAXTransformerFactory

newTemplatesHandler, newTransformerHandler, newTransformerHandler, newTransformerHandler, newXMLFilter, newXMLFilter

Methods inherited from class javax.xml.transform.TransformerFactory

getAssociatedStylesheet, getAttribute, getErrorListener, getFeature, getURIResolver, newInstance, newTemplates, newTransformer, newTransformer, setAttribute, setErrorListener, setURIResolver

Constructor Details

SmartTransformerFactoryImpl

public SmartTransformerFactoryImpl()
implementation of the SmartTransformerFactory. This factory uses org.apache.xalan.xsltc.trax.TransformerFactory to return Templates objects; and uses org.apache.xalan.processor.TransformerFactory to return Transformer objects.

Method Details

getAssociatedStylesheet

public Source getAssociatedStylesheet(Source source,
                                      String media,
                                      String title,
                                      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 in a single stylesheet.
Overrides:
getAssociatedStylesheet in interface TransformerFactory

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
Allows the user to retrieve specific attributes on the underlying implementation.
Overrides:
getAttribute in interface TransformerFactory

Parameters:
name - The name of the attribute.

Returns:
value The value of the attribute.


getErrorListener

public ErrorListener getErrorListener()
Get the error event handler for the TransformerFactory.
Overrides:
getErrorListener in interface TransformerFactory

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


getFeature

public boolean getFeature(String name)
javax.xml.transform.sax.TransformerFactory implementation. Look up the value of a feature (to see if it is supported). This method must be updated as the various methods and features of this class are implemented.
Overrides:
getFeature in interface TransformerFactory

Parameters:
name - The feature name

Returns:
'true' if feature is supported, 'false' if not


getURIResolver

public URIResolver getURIResolver()
Get the object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include.
Overrides:
getURIResolver in interface TransformerFactory

Returns:
The URIResolver that was set with setURIResolver.


newTemplates

public Templates newTemplates(Source source)
            throws TransformerConfigurationException
Create a Templates object that from the input stylesheet Uses the org.apache.xalan.xsltc.trax.TransformerFactory.
Overrides:
newTemplates in interface TransformerFactory

Parameters:
source - the stylesheet.

Returns:
A Templates object.


newTemplatesHandler

public TemplatesHandler newTemplatesHandler()
            throws TransformerConfigurationException
Get a TemplatesHandler object that can process SAX ContentHandler events into a Templates object. Uses the org.apache.xalan.xsltc.trax.TransformerFactory.
Overrides:
newTemplatesHandler in interface SAXTransformerFactory


newTransformer

public Transformer newTransformer()
            throws TransformerConfigurationException
Create a Transformer object that copies the input document to the result. Uses the org.apache.xalan.processor.TransformerFactory.
Overrides:
newTransformer in interface TransformerFactory

Returns:
A Transformer object.


newTransformer

public Transformer newTransformer(Source source)
            throws TransformerConfigurationException
Create a Transformer object that from the input stylesheet Uses the org.apache.xalan.processor.TransformerFactory.
Overrides:
newTransformer in interface TransformerFactory

Parameters:
source - the stylesheet.

Returns:
A Transformer object.


newTransformerHandler

public TransformerHandler newTransformerHandler()
            throws TransformerConfigurationException
Get a TransformerHandler object that can process SAX ContentHandler events based on a copy transformer. Uses org.apache.xalan.processor.TransformerFactory.
Overrides:
newTransformerHandler in interface SAXTransformerFactory


newTransformerHandler

public TransformerHandler newTransformerHandler(Source src)
            throws TransformerConfigurationException
Get a TransformerHandler object that can process SAX ContentHandler events based on a transformer specified by the stylesheet Source. Uses org.apache.xalan.processor.TransformerFactory.
Overrides:
newTransformerHandler in interface SAXTransformerFactory


newTransformerHandler

public TransformerHandler newTransformerHandler(Templates templates)
            throws TransformerConfigurationException
Get a TransformerHandler object that can process SAX ContentHandler events based on a transformer specified by the stylesheet Source. Uses org.apache.xalan.xsltc.trax.TransformerFactory.
Overrides:
newTransformerHandler in interface SAXTransformerFactory


newXMLFilter

public XMLFilter newXMLFilter(Source src)
            throws TransformerConfigurationException
Create an XMLFilter that uses the given source as the transformation instructions. Uses org.apache.xalan.xsltc.trax.TransformerFactory.
Overrides:
newXMLFilter in interface SAXTransformerFactory


newXMLFilter

public XMLFilter newXMLFilter(Templates templates)
            throws TransformerConfigurationException
Create an XMLFilter, based on the Templates argument..
Overrides:
newXMLFilter in interface SAXTransformerFactory

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.


setAttribute

public void setAttribute(String name,
                         Object value)
            throws IllegalArgumentException
Allows the user to set specific attributes on the underlying implementation. An attribute in this context is defined to be an option that the implementation provides.
Overrides:
setAttribute in interface TransformerFactory

Parameters:
name - The name of the attribute.
value - The value of the attribute.


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, and not for the transformation itself.
Overrides:
setErrorListener in interface TransformerFactory

Parameters:
listener - The new error listener.


setURIResolver

public void setURIResolver(URIResolver resolver)
Set an object that is used by default during the transformation to resolve URIs used in xsl:import, or xsl:include.
Overrides:
setURIResolver in interface TransformerFactory

Parameters:
resolver - An object that implements the URIResolver interface, or null.


Copyright B) 2004 Apache XML Project. All Rights Reserved.