Class XSLTMediator
- java.lang.Object
-
- org.apache.synapse.mediators.AbstractMediator
-
- org.apache.synapse.mediators.transform.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 Summary
Fields Modifier and Type Field Description static String
RESULT_BUILDER_FACTORY
The name of the attribute that allows to specify theResultBuilderFactory
.static String
SOURCE_BUILDER_FACTORY
The name of the attribute that allows to specify theSourceBuilderFactory
.static String
STYLESHEET_PARSING_ACTIVITY
static 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" attributestatic String
USE_DOM_SOURCE_AND_RESULTS
The feature for which deciding switching between DOM and Stream during the transformation processstatic String
XSLT_TRANSFORMATION_ACTIVITY
Two template creation activities-
Fields inherited from class org.apache.synapse.mediators.AbstractMediator
log, trace, traceState
-
-
Constructor Summary
Constructors Constructor Description XSLTMediator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAllProperties(List<MediatorProperty> list)
void
addAttribute(String name, String value)
Add an attribute to be set on theTransformerFactory
used by this mediator instance.void
addFeature(String featureName, boolean isFeatureEnable)
Add a feature to be set on theTransformerFactory
used by this mediator instance.void
addProperty(MediatorProperty p)
List<MediatorProperty>
getAttributes()
List<MediatorProperty>
getFeatures()
List<MediatorProperty>
getProperties()
ResourceMap
getResourceMap()
SynapseXPath
getSource()
String
getTargetPropertyName()
Value
getXsltKey()
boolean
isContentAltering()
This is used to indicate whether message payload get modified during mediationboolean
isUseCache()
boolean
mediate(MessageContext synCtx)
Transforms this message (or its element specified as the source) using the given XSLT transformationvoid
setResourceMap(ResourceMap resourceMap)
void
setSource(SynapseXPath source)
void
setSourceXPathString(String sourceXPathString)
void
setTargetPropertyName(String targetPropertyName)
void
setUseCache(boolean useCache)
void
setXsltKey(Value xsltKey)
-
Methods inherited from class org.apache.synapse.mediators.AbstractMediator
auditLog, auditWarn, configure, disableStatistics, disableTracing, divertMediationRoute, enableStatistics, enableTracing, getAspectConfiguration, getCommentsList, getDescription, getInputType, getLastSequenceFaultHandler, getLog, getMediatorName, getMediatorPosition, getOutputType, getRegisteredMediationFlowPoint, getShortDescription, getTraceState, getType, handleException, handleException, isBreakPoint, isContentAware, isSkipEnabled, isStatisticsEnable, isTraceOn, isTraceOrDebugOn, isTracingEnabled, registerMediationFlowPoint, reportCloseStatistics, reportOpenStatistics, setBreakPoint, setCommentsList, setComponentStatisticsId, setDescription, setEffectiveTraceState, setMediatorPosition, setShortDescription, setSkipEnabled, setTraceState, shouldCaptureTracing, shouldTrace, shouldTrace, traceOrDebug, traceOrDebugWarn, unregisterMediationFlowPoint
-
-
-
-
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
-
SOURCE_BUILDER_FACTORY
public static final String SOURCE_BUILDER_FACTORY
The name of the attribute that allows to specify theSourceBuilderFactory
.- See Also:
- Constant Field Values
-
RESULT_BUILDER_FACTORY
public static final String RESULT_BUILDER_FACTORY
The name of the attribute that allows to specify theResultBuilderFactory
.- 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
-
STYLESHEET_PARSING_ACTIVITY
public static final String STYLESHEET_PARSING_ACTIVITY
- See Also:
- Constant Field Values
-
-
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
-
getSource
public SynapseXPath getSource()
-
setSource
public void setSource(SynapseXPath source)
-
getXsltKey
public Value getXsltKey()
-
setXsltKey
public void setXsltKey(Value xsltKey)
-
addProperty
public void addProperty(MediatorProperty p)
-
addFeature
public void addFeature(String featureName, boolean isFeatureEnable)
Add a feature to be set on theTransformerFactory
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 featureisFeatureEnable
- 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 theTransformerFactory
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 featurevalue
- 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.
-
addAllProperties
public void addAllProperties(List<MediatorProperty> list)
-
getProperties
public List<MediatorProperty> getProperties()
-
setSourceXPathString
public void setSourceXPathString(String sourceXPathString)
-
getTargetPropertyName
public String getTargetPropertyName()
-
setTargetPropertyName
public void setTargetPropertyName(String targetPropertyName)
-
getResourceMap
public ResourceMap getResourceMap()
-
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 interfaceMediator
- Overrides:
isContentAltering
in classAbstractMediator
- Returns:
- whether mediator modify the payload
-
isUseCache
public boolean isUseCache()
-
setUseCache
public void setUseCache(boolean useCache)
-
-