|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mule.transformer.AbstractTransformer
org.mule.transformer.AbstractMessageAwareTransformer
org.mule.module.xml.transformer.AbstractXmlTransformer
org.mule.module.xml.transformer.XsltTransformer
public class XsltTransformer
XsltTransformer performs an XSLT transform on a DOM (or other XML-ish)
object.
Transformer objects to speed up processing of concurrent requests.
The pool can be configured using setMaxIdleTransformers(int).
Parameter can also be set as part of the transformation context and these can be mapped to conent in the current message using
property extractors or can be fixed values.
For example, the current event's message has a property named "myproperty", also you want to generate a uuid as a
parameter. To do this you can define context properties that can provide an expression to be evaluated on the current
message.
Example Configuration:
<mxml:xslt-transformer name="MyXsltTransformer" xslFile="myXslFile.xsl">
<context-property name="myParameter" value="#[head:myproperty]"/>
<context-property name="myParameter2" value="#[function:uuid]"/>
</mxml:xslt-transformer>
The 'header' expression pulls a header from the current message and 'function' can execute a set of arbitrary functions. You can also pass in static values by ommitting the expression prefix '#['.
In addition to being able to pass in an XSLT file you can also define templates inline. For example -
<mxml:xslt-transformer name="MyXsltTransformer">
<mxml:xslt-text>
</mxml:xslt-text>
| Nested Class Summary | |
|---|---|
protected class |
XsltTransformer.DefaultErrorListener
|
protected class |
XsltTransformer.PooledXsltTransformerFactory
|
| Nested classes/interfaces inherited from class org.mule.module.xml.transformer.AbstractXmlTransformer |
|---|
AbstractXmlTransformer.ResultHolder |
| Field Summary | |
|---|---|
static String |
PREFERRED_TRANSFORMER_FACTORY
|
protected GenericObjectPool |
transformerPool
|
| Fields inherited from class org.mule.transformer.AbstractTransformer |
|---|
DEFAULT_TRUNCATE_LENGTH, endpoint, logger, MULE_MESSAGE_ADAPTER_DATA_TYPE, MULE_MESSAGE_DATA_TYPE, muleContext, name, returnType, sourceTypes |
| Fields inherited from interface org.mule.api.lifecycle.Initialisable |
|---|
PHASE_NAME |
| Constructor Summary | |
|---|---|
XsltTransformer()
|
|
XsltTransformer(String xslFile)
|
|
| Method Summary | |
|---|---|
protected void |
doTransform(MuleMessage message,
String encoding,
Source sourceDoc,
Result result)
|
protected Object |
evaluateTransformParameter(String name,
Object value,
MuleMessage message)
Returns the value to be set for the parameter. |
Map |
getContextProperties()
Gets the parameters to be used when applying the transformation |
protected Object |
getDelayedResult(MuleMessage message,
String encoding,
Source sourceDoc)
|
int |
getMaxActiveTransformers()
|
int |
getMaxIdleTransformers()
|
protected StreamSource |
getStreamSource()
Returns the StreamSource corresponding to xslFile |
URIResolver |
getUriResolver()
|
String |
getXslFile()
|
String |
getXslt()
|
String |
getXslTransformerFactory()
Returns the name of the currently configured javax.xml.transform.Transformer factory class used to create XSLT Transformers. |
void |
initialise()
Template method where deriving classes can do any initialisation after the properties have been set on this transformer |
void |
setContextProperties(Map contextProperties)
Sets the parameters to be used when applying the transformation |
void |
setMaxActiveTransformers(int maxActiveTransformers)
Sets the the current maximum number of active transformer objects allowed in the pool |
void |
setMaxIdleTransformers(int maxIdleTransformers)
Sets the the current maximum number of idle transformer objects allowed in the pool |
void |
setUriResolver(URIResolver uriResolver)
|
void |
setXslFile(String xslFile)
|
void |
setXslt(String xslt)
|
void |
setXslTransformerFactory(String xslTransformerFactory)
Configures the javax.xml.transform.Transformer factory class |
Object |
transform(MuleMessage message,
String encoding)
Transform, using XSLT, a XML String to another String. |
| Methods inherited from class org.mule.module.xml.transformer.AbstractXmlTransformer |
|---|
convertToBytes, convertToText, convertToText, getOutputEncoding, getResultHolder, getXMLInputFactory, getXMLOutputFactory, isUseStaxSource, setOutputEncoding, setUseStaxSource, setXMLInputFactory, setXMLOutputFactory, writeToStream |
| Methods inherited from class org.mule.transformer.AbstractMessageAwareTransformer |
|---|
doTransform, isSourceDataTypeSupported |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String PREFERRED_TRANSFORMER_FACTORY
protected final GenericObjectPool transformerPool
| Constructor Detail |
|---|
public XsltTransformer()
public XsltTransformer(String xslFile)
| Method Detail |
|---|
public void initialise()
throws InitialisationException
AbstractTransformer
initialise in interface Initialisableinitialise in class AbstractTransformerInitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from
public Object transform(MuleMessage message,
String encoding)
throws TransformerException
transform in class AbstractMessageAwareTransformerTransformerException
protected Object getDelayedResult(MuleMessage message,
String encoding,
Source sourceDoc)
protected void doTransform(MuleMessage message,
String encoding,
Source sourceDoc,
Result result)
throws Exception
Exceptionpublic String getXslTransformerFactory()
null if none has been
configuredpublic void setXslTransformerFactory(String xslTransformerFactory)
xslTransformerFactory - the name of the TransformerFactory class to usepublic String getXslFile()
public void setXslFile(String xslFile)
xslFile - The xslFile to set.public String getXslt()
public void setXslt(String xslt)
public URIResolver getUriResolver()
public void setUriResolver(URIResolver uriResolver)
protected StreamSource getStreamSource()
throws InitialisationException
InitialisationExceptionpublic int getMaxActiveTransformers()
public void setMaxActiveTransformers(int maxActiveTransformers)
maxActiveTransformers - New maximum size to setpublic int getMaxIdleTransformers()
public void setMaxIdleTransformers(int maxIdleTransformers)
maxIdleTransformers - New maximum size to setpublic Map getContextProperties()
Transformer.setParameter(java.lang.String,
java.lang.Object)public void setContextProperties(Map contextProperties)
contextProperties - a map of the parameter names and associated valuesTransformer.setParameter(java.lang.String,
java.lang.Object)
protected Object evaluateTransformParameter(String name,
Object value,
MuleMessage message)
throws TransformerException
name - the name of the parameter. The name isn't used for this implementation but is exposed as a
param for classes that may need it.value - the value of the paramter
TransformerException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||