public class XSLTProcessorImpl extends org.apache.avalon.framework.logger.AbstractLogEnabled implements XSLTProcessor, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.parameters.Parameterizable, org.apache.avalon.excalibur.pool.Recyclable, javax.xml.transform.URIResolver, org.apache.avalon.framework.component.Component
XSLTProcessor
component.
The <use-store> configuration forces the transformer to put the
Templates generated from the XSLT stylesheet into the
Store. This property is false by default.
The <transformer-factory> configuration tells the transformer to use a particular
implementation of javax.xml.transform.TransformerFactory. This allows to force
the use of a given TRAX implementation (e.g. xalan or saxon) if several are available in the
classpath. If this property is not set, the transformer uses the standard TRAX mechanism
(TransformerFactory.newInstance()).
XSLTProcessor.TransformerHandlerAndValidity| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_checkIncludes
Check included stylesheets
|
protected javax.xml.transform.sax.SAXTransformerFactory |
m_defaultFactory
The default TransformerFactory used by this component
|
protected TraxErrorHandler |
m_errorHandler
The error handler for the transformer
|
protected javax.xml.transform.sax.SAXTransformerFactory |
m_factory
The trax TransformerFactory this component uses
|
private java.lang.String |
m_id
Hold the System ID of the main/base stylesheet
|
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 org.apache.avalon.framework.service.ServiceManager |
m_manager
The ServiceManager
|
protected org.apache.excalibur.source.SourceResolver |
m_resolver
Resolver used to resolve XSLT document() calls, imports and includes
|
protected org.apache.excalibur.store.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 |
ROLE| Constructor and Description |
|---|
XSLTProcessorImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Disposable
|
private static org.xml.sax.InputSource |
getInputSource(org.apache.excalibur.source.Source source)
Return a new
InputSource object that uses
the InputStream and the system ID of the
Source object. |
private XSLTProcessor.TransformerHandlerAndValidity |
getTemplates(org.apache.excalibur.source.Source stylesheet,
java.lang.String id) |
private javax.xml.transform.sax.SAXTransformerFactory |
getTransformerFactory(java.lang.String factoryName)
Get the TransformerFactory associated with the given classname.
|
javax.xml.transform.sax.TransformerHandler |
getTransformerHandler(org.apache.excalibur.source.Source stylesheet)
|
javax.xml.transform.sax.TransformerHandler |
getTransformerHandler(org.apache.excalibur.source.Source stylesheet,
org.xml.sax.XMLFilter filter)
Return a
TransformerHandler for a given
stylesheet Source. |
XSLTProcessor.TransformerHandlerAndValidity |
getTransformerHandlerAndValidity(org.apache.excalibur.source.Source stylesheet)
|
XSLTProcessor.TransformerHandlerAndValidity |
getTransformerHandlerAndValidity(org.apache.excalibur.source.Source stylesheet,
org.xml.sax.XMLFilter filter)
Return a
TransformerHandler and
SourceValidity for a given stylesheet
Source. |
void |
initialize()
Initialize
|
void |
parameterize(org.apache.avalon.framework.parameters.Parameters params)
Configure the component
|
private void |
putTemplates(javax.xml.transform.Templates templates,
org.apache.excalibur.source.Source stylesheet,
java.lang.String id) |
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(org.apache.avalon.framework.service.ServiceManager manager)
Compose.
|
void |
setTransformerFactory(java.lang.String classname)
Set the transformer factory used by this component
|
private void |
sourceToSAX(org.apache.excalibur.source.Source source,
org.xml.sax.ContentHandler handler) |
void |
transform(org.apache.excalibur.source.Source source,
org.apache.excalibur.source.Source stylesheet,
org.apache.avalon.framework.parameters.Parameters params,
javax.xml.transform.Result result)
Applies an XSLT stylesheet to an XML document.
|
protected org.apache.excalibur.store.Store m_store
protected java.lang.String m_transformerFactory
protected javax.xml.transform.sax.SAXTransformerFactory m_factory
protected javax.xml.transform.sax.SAXTransformerFactory m_defaultFactory
protected boolean m_useStore
protected boolean m_incrementalProcessing
protected org.apache.excalibur.source.SourceResolver m_resolver
protected TraxErrorHandler m_errorHandler
protected boolean m_checkIncludes
protected java.util.Map m_includesMap
protected XMLizer m_xmlizer
protected org.apache.avalon.framework.service.ServiceManager m_manager
private java.lang.String m_id
public void service(org.apache.avalon.framework.service.ServiceManager manager)
throws org.apache.avalon.framework.service.ServiceException
service in interface org.apache.avalon.framework.service.Serviceableorg.apache.avalon.framework.service.ServiceExceptionpublic void initialize()
throws java.lang.Exception
initialize in interface org.apache.avalon.framework.activity.Initializablejava.lang.Exceptionpublic void dispose()
dispose in interface org.apache.avalon.framework.activity.Disposablepublic void parameterize(org.apache.avalon.framework.parameters.Parameters params)
throws org.apache.avalon.framework.parameters.ParameterException
parameterize in interface org.apache.avalon.framework.parameters.Parameterizableorg.apache.avalon.framework.parameters.ParameterExceptionpublic void setTransformerFactory(java.lang.String classname)
setTransformerFactory in interface XSLTProcessorclassname - 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.public javax.xml.transform.sax.TransformerHandler getTransformerHandler(org.apache.excalibur.source.Source stylesheet)
throws XSLTProcessorException
XSLTProcessorgetTransformerHandler in interface XSLTProcessorstylesheet - a Source valueTransformerHandler valueXSLTProcessorException - if an error occursXSLTProcessor.getTransformerHandler(org.apache.excalibur.source.Source)public javax.xml.transform.sax.TransformerHandler getTransformerHandler(org.apache.excalibur.source.Source stylesheet,
org.xml.sax.XMLFilter filter)
throws XSLTProcessorException
XSLTProcessorReturn 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.
getTransformerHandler in interface XSLTProcessorstylesheet - a Source valuefilter - a XMLFilter valueTransformerHandler valueXSLTProcessorException - if an error occursXSLTProcessor.getTransformerHandler(org.apache.excalibur.source.Source, org.xml.sax.XMLFilter)public XSLTProcessor.TransformerHandlerAndValidity getTransformerHandlerAndValidity(org.apache.excalibur.source.Source stylesheet) throws XSLTProcessorException
XSLTProcessorgetTransformerHandlerAndValidity in interface XSLTProcessorstylesheet - a Source valueXSLTProcessor.TransformerHandlerAndValidity valueXSLTProcessorException - if an error occurspublic XSLTProcessor.TransformerHandlerAndValidity getTransformerHandlerAndValidity(org.apache.excalibur.source.Source stylesheet, org.xml.sax.XMLFilter filter) throws XSLTProcessorException
XSLTProcessorReturn 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.
getTransformerHandlerAndValidity in interface XSLTProcessorstylesheet - a Source valuefilter - a XMLFilter valueTransformerHandlerAndValidity valueXSLTProcessorException - if an error occursprivate void sourceToSAX(org.apache.excalibur.source.Source source,
org.xml.sax.ContentHandler handler)
throws org.xml.sax.SAXException,
java.io.IOException,
org.apache.excalibur.source.SourceException
org.xml.sax.SAXExceptionjava.io.IOExceptionorg.apache.excalibur.source.SourceExceptionpublic void transform(org.apache.excalibur.source.Source source,
org.apache.excalibur.source.Source stylesheet,
org.apache.avalon.framework.parameters.Parameters params,
javax.xml.transform.Result result)
throws XSLTProcessorException
XSLTProcessorSource
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.transform in interface XSLTProcessorsource - a Source valuestylesheet - a Source valueparams - a Parameters valueresult - a Result valueXSLTProcessorException - if an error occursprivate javax.xml.transform.sax.SAXTransformerFactory getTransformerFactory(java.lang.String factoryName)
private XSLTProcessor.TransformerHandlerAndValidity getTemplates(org.apache.excalibur.source.Source stylesheet, java.lang.String id) throws java.io.IOException, org.apache.excalibur.source.SourceException, javax.xml.transform.TransformerException
java.io.IOExceptionorg.apache.excalibur.source.SourceExceptionjavax.xml.transform.TransformerExceptionprivate void putTemplates(javax.xml.transform.Templates templates,
org.apache.excalibur.source.Source stylesheet,
java.lang.String id)
throws java.io.IOException
java.io.IOExceptionpublic javax.xml.transform.Source resolve(java.lang.String href,
java.lang.String base)
throws javax.xml.transform.TransformerException
resolve in interface javax.xml.transform.URIResolverhref - An href attribute, which may be relative or absolute.base - The base URI in effect when the href attribute
was encountered.javax.xml.transform.TransformerException - if an error occurs when trying to
resolve the URI.private static org.xml.sax.InputSource getInputSource(org.apache.excalibur.source.Source source)
throws java.io.IOException,
org.apache.excalibur.source.SourceException
InputSource object that uses
the InputStream and the system ID of the
Source object.java.io.IOException - if I/O error occured.org.apache.excalibur.source.SourceExceptionpublic void recycle()
recycle in interface org.apache.avalon.excalibur.pool.Recyclable