mulexpath-3.0

Mule 3.6.1 xpath3


I am trying to migrate my Mule 3.4 CE applications to Mule 3.6.1 CE and having issues with xpath3.

Payload:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:itemMessage xmlns:ns2="http://test.com/messages">
    <requestId>QAREQ:150623_0002</requestId>
    <requestStatus>COMPLETE</requestStatus>
</ns2:itemMessage>

xpath expression (working)

#[xpath('string(//itemMessage/requestId/text())')]

xpath3 expression (not working)

#[xpath3('//itemMessage/requestId/text()', payload, 'STRING')]

Appreciate any insight.


Solution

  • Your Xpath expression does not seem to match the XML document. But based on the XML document this works:

    <mulexml:namespace-manager
            includeConfigNamespaces="true">
       <mulexml:namespace prefix="ns2" uri="http://test.com/messages" />
    </mulexml:namespace-manager>
    
    <flow name="testFlow">
        <poll doc:name="Poll">
            <set-payload
                value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt; &lt;ns2:itemMessage xmlns:ns2=&quot;http://test.com/messages&quot;&gt; &lt;requestId&gt;QAREQ:150623_0002&lt;/requestId&gt; &lt;requestStatus&gt;COMPLETE&lt;/requestStatus&gt; &lt;/ns2:itemMessage&gt;"
                doc:name="Set Payload" />
        </poll>
        <logger level="INFO" message="#[xpath3('ns2:itemMessage/requestId/text()', payload, 'STRING')]" />
    </flow>