org.springframework.integration.xml.transformer
Class XsltPayloadTransformer

java.lang.Object
  extended by org.springframework.integration.xml.transformer.XsltPayloadTransformer
All Implemented Interfaces:
PayloadTransformer<java.lang.Object,java.lang.Object>

public class XsltPayloadTransformer
extends java.lang.Object
implements PayloadTransformer<java.lang.Object,java.lang.Object>

XSLT transformer implementation which returns a transformed Source, Document, or String. If alwaysUseSourceResultFactories is false (default) the following logic occurs String payload in results in String payload out Document payload in Document payload out Source payload in Result payload out, type will be determined by the ResultFactory, DomResultFactory by default. If an instance of ResultTransformer is registered this will be used to convert the result. If alwaysUseSourceResultFactories is true then the ResultFactory and SourceFactory will be used to create the Source from the payload and the Result to pass into the transformer. An instance of ResultTransformer can also be provided to convert the Result prior to returnign

Author:
Jonas Partner, Mark Fisher

Field Summary
private  boolean alwaysUseSourceResultFactories
           
private  ResultFactory resultFactory
           
private  ResultTransformer resultTransformer
           
private  SourceFactory sourceFactory
           
private  javax.xml.transform.Templates templates
           
 
Constructor Summary
XsltPayloadTransformer(org.springframework.core.io.Resource xslResource)
           
XsltPayloadTransformer(org.springframework.core.io.Resource xslResource, ResultTransformer resultTransformer)
           
XsltPayloadTransformer(javax.xml.transform.Templates templates)
           
XsltPayloadTransformer(javax.xml.transform.Templates templates, ResultTransformer resultTransformer)
           
 
Method Summary
 void setAlwaysUseSourceResultFactories(boolean alwaysUserSourceResultFactories)
          Forces use of ResultFactory and SourceFactory even for directly supported payloads such as String and Document
 void setResultFactory(ResultFactory resultFactory)
           
 void setSourceFactory(SourceFactory sourceFactory)
           
 java.lang.Object transform(java.lang.Object payload)
           
protected  org.w3c.dom.Document transformDocument(org.w3c.dom.Document documentPayload)
           
protected  java.lang.Object transformSource(javax.xml.transform.Source source, java.lang.Object payload)
           
protected  java.lang.String transformString(java.lang.String stringPayload)
           
protected  java.lang.Object transformUsingFactories(java.lang.Object payload)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

templates

private final javax.xml.transform.Templates templates

resultTransformer

private final ResultTransformer resultTransformer

sourceFactory

private volatile SourceFactory sourceFactory

resultFactory

private volatile ResultFactory resultFactory

alwaysUseSourceResultFactories

private volatile boolean alwaysUseSourceResultFactories
Constructor Detail

XsltPayloadTransformer

public XsltPayloadTransformer(javax.xml.transform.Templates templates)
                       throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException

XsltPayloadTransformer

public XsltPayloadTransformer(javax.xml.transform.Templates templates,
                              ResultTransformer resultTransformer)
                       throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException

XsltPayloadTransformer

public XsltPayloadTransformer(org.springframework.core.io.Resource xslResource)
                       throws java.lang.Exception
Throws:
java.lang.Exception

XsltPayloadTransformer

public XsltPayloadTransformer(org.springframework.core.io.Resource xslResource,
                              ResultTransformer resultTransformer)
                       throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

transform

public java.lang.Object transform(java.lang.Object payload)
                           throws javax.xml.transform.TransformerException
Specified by:
transform in interface PayloadTransformer<java.lang.Object,java.lang.Object>
Throws:
javax.xml.transform.TransformerException

setSourceFactory

public void setSourceFactory(SourceFactory sourceFactory)
Parameters:
sourceFactory -

setResultFactory

public void setResultFactory(ResultFactory resultFactory)
Parameters:
resultFactory -

setAlwaysUseSourceResultFactories

public void setAlwaysUseSourceResultFactories(boolean alwaysUserSourceResultFactories)
Forces use of ResultFactory and SourceFactory even for directly supported payloads such as String and Document

Parameters:
alwaysUserSourceResultFactories -

transformUsingFactories

protected java.lang.Object transformUsingFactories(java.lang.Object payload)
                                            throws javax.xml.transform.TransformerException
Throws:
javax.xml.transform.TransformerException

transformSource

protected java.lang.Object transformSource(javax.xml.transform.Source source,
                                           java.lang.Object payload)
                                    throws javax.xml.transform.TransformerException
Throws:
javax.xml.transform.TransformerException

transformString

protected java.lang.String transformString(java.lang.String stringPayload)
                                    throws javax.xml.transform.TransformerException
Throws:
javax.xml.transform.TransformerException

transformDocument

protected org.w3c.dom.Document transformDocument(org.w3c.dom.Document documentPayload)
                                          throws javax.xml.transform.TransformerException
Throws:
javax.xml.transform.TransformerException