org.springframework.integration.xml.transformer
Class XsltPayloadTransformer

java.lang.Object
  extended by org.springframework.integration.transformer.AbstractTransformer
      extended by org.springframework.integration.xml.transformer.XsltPayloadTransformer
All Implemented Interfaces:
Transformer

public class XsltPayloadTransformer
extends AbstractTransformer

Thread safe 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 returning

Author:
Jonas Partner, Mark Fisher

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
protected  javax.xml.transform.Transformer buildTransformer(Message<?> message)
           
protected  java.lang.Object doTransform(Message<?> message)
          Subclasses must implement this method to provide the transformation logic.
 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)
           
protected  org.w3c.dom.Document transformDocument(org.w3c.dom.Document documentPayload, javax.xml.transform.Transformer transformer)
           
protected  java.lang.Object transformSource(javax.xml.transform.Source source, java.lang.Object payload, javax.xml.transform.Transformer transformer)
           
protected  java.lang.String transformString(java.lang.String stringPayload, javax.xml.transform.Transformer transformer)
           
protected  java.lang.Object transformUsingFactories(java.lang.Object payload, javax.xml.transform.Transformer transformer)
           
 
Methods inherited from class org.springframework.integration.transformer.AbstractTransformer
transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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 -

doTransform

protected java.lang.Object doTransform(Message<?> message)
                                throws java.lang.Exception
Description copied from class: AbstractTransformer
Subclasses must implement this method to provide the transformation logic. If the return value is itself a Message, it will be used as the result. Otherwise, any non-null return value will be used as the payload of the result Message.

Specified by:
doTransform in class AbstractTransformer
Throws:
java.lang.Exception

transformUsingFactories

protected java.lang.Object transformUsingFactories(java.lang.Object payload,
                                                   javax.xml.transform.Transformer transformer)
                                            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,
                                           javax.xml.transform.Transformer transformer)
                                    throws javax.xml.transform.TransformerException
Throws:
javax.xml.transform.TransformerException

transformString

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

transformDocument

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

buildTransformer

protected javax.xml.transform.Transformer buildTransformer(Message<?> message)
                                                    throws javax.xml.transform.TransformerException
Throws:
javax.xml.transform.TransformerException