org.apache.cocoon.components.xslt
Class XSLTProcessorImpl
java.lang.Object
|
+--org.apache.avalon.framework.logger.AbstractLoggable
|
+--org.apache.cocoon.components.xslt.XSLTProcessorImpl
- All Implemented Interfaces:
- org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.logger.Loggable, javax.xml.transform.URIResolver, XSLTProcessor
- public class XSLTProcessorImpl
- extends org.apache.avalon.framework.logger.AbstractLoggable
- implements XSLTProcessor, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.configuration.Configurable, javax.xml.transform.URIResolver, org.apache.avalon.framework.component.Component
This class defines the implementation of the XSLTProcessor
component.
To configure it, add the following lines in the
cocoon.xconf file:
<xslt-processor class="org.apache.cocoon.components.xslt.XSLTProcessorImpl">
<parameter name="use-store" value="true"/>
<parameter name="transformer-factory" value="org.apache.xalan.processor.TransformerFactoryImpl"/>
</xslt-processor>
The <use-store> configuration forces the transformer to put the
Templates
generated from the XSLT stylesheet into the
Store
. This property is true 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()
).
- Since:
- July 11, 2001
- Version:
- 1.0
- Author:
- Ovidiu Predescu
Method Summary |
void |
compose(org.apache.avalon.framework.component.ComponentManager manager)
|
void |
configure(org.apache.avalon.framework.configuration.Configuration conf)
|
void |
dispose()
|
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 . |
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 |
setSourceResolver(SourceResolver resolver)
Set the SourceResolver for
this instance. |
void |
transform(Source source,
Source stylesheet,
org.apache.avalon.framework.parameters.Parameters params,
javax.xml.transform.Result result)
Applies an XSLT stylesheet to an XML document. |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable |
getLogger, setLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
manager
protected org.apache.avalon.framework.component.ComponentManager manager
entityResolver
protected Resolver entityResolver
- the Entity Resolver
XSLTProcessorImpl
public XSLTProcessorImpl()
compose
public void compose(org.apache.avalon.framework.component.ComponentManager manager)
throws org.apache.avalon.framework.component.ComponentException
- Specified by:
compose
in interface org.apache.avalon.framework.component.Composable
dispose
public void dispose()
- Specified by:
dispose
in interface org.apache.avalon.framework.activity.Disposable
configure
public void configure(org.apache.avalon.framework.configuration.Configuration conf)
throws org.apache.avalon.framework.configuration.ConfigurationException
- Specified by:
configure
in interface org.apache.avalon.framework.configuration.Configurable
getTransformerHandler
public javax.xml.transform.sax.TransformerHandler getTransformerHandler(Source stylesheet)
throws ProcessingException
- Description copied from interface:
XSLTProcessor
- Same as
XSLTProcessor.getTransformerHandler(Source,XMLFilter)
, with
filter
set to null
.
- Specified by:
getTransformerHandler
in interface XSLTProcessor
- Following copied from interface:
org.apache.cocoon.components.xslt.XSLTProcessor
- Parameters:
stylesheet
- a Source
value- Returns:
- a
TransformerHandler
value - Throws:
ProcessingException
- if an error occurs- See Also:
TraxTransformer.setConsumer(org.apache.cocoon.xml.XMLConsumer)
getTransformerHandler
public javax.xml.transform.sax.TransformerHandler getTransformerHandler(Source stylesheet,
org.xml.sax.XMLFilter filter)
throws ProcessingException
- 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 TraxTransformer.setConsumer(org.apache.cocoon.xml.XMLConsumer)
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 Source object and performs a reparsing
only if this changes.
- Specified by:
getTransformerHandler
in interface XSLTProcessor
- Following copied from interface:
org.apache.cocoon.components.xslt.XSLTProcessor
- Parameters:
stylesheet
- a Source
valuefilter
- a XMLFilter
value- Returns:
- a
TransformerHandler
value - Throws:
ProcessingException
- if an error occurs
transform
public void transform(Source source,
Source stylesheet,
org.apache.avalon.framework.parameters.Parameters params,
javax.xml.transform.Result result)
throws ProcessingException
- 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
- Following copied from interface:
org.apache.cocoon.components.xslt.XSLTProcessor
- Parameters:
source
- a Source
valuestylesheet
- a Source
valueparams
- a Parameters
valueresult
- a Result
value- Throws:
ProcessingException
- 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.
setSourceResolver
public void setSourceResolver(SourceResolver resolver)
- Description copied from interface:
XSLTProcessor
- Set the
SourceResolver
for
this instance. The resolver
is invoked to return a
Source
object, given an HREF.
- Specified by:
setSourceResolver
in interface XSLTProcessor
- Following copied from interface:
org.apache.cocoon.components.xslt.XSLTProcessor
- Parameters:
resolver
- a SourceResolver
value
Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.