Class XSLTMediator

  • All Implemented Interfaces:
    AspectConfigurable, Mediator, SynapseArtifact

    public class XSLTMediator
    extends AbstractMediator
    The XSLT mediator performs an XSLT transformation requested, using the current message. The source attribute (if available) specifies the source element on which the transformation would be applied. It will default to the first child of the messages' SOAP body, if it is omitted.

    Additional properties passed into this mediator would become parameters for XSLT. Additional features passed into this mediator would become features except for "http://ws.apache.org/ns/synapse/transform/feature/dom" for the Transformer Factory, which is used to decide between using DOM and Streams during the transformation process. By default this is turned on as an optimization, but should be set to false if issues are detected

    Note: Set the TransformerFactory system property to generate and use translets -Djavax.xml.transform.TransformerFactory=org.apache.xalan.xsltc.trax.TransformerFactoryImpl

    • Field Detail

      • USE_DOM_SOURCE_AND_RESULTS

        public static final String USE_DOM_SOURCE_AND_RESULTS
        The feature for which deciding switching between DOM and Stream during the transformation process
        See Also:
        Constant Field Values
      • TRANSFORM_XSLT_RESULT_DISABLE_BUILD

        public static final String TRANSFORM_XSLT_RESULT_DISABLE_BUILD
        IF the user have set this property, the XSLTMediator does not build the result xml, instead it will be stored as string property with name givent in "target" attribute
        See Also:
        Constant Field Values
      • XSLT_TRANSFORMATION_ACTIVITY

        public static final String XSLT_TRANSFORMATION_ACTIVITY
        Two template creation activities
        See Also:
        Constant Field Values
    • Constructor Detail

      • XSLTMediator

        public XSLTMediator()
    • Method Detail

      • mediate

        public boolean mediate​(MessageContext synCtx)
        Transforms this message (or its element specified as the source) using the given XSLT transformation
        Parameters:
        synCtx - the current message where the transformation will apply
        Returns:
        true always
      • setSource

        public void setSource​(SynapseXPath source)
      • getXsltKey

        public Value getXsltKey()
      • setXsltKey

        public void setXsltKey​(Value xsltKey)
      • addFeature

        public void addFeature​(String featureName,
                               boolean isFeatureEnable)
        Add a feature to be set on the TransformerFactory used by this mediator instance. This method can also be used to enable some Synapse specific optimizations and enhancements as described in the documentation of this class.
        Parameters:
        featureName - The name of the feature
        isFeatureEnable - the desired state of the feature
        See Also:
        TransformerFactory.setFeature(String, boolean), XSLTMediator
      • addAttribute

        public void addAttribute​(String name,
                                 String value)
        Add an attribute to be set on the TransformerFactory used by this mediator instance. This method can also be used to enable some Synapse specific optimizations and enhancements as described in the documentation of this class.
        Parameters:
        name - The name of the feature
        value - should this feature enable?
        See Also:
        TransformerFactory.setAttribute(String, Object), XSLTMediator
      • getFeatures

        public List<MediatorProperty> getFeatures()
        Returns:
        Return the features explicitly set to the TransformerFactory through this mediator.
      • getAttributes

        public List<MediatorProperty> getAttributes()
        Returns:
        Return the attributes explicitly set to the TransformerFactory through this mediator.
      • setSourceXPathString

        public void setSourceXPathString​(String sourceXPathString)
      • getTargetPropertyName

        public String getTargetPropertyName()
      • setTargetPropertyName

        public void setTargetPropertyName​(String targetPropertyName)
      • setResourceMap

        public void setResourceMap​(ResourceMap resourceMap)
      • isContentAltering

        public boolean isContentAltering()
        Description copied from interface: Mediator
        This is used to indicate whether message payload get modified during mediation
        Specified by:
        isContentAltering in interface Mediator
        Overrides:
        isContentAltering in class AbstractMediator
        Returns:
        whether mediator modify the payload
      • isUseCache

        public boolean isUseCache()
      • setUseCache

        public void setUseCache​(boolean useCache)