org.apache.excalibur.xml.xslt
Class XSLTProcessorImpl

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.excalibur.xml.xslt.XSLTProcessorImpl
All Implemented Interfaces:
Component, Disposable, Initializable, LogEnabled, Parameterizable, Poolable, Recyclable, Serviceable, javax.xml.transform.URIResolver, XSLTProcessor

public class XSLTProcessorImpl
extends AbstractLogEnabled
implements XSLTProcessor, Serviceable, Initializable, Disposable, Parameterizable, Recyclable, javax.xml.transform.URIResolver

Author:
CZiegeler To change the template for this generated type comment go to Window - Preferences - Java - Code Generation - Code and Comments

Nested Class Summary
 
Nested classes inherited from class org.apache.excalibur.xml.xslt.XSLTProcessor
XSLTProcessor.TransformerHandlerAndValidity
 
Field Summary
protected  boolean m_checkIncludes
          Check included stylesheets
protected  javax.xml.transform.sax.SAXTransformerFactory m_defaultFactory
          The default TransformerFactory used by this component
protected  org.apache.excalibur.xml.xslt.TraxErrorHandler m_errorHandler
          The error handler for the transformer
protected  javax.xml.transform.sax.SAXTransformerFactory m_factory
          The trax TransformerFactory this component uses
protected  java.util.Map m_includesMap
          Map of pairs of System ID's / validities of the included stylesheets
protected  boolean m_incrementalProcessing
          Is incremental processing turned on? (default for Xalan: no)
protected  ServiceManager m_manager
          The ServiceManager
protected  SourceResolver m_resolver
          Resolver used to resolve XSLT document() calls, imports and includes
protected  Store m_store
          The store service instance
protected  java.lang.String m_transformerFactory
          The configured transformer factory to use
protected  boolean m_useStore
          Is the store turned on? (default is off)
protected  XMLizer m_xmlizer
           
 
Fields inherited from interface org.apache.excalibur.xml.xslt.XSLTProcessor
ROLE
 
Constructor Summary
XSLTProcessorImpl()
           
 
Method Summary
 void dispose()
          Disposable
 javax.xml.transform.sax.TransformerHandler getTransformerHandler(Source stylesheet)
          Same as getTransformerHandler(Source,XMLFilter), with filter set to null.
 javax.xml.transform.sax.TransformerHandler getTransformerHandler(Source stylesheet, org.xml.sax.XMLFilter filter)
          Return a TransformerHandler for a given stylesheet Source.
 XSLTProcessor.TransformerHandlerAndValidity getTransformerHandlerAndValidity(Source stylesheet)
          Same as getTransformerHandlerAndValidity(Source,XMLFilter), with filter set to null.
 XSLTProcessor.TransformerHandlerAndValidity getTransformerHandlerAndValidity(Source stylesheet, org.xml.sax.XMLFilter filter)
          Return a TransformerHandler and SourceValidity for a given stylesheet Source.
 void initialize()
          Initialize
 void parameterize(Parameters params)
          Configure the component
 void recycle()
          Recycle the component
 javax.xml.transform.Source resolve(java.lang.String href, java.lang.String base)
          Called by the processor when it encounters an xsl:include, xsl:import, or document() function.
 void service(ServiceManager manager)
          Compose.
 void setTransformerFactory(java.lang.String classname)
          Set the transformer factory used by this component
 void transform(Source source, Source stylesheet, Parameters params, javax.xml.transform.Result result)
          Applies an XSLT stylesheet to an XML document.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_store

protected Store m_store
The store service instance


m_transformerFactory

protected java.lang.String m_transformerFactory
The configured transformer factory to use


m_factory

protected javax.xml.transform.sax.SAXTransformerFactory m_factory
The trax TransformerFactory this component uses


m_defaultFactory

protected javax.xml.transform.sax.SAXTransformerFactory m_defaultFactory
The default TransformerFactory used by this component


m_useStore

protected boolean m_useStore
Is the store turned on? (default is off)


m_incrementalProcessing

protected boolean m_incrementalProcessing
Is incremental processing turned on? (default for Xalan: no)


m_resolver

protected SourceResolver m_resolver
Resolver used to resolve XSLT document() calls, imports and includes


m_errorHandler

protected org.apache.excalibur.xml.xslt.TraxErrorHandler m_errorHandler
The error handler for the transformer


m_checkIncludes

protected boolean m_checkIncludes
Check included stylesheets


m_includesMap

protected java.util.Map m_includesMap
Map of pairs of System ID's / validities of the included stylesheets


m_xmlizer

protected XMLizer m_xmlizer

m_manager

protected ServiceManager m_manager
The ServiceManager

Constructor Detail

XSLTProcessorImpl

public XSLTProcessorImpl()
Method Detail

service

public void service(ServiceManager manager)
             throws ServiceException
Compose. Try to get the store

Specified by:
service in interface Serviceable
Parameters:
manager - The ServiceManager which this Serviceable uses. Must not be null.
Throws:
ServiceException - if an error occurs

initialize

public void initialize()
                throws java.lang.Exception
Initialize

Specified by:
initialize in interface Initializable
Throws:
java.lang.Exception - if an error occurs

dispose

public void dispose()
Disposable

