user3595078
user3595078

Reputation: 273

Throwing errors when using XSLT mediator in WSO2ESB

I am using wso2esb4.8.0 I wish to transform the data but unable to do it

I am getting message input like this

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:env="http://eai.parn.getv/Envelope" xmlns:open="http://www.openuri.org/" xmlns:gg="http://eai.par.getv/mm">
   <soapenv:Header />
   <soapenv:Body>
      <open:clientRequest>
         <env:EaiEnvelope>
            <env:GenTimeStamp>1</env:GenTimeStamp>
            <env:SentTimeStamp>1</env:SentTimeStamp>
            <env:Payload>
               <gg:mm>
                  <gg:Request>
                     <gg:Operation_Name>dd</gg:Operation_Name>
                  </gg:Request>
               </gg:mm>
            </env:Payload>
         </env:EaiEnvelope>
      </open:clientRequest>
   </soapenv:Body>
</soapenv:Envelope>

But my adapter endggt will allow the request in this format. If it is for one operation I may follow payload mediator to make my request but those are bunch of requests so endggt allowing request is

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:open="http://www.openuri.org/" xmlns:gg="http://eai.par.getv/mm">
   <soapenv:Header/>
   <soapenv:Body>
      <open:dd>
         <gg:mm>
            <gg:Request>
               <gg:Operation_Name>dd</gg:Operation_Name>
            </gg:Request>
         </gg:mm>
      </open:dd>
   </soapenv:Body>
</soapenv:Envelope>

Just extract the Operation_Name and adding it as complex element but I am unable to do it I am trying in proxy like this

Proxy is

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="ProxyPOC8"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property xmlns:open="http://www.openuri.org/"
                   xmlns:ns="http://org.apache.synapse/xsd"
                   xmlns:env="http://eai.parn.getv/Envelope"
                   xmlns:gg="http://eai.par.getv/mm"
                   name="payloadvalue"
                   expression="//env:Payload/*"
                   scope="default"
                   type="STRING"/>
         <property xmlns:open="http://www.openuri.org/"
                   xmlns:ns="http://org.apache.synapse/xsd"
                   xmlns:env="http://eai.parn.getv/Envelope"
                   name="operation_name"
                   expression="concat('open:',get-property('Operation_Name'))"
                   scope="default"
                   type="STRING"/>
         <xslt key="sample2.xslt">
            <property name="operation_name" expression="get-property('operation_name')"/>
            <property name="payloadvalue" expression="get-property('payloadvalue')"/>
         </xslt>
         <log level="full">
            <property name="Message" expression="get-property('AddElement')"/>
         </log>
      </inSequence>
   </target>
   <description/>
</proxy>

XSLT stylesheet written like this

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:open="http://www.openuri.org/" xmlns:env="http://eai.parn.getv/Envelope" xmlns:gg="http://eai.par.getv/mm" version="1.0">
      <xsl:param name="operation_name"></xsl:param>
      <xsl:param name="payloadvalue"></xsl:param>
      <xsl:template match="//">
         <xsl:element name="{$operation_name}">
            <xsl:value-of select="$payloadvalue"></xsl:value-of>
         </xsl:element>
      </xsl:template>
   </xsl:stylesheet>

Error in log showing like this

ProxyPOC8 {super-tenant}
[2014-05-15 14:23:53,314] INFO - ProxyService Successfully created the Axis2 service for Proxy service : ProxyPOC8
[2014-05-15 14:24:01,217] ERROR - XSLTMediator Fatal error occurred in stylesheet parsing : net.sf.saxon.trans.XPathException: Unexpected token "" in path expression
[2014-05-15 14:24:01,262] ERROR - XSLTMediator Error creating XSLT transformer using : Value {name ='null', keyValue ='sample2.xslt'}
javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.
at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:220) at net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:132)
at org.apache.synapse.mediators.transform.XSLTMediator.createTemplate(XSLTMediator.java:383)

Can anybody help me with this problem?

Thanks in advance.

Upvotes: 0

Views: 1052

Answers (1)

Joel M. Lamsen
Joel M. Lamsen

Reputation: 7173

change

<xsl:template match="//">

to

<xsl:template match="/">

Upvotes: 1

Related Questions