com.day.cq.rewriter.xml
Class XSLTProcessorImpl

java.lang.Object
  extended by com.day.cq.rewriter.xml.XSLTProcessorImpl
All Implemented Interfaces:
URIResolver

public class XSLTProcessorImpl
extends Object
implements URIResolver

Adaptation of Excalibur's XSLTProcessor implementation for OSGi.


Nested Class Summary
static class XSLTProcessorImpl.MyTransformerHandlerAndValidity
          Subclass to allow for instanciation, as for some unknown reason the constructor is protected....
static class XSLTProcessorImpl.TransformerHandlerAndValidity
           
 
Field Summary
protected  boolean checkIncludes
          Check included stylesheets
protected  SAXTransformerFactory factory
          The trax TransformerFactory this component uses
protected  Map<String,List<Object[]>> includesMap
          Map of pairs of System ID's / validities of the included stylesheets
protected  boolean incrementalProcessing
          Is incremental processing turned on? (default for Xalan: no)
protected  SourceResolver resolver
          The source resolver
protected  JaxpSAXParser saxParser
           
 
Constructor Summary
XSLTProcessorImpl(SourceResolver resolver)
           
 
Method Summary
 TransformerHandler getTransformerHandler(Source stylesheet)
          Return a TransformerHandler for a given stylesheet Source.
 Source resolve(String href, String base)
          Called by the processor when it encounters an xsl:include, xsl:import, or document() function.
 void setCheckIncludes(boolean checkIncludes)
           
 void setIncrementalProcessing(boolean incrementalProcessing)
           
 void transform(Source source, Source stylesheet, Map<String,Object> params, Result result)
          Applies an XSLT stylesheet to an XML document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected SAXTransformerFactory factory
The trax TransformerFactory this component uses


incrementalProcessing

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


resolver

protected SourceResolver resolver
The source resolver


checkIncludes

protected boolean checkIncludes
Check included stylesheets


includesMap

protected Map<String,List<Object[]>> includesMap
Map of pairs of System ID's / validities of the included stylesheets


saxParser

protected JaxpSAXParser saxParser
Constructor Detail

XSLTProcessorImpl

public XSLTProcessorImpl(SourceResolver resolver)
Method Detail

setIncrementalProcessing

public void setIncrementalProcessing(boolean incrementalProcessing)

setCheckIncludes

public void setCheckIncludes(boolean checkIncludes)

getTransformerHandler

public TransformerHandler getTransformerHandler(Source stylesheet)
                                         throws XSLTProcessorException

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.

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

Parameters:
stylesheet - a Source value < * @return a TransformerHandler value
Throws:
XSLTProcessorException - if an error occurs

transform

public void transform(Source source,
                      Source stylesheet,
                      Map<String,Object> params,
                      Result result)
               throws XSLTProcessorException
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.

Parameters:
source - a Source value
stylesheet - a Source value
params - a Map
result - a Result value
Throws:
XSLTProcessorException - if an error occurs

resolve

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

Specified by:
resolve in interface 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:
TransformerException - if an error occurs when trying to resolve the URI.


Copyright © 2008 Day Management AG. All Rights Reserved.