synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Harts <prgt...@gmail.com>
Subject Re: Question about XSLT mediator
Date Tue, 14 Jul 2009 14:47:40 GMT
Andreas, Ruwan:

Thanks for clarifying this, it fixed my problem.  May I suggest
incorporating passing a parameter to a stylesheet into one of the samples?

Bill

On Tue, Jul 14, 2009 at 7:17 AM, Ruwan Linton <ruwan.linton@gmail.com>wrote:

> Yes, you need to declare the parameter with the exact name as the property
> name... I wonder why we call this property it is confusing to pass in
> parameters as properties :(
>
> Thanks,
> Ruwan
>
> On Tue, Jul 14, 2009 at 12:37 PM, Andreas Veithen <
> andreas.veithen@gmail.com> wrote:
>
>> Bill,
>>
>> I think you need to declare the parameter in your stylesheet using:
>>
>> <xsl:param name="TestMe"/>
>>
>> This declaration should be placed just below the <xsl:stylesheet> tag.
>>
>> Andreas
>>
>> On Mon, Jul 13, 2009 at 21:23, Bill Harts<bill@hartsandco.com> wrote:
>> > Can someone point me in the right direction to pass parameters (or
>> registry
>> > values) into an XSLT transform?
>> >
>> > In the documentation for the XSLT mediator it states,
>> >
>> > "Optionally parameters (XSLT) could be passed into the transformation
>> > through the 'property' elements."
>> >
>> > I am trying to take advantage of this. Here is my synapse.xml code:
>> >
>> > <localEntry key="xslt-key-resp"
>> > src="file:repository/conf/resources/transform/MyTransform.xslt" />
>> >
>> > .
>> > .
>> > .
>> >  <xslt key="xslt-key-resp">
>> >    <property name="TestMe" value="This is a test"/>
>> >  </xslt>
>> >
>> > and MyTransform.xslt:
>> >
>> >  <xsl:stylesheet version="2.0"
>> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> > xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
>> >    <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
>> >    <xsl:template match="/">
>> >        <message inSession="FIX.4.2:OPTMED->BROKER" counter="1">
>> >            <header>
>> >                <field id="8"><![CDATA[FIX.4.2]]></field>
>> >                <field id="35"><![CDATA[8]]></field>
>> >                <field id="49"><![CDATA[BROKER]]></field>
>> >                <field id="52"><![CDATA[20090526-06:50:26.661]]></field>
>> >                <field id="56"><![CDATA[OPTMED]]></field>
>> >            </header>
>> >            <body>
>> >                <field id="11"><xsl:value-of select="$TestMe" /></field>
>> >                <field id="21"><![CDATA[1]]></field>
>> >                <field id="38"><![CDATA[10000]]></field>
>> >                <field id="40"><![CDATA[1]]></field>
>> >                <field id="54"><![CDATA[1]]></field>
>> >                <field id="59"><![CDATA[0]]></field>
>> >                <field id="60"><![CDATA[20090526-06:50:26.657]]></field>
>> >                <field id="453"><![CDATA[1]]></field>
>> >            </body>
>> >            <trailer>
>> >                <field id="10"><![CDATA[186]]></field>
>> >            </trailer>
>> >        </message>
>> >    </xsl:template>
>> > </xsl:stylesheet>
>> >
>> > When I run it, I get an exception:
>> >
>> > 2009-07-13 14:53:28,019 [-] [HttpClientWorker-20] ERROR XSLTMediator
>> > Error creating XSLT transformer using : xslt-key-resp
>> > javax.xml.transform.TransformerConfigurationException:
>> > javax.xml.transform.TransformerException:
>> > org.apache.xml.utils.WrappedRuntimeException: Could not find variable
>> > with the name of TestMe
>> >
>> >        at
>> org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:961)
>> >        at
>> org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:239)
>> >        at
>> org.apache.synapse.mediators.transform.XSLTMediator.mediate(XSLTMediator.java:197)
>> >
>> >        at
>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
>> >        at
>> org.apache.synapse.mediators.filters.FilterMediator.mediate(FilterMediator.java:112)
>> >        at
>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
>> >
>> >        at
>> org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:115)
>> >        at
>> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:139)
>> >        at
>> org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:339)
>> >
>> >        at
>> org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:135)
>> >        at
>> org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
>> >        at
>> org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:230)
>> >
>> >        at
>> org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:58)
>> >        at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
>> >        at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
>> >
>> >        at java.lang.Thread.run(Thread.java:595)
>> > Caused by: javax.xml.transform.TransformerException:
>> > org.apache.xml.utils.WrappedRuntimeException: Could not find variable
>> > with the name of TestMe
>> >        at
>> org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:952)
>> >
>> >        ... 15 more
>> > Caused by: org.apache.xml.utils.WrappedRuntimeException: Could not
>> > find variable with the name of TestMe
>> >        at
>> org.apache.xpath.operations.Variable.fixupVariables(Variable.java:148)
>> >        at org.apache.xpath.XPath.fixupVariables(XPath.java:88)
>> >
>> >        at
>> org.apache.xalan.templates.ElemValueOf.compose(ElemValueOf.java:183)
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366)
>> >
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366)
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366)
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366)
>> >
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366)
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:341)
>> >        at
>> org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:471)
>> >
>> >        at
>> org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown
>> > Source)
>> >        at
>> org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown
>> > Source)
>> >        at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown
>> Source)
>> >
>> >        at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
>> >        at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown
>> Source)
>> >        at
>> org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown
>> > Source)
>> >
>> >        at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
>> > Source)
>> >        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
>> Source)
>> >        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
>> Source)
>> >
>> >        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>> >        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
>> Source)
>> >        at
>> org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
>> > Source)
>> >
>> >        at
>> org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:922)
>> >        ... 15 more
>> > 2009-07-13 14:53:28,219 [-] [DefaultQuartzScheduler_Worker-2] DEBUG
>> > InMediator Current message is incoming - executing child mediators
>> >
>> > 2009-07-13 14:53:29,762 [-] [HttpClientWorker-20] ERROR XSLTMediator
>> > Unable to perform XSLT transformation using : xslt-key-resp against
>> > source XPath : s11:Body/child::*[position()=1] |
>> > s12:Body/child::*[position()=1]
>> >
>> > org.apache.synapse.SynapseException: Error creating XSLT transformer
>> > using : xslt-key-resp
>> >        at
>> org.apache.synapse.mediators.AbstractMediator.handleException(AbstractMediator.java:275)
>> >        at
>> org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:245)
>> >
>> >        at
>> org.apache.synapse.mediators.transform.XSLTMediator.mediate(XSLTMediator.java:197)
>> >        at
>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
>> >        at
>> org.apache.synapse.mediators.filters.FilterMediator.mediate(FilterMediator.java:112)
>> >
>> >        at
>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
>> >        at
>> org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:115)
>> >        at
>> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:139)
>> >
>> >        at
>> org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:339)
>> >        at
>> org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:135)
>> >
>> >        at
>> org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
>> >        at
>> org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:230)
>> >        at
>> org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:58)
>> >
>> >        at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
>> >        at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
>> >        at java.lang.Thread.run(Thread.java:595)
>> >
>> > Caused by: javax.xml.transform.TransformerConfigurationException:
>> > javax.xml.transform.TransformerException:
>> > org.apache.xml.utils.WrappedRuntimeException: Could not find variable
>> > with the name of TestMe
>> >        at
>> org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:961)
>> >
>> >        at
>> org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:239)
>> >        ... 14 more
>> > Caused by: javax.xml.transform.TransformerException:
>> > org.apache.xml.utils.WrappedRuntimeException: Could not find variable
>> > with the name of TestMe
>> >
>> >        at
>> org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:952)
>> >        ... 15 more
>> > Caused by: org.apache.xml.utils.WrappedRuntimeException: Could not
>> > find variable with the name of TestMe
>> >
>> >        at
>> org.apache.xpath.operations.Variable.fixupVariables(Variable.java:148)
>> >        at org.apache.xpath.XPath.fixupVariables(XPath.java:88)
>> >        at
>> org.apache.xalan.templates.ElemValueOf.compose(ElemValueOf.java:183)
>> >
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366)
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366)
>> >
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366)
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366)
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366)
>> >
>> >        at
>> org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:341)
>> >        at
>> org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:471)
>> >        at
>> org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown
>> > Source)
>> >
>> >        at
>> org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown
>> > Source)
>> >        at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown
>> Source)
>> >        at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
>> >
>> >        at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown
>> Source)
>> >        at
>> org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown
>> > Source)
>> >        at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
>> > Source)
>> >
>> >        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
>> Source)
>> >        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
>> Source)
>> >        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>> >
>> >        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
>> Source)
>> >        at
>> org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
>> > Source)
>> >        at
>> org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:922)
>> >
>> >        ... 15 more
>> >
>> >
>> >  Alternatively, is there a way to use
>> "get-property('Registry-variable')" in
>> > the XSLT file?
>> >
>> > Is there an example of how to do this?
>> >
>> > Thanks,
>> > Bill
>> >
>>
>
>
>
> --
> Ruwan Linton
> Technical Lead & Product Manager; WSO2 ESB; http://wso2.org/esb
> WSO2 Inc.; http://wso2.org
> email: ruwan@wso2.com; cell: +94 77 341 3097
> blog: http://ruwansblog.blogspot.com
>

Mime
View raw message