Specified by:
dispose in interface Disposable

parameterize

public void parameterize(Parameters params)
                  throws ParameterException
Configure the component

Specified by:
parameterize in interface Parameterizable
Parameters:
params - the parameters. Must not be null.
Throws:
ParameterException - if parameters are invalid

setTransformerFactory

public void setTransformerFactory(java.lang.String classname)
Set the transformer factory used by this component

Specified by:
setTransformerFactory in interface XSLTProcessor
Parameters:
classname - the name of the class implementing TransformerFactory value. If an error is found or the indicated class doesn't implement the required interface the original factory of the component is maintained.

getTransformerHandler

public javax.xml.transform.sax.TransformerHandler getTransformerHandler(Source stylesheet)
                                                                 throws XSLTProcessorException
Description copied from interface: XSLTProcessor
Same as XSLTProcessor.getTransformerHandler(Source,XMLFilter), with filter set to null.

Specified by:
getTransformerHandler in interface XSLTProcessor
Parameters:
stylesheet - a Source value
Returns:
a TransformerHandler value
Throws:
XSLTProcessorException - if an error occurs
See Also:
XSLTProcessor.getTransformerHandler(org.apache.excalibur.source.Source)

getTransformerHandler

public javax.xml.transform.sax.TransformerHandler getTransformerHandler(Source stylesheet,
                                                                        org.xml.sax.XMLFilter filter)
                                                                 throws XSLTProcessorException
Description copied from interface: XSLTProcessor

Return a TransformerHandler for a given stylesheet Source. This can be used in a pipeline to handle the transformation of a stream of SAX events. See org.apache.cocoon.transformation.TraxTransformer#setConsumer for an example of how to use this method.

The additional filter argument, if it's not null, is inserted in the chain SAX events as an XML filter during the parsing or the source document.

This method caches the Templates object with meta information (modification time and list of included stylesheets) and performs a reparsing only if this changes.

Specified by:
getTransformerHandler in interface XSLTProcessor
Parameters:
stylesheet - a Source value
filter - a XMLFilter value
Returns:
a TransformerHandler value
Throws:
XSLTProcessorException - if an error occurs
See Also:
XSLTProcessor.getTransformerHandler(org.apache.excalibur.source.Source, org.xml.sax.XMLFilter)

getTransformerHandlerAndValidity

public XSLTProcessor.TransformerHandlerAndValidity getTransformerHandlerAndValidity(Source stylesheet)
                                                                             throws XSLTProcessorException
Description copied from interface: XSLTProcessor
Same as XSLTProcessor.getTransformerHandlerAndValidity(Source,XMLFilter), with filter set to null.

Specified by:
getTransformerHandlerAndValidity in interface XSLTProcessor
Parameters:
stylesheet - a Source value
Returns:
a XSLTProcessor.TransformerHandlerAndValidity value
Throws:
XSLTProcessorException - if an error occurs

getTransformerHandlerAndValidity

public XSLTProcessor.TransformerHandlerAndValidity getTransformerHandlerAndValidity(Source stylesheet,
                                                                                    org.xml.sax.XMLFilter filter)
                                                                             throws XSLTProcessorException
Description copied from interface: XSLTProcessor

Return a TransformerHandler and SourceValidity for a given stylesheet Source. This can be used in a pipeline to handle the transformation of a stream of SAX events. See org.apache.cocoon.transformation.TraxTransformer#setConsumer for an example of how to use this method.

The additional filter argument, if it's not null, is inserted in the chain SAX events as an XML filter during the parsing or the source document.

This method caches the Templates object with meta information (modification time and list of included stylesheets) and performs a reparsing only if this changes.

Specified by:
getTransformerHandlerAndValidity in interface XSLTProcessor
Parameters:
stylesheet - a Source value
filter - a XMLFilter value
Returns:
a TransformerHandlerAndValidity value
Throws:
XSLTProcessorException - if an error occurs

transform

public void transform(Source source,
                      Source stylesheet,
                      Parameters params,
                      javax.xml.transform.Result result)
               throws XSLTProcessorException
Description copied from interface: XSLTProcessor
Applies an XSLT stylesheet to an XML document. The source and stylesheet documents are specified as Source objects. The result of the transformation is placed in Result, which should be properly initialized before invoking this method. Any additional parameters passed in params will become arguments to the stylesheet.

Specified by:
transform in interface XSLTProcessor
Parameters:
source - a Source value
stylesheet - a Source value
params - a Parameters value
result - a Result value
Throws:
XSLTProcessorException - if an error occurs

resolve

public javax.xml.transform.Source resolve(java.lang.String href,
                                          java.lang.String base)
                                   throws javax.xml.transform.TransformerException
Called by the processor when it encounters an xsl:include, xsl:import, or document() function.

Specified by:
resolve in interface javax.xml.transform.URIResolver
Parameters:
href - An href attribute, which may be relative or absolute.
base - The base URI in effect when the href attribute was encountered.
Returns:
A Source object, or null if the href cannot be resolved, and the processor should try to resolve the URI itself.
Throws:
javax.xml.transform.TransformerException - if an error occurs when trying to resolve the URI.

recycle

public void recycle()
Recycle the component

Specified by:
recycle in interface Recyclable


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.