jd.xml.xslt.trax
Class TransformerFactoryImpl

java.lang.Object
  extended byjavax.xml.transform.TransformerFactory
      extended byjavax.xml.transform.sax.SAXTransformerFactory
          extended byjd.xml.xslt.trax.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(...);
 


Field Summary
 
Fields inherited from class javax.xml.transform.sax.SAXTransformerFactory
FEATURE, FEATURE_XMLFILTER
 
Constructor Summary
TransformerFactoryImpl()
           
 
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)
          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.
 URIResolver getURIResolver()
          Return the URIResolver that was set with setURIResolver or the default resolver if no URIResolver was set.
 Templates newTemplates(Source source)
          Process the Source into a Templates object, which is a a compiled representation of the source.
 Templates newTemplates(XmlSource 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()
          Get a TransformerHandler object that can process SAX ContentHandler events into a Result.
 TransformerHandler newTransformerHandler(Source source)
          Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.
 TransformerHandler newTransformerHandler(Templates templates)
          Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the Templates argument.
 XMLFilter newXMLFilter(Source source)
          Return null since XMLFilters are not supported.
 XMLFilter newXMLFilter(Templates templates)
          Return null since XMLFilters are not 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 setURIResolver(URIResolver traxUriResolver)
          Set the URIResolver.
 
Methods inherited from class javax.xml.transform.TransformerFactory
newInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformerFactoryImpl

public TransformerFactoryImpl()
Method Detail

newTransformer

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

Parameters:
source - An object that holds a URI, input stream, etc.
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.

newTransformer

public Transformer newTransformer()
                           throws TransformerConfigurationException
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.

newTemplates

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

Parameters:
source - An object that holds a URL, input stream, etc.
Returns:
A Templates object capable of being used for transformation purposes, never null.
Throws:
TransformerConfigurationException - May throw this during the parse when it is constructing the Templates object and fails.

newTemplates

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

Throws:
TransformerConfigurationException

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.

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.
TransformerConfigurationException

setURIResolver

public void setURIResolver(URIResolver traxUriResolver)
Set the URIResolver.

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

getURIResolver

public URIResolver getURIResolver()
Return the URIResolver that was set with setURIResolver or the default resolver if no URIResolver was set.

Returns:
The URIResolver that was set with setURIResolver.

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).

setAttribute

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

Parameters:
name - The name of the attribute.
value - The value of the attribute.
Throws:
IllegalArgumentException - thrown if the underlying implementation doesn't recognize the attribute.

getAttribute

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

Parameters:
name - The name of the attribute.
Returns:
value The value of the attribute.
Throws:
IllegalArgumentException - thrown if the underlying implementation doesn't recognize 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,

Parameters:
listener - The new error listener.
Throws:
IllegalArgumentException - if listener is null.

getErrorListener

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

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

newTemplatesHandler

public TemplatesHandler newTemplatesHandler()
Description copied from class: SAXTransformerFactory
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.

newTransformerHandler

public TransformerHandler newTransformerHandler()
                                         throws TransformerConfigurationException
Description copied from class: SAXTransformerFactory
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.

newTransformerHandler

public TransformerHandler newTransformerHandler(Source source)
                                         throws TransformerConfigurationException
Description copied from class: SAXTransformerFactory
Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.

Parameters:
source - 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 TransformerHandler newTransformerHandler(Templates templates)
                                         throws TransformerConfigurationException
Description copied from class: SAXTransformerFactory
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.

newXMLFilter

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

Parameters:
source - The Source of the transformation instructions.
Returns:
An XMLFilter object, or null if this feature is not supported.

newXMLFilter

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

Parameters:
templates - The compiled transformation instructions.
Returns:
An XMLFilter object, or null if this feature is not supported.