Spring Integration

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 results in Document payload out

Source payload in results 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, Oleg Zhurakousky

Constructor Summary
XsltPayloadTransformer(Resource xslResource)
           
XsltPayloadTransformer(Resource xslResource, ResultTransformer resultTransformer)
           
XsltPayloadTransformer(Templates templates)
           
XsltPayloadTransformer(Templates templates, ResultTransformer resultTransformer)
           
 
Method Summary
protected  Transformer buildTransformer(Message<?> message)
           
protected  Object doTransform(Message<?> message)
          Subclasses must implement this method to provide the transformation logic.
 Map<String,Expression> getXslParameterMappings()
           
 String[] getXsltParamHeaders()
           
 void setAlwaysUseSourceResultFactories(boolean alwaysUserSourceResultFactories)
          Specifies whether ResultFactory and SourceFactory should always be used, even for directly supported payloads such as String and Document.
 void setResultFactory(ResultFactory resultFactory)
          Sets the ResultFactory
 void setSourceFactory(SourceFactory sourceFactory)
          Sets the SourceFactory.
 void setXslParameterMappings(Map<String,Expression> xslParameterMappings)
           
 void setXsltParamHeaders(String[] xsltParamHeaders)
           
protected  Document transformDocument(Document documentPayload, Transformer transformer)
           
protected  Object transformSource(Source source, Object payload, Transformer transformer)
           
protected  String transformString(String stringPayload, Transformer transformer)
           
protected  Object transformUsingFactories(Object payload, 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(Templates templates)
                       throws ParserConfigurationException
Throws:
ParserConfigurationException

XsltPayloadTransformer

public XsltPayloadTransformer(Templates templates,
                              ResultTransformer resultTransformer)
                       throws ParserConfigurationException
Throws:
ParserConfigurationException

XsltPayloadTransformer

public XsltPayloadTransformer(Resource xslResource)
                       throws Exception
Throws:
Exception

XsltPayloadTransformer

public XsltPayloadTransformer(Resource xslResource,
                              ResultTransformer resultTransformer)
                       throws Exception
Throws:
Exception
Method Detail

setSourceFactory

public void setSourceFactory(SourceFactory sourceFactory)
Sets the SourceFactory.


setResultFactory

public void setResultFactory(ResultFactory resultFactory)
Sets the ResultFactory


setAlwaysUseSourceResultFactories

public void setAlwaysUseSourceResultFactories(boolean alwaysUserSourceResultFactories)
Specifies whether ResultFactory and SourceFactory should always be used, even for directly supported payloads such as String and Document.


doTransform

protected Object doTransform(Message<?> message)
                      throws 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:
Exception

transformUsingFactories

protected Object transformUsingFactories(Object payload,
                                         Transformer transformer)
                                  throws TransformerException
Throws:
TransformerException

transformSource

protected Object transformSource(Source source,
                                 Object payload,
                                 Transformer transformer)
                          throws TransformerException
Throws:
TransformerException

transformString

protected String transformString(String stringPayload,
                                 Transformer transformer)
                          throws TransformerException
Throws:
TransformerException

transformDocument

protected Document transformDocument(Document documentPayload,
                                     Transformer transformer)
                              throws TransformerException
Throws:
TransformerException

buildTransformer

protected Transformer buildTransformer(Message<?> message)
                                throws TransformerException
Throws:
TransformerException

getXslParameterMappings

public Map<String,Expression> getXslParameterMappings()

setXslParameterMappings

public void setXslParameterMappings(Map<String,Expression> xslParameterMappings)

getXsltParamHeaders

public String[] getXsltParamHeaders()

setXsltParamHeaders

public void setXsltParamHeaders(String[] xsltParamHeaders)

Spring Integration

Copyright © 2010. All Rights Reserved.