Class XsltPayloadTransformer

All Implemented Interfaces:
Aware, BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, InitializingBean, ApplicationContextAware, ExpressionCapable, GenericTransformer<Message<?>,Message<?>>, NamedComponent, Transformer

public class XsltPayloadTransformer extends AbstractXmlTransformer implements BeanClassLoaderAware
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, Artem Bilan, Mike Bazos, Gary Russell, Trung Pham
  • Constructor Details

    • XsltPayloadTransformer

      public XsltPayloadTransformer(Templates templates)
    • XsltPayloadTransformer

      public XsltPayloadTransformer(Templates templates, ResultTransformer resultTransformer)
    • XsltPayloadTransformer

      public XsltPayloadTransformer(Resource xslResource)
    • XsltPayloadTransformer

      public XsltPayloadTransformer(Resource xslResource, ResultTransformer resultTransformer)
    • XsltPayloadTransformer

      public XsltPayloadTransformer(Resource xslResource, String transformerFactoryClassName)
    • XsltPayloadTransformer

      public XsltPayloadTransformer(Resource xslResource, ResultTransformer resultTransformer, String transformerFactoryClassName)
  • Method Details

    • setSourceFactory

      public void setSourceFactory(SourceFactory sourceFactory)
      Sets the SourceFactory.
      Parameters:
      sourceFactory - The source factory.
    • setResultFactory

      public void setResultFactory(ResultFactory resultFactory)
      Sets the ResultFactory.
      Overrides:
      setResultFactory in class AbstractXmlTransformer
      Parameters:
      resultFactory - The result factory.
    • setAlwaysUseSourceFactory

      public void setAlwaysUseSourceFactory(boolean alwaysUseSourceFactory)
      Specify whether to always use source factory even for directly supported payload types.
      Parameters:
      alwaysUseSourceFactory - true to always use the source factory.
    • setAlwaysUseResultFactory

      public void setAlwaysUseResultFactory(boolean alwaysUseResultFactory)
      Specify whether to always use result factory even for directly supported payload types
      Parameters:
      alwaysUseResultFactory - true to always use the result factory.
    • setXslParameterMappings

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

      public void setXsltParamHeaders(String... xsltParamHeaders)
    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader classLoader)
      Specified by:
      setBeanClassLoader in interface BeanClassLoaderAware
    • setResultType

      public void setResultType(String resultType)
      Overrides:
      setResultType in class AbstractXmlTransformer
    • setResultFactoryName

      public void setResultFactoryName(String resultFactoryName)
      Overrides:
      setResultFactoryName in class AbstractXmlTransformer
    • getComponentType

      public String getComponentType()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this method to provide component type information.
      Specified by:
      getComponentType in interface NamedComponent
      Overrides:
      getComponentType in class IntegrationObjectSupport
    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class AbstractXmlTransformer
    • doTransform

      protected Object doTransform(Message<?> message)
      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
      Parameters:
      message - The message.
      Returns:
      The result of the transformation.