Reputation: 85
I want to translate XML as CDATA, use XSLT mediator,
in client, send below message as application/xml,
<users>
<user>
<name>user-1</name>
<sex>M</sex>
<job>DBA</job>
</user>
<user>
<name>user-2</name>
<sex>F</sex>
<job>BPMS</job>
</user>
</users>
in proxy service,
<inSequence xmlns="http://ws.apache.org/ns/synapse">
<xslt key="test_xslt"/>
<log level="full">
<property name="text" value="===================="/>
</log>
</inSequence>
and XSLT of local entry "test_xslt",
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<body xmlns="http://ws.apache.org/ns/synapse">
<op_test_xml_parm>
<clob_xml>
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
<xsl:copy-of select="/"/>
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</clob_xml>
</op_test_xml_parm>
</body>
</xsl:template>
</xsl:stylesheet>
But the output:
[2013-07-03 18:30:42,998] INFO - LogMediator To: /services/test_xslt, MessageID: urn:uuid:7dff989b-7dc1-41b4-8826-55685009d4b5, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><body xmlns="http://ws.apache.org/ns/synapse">
<op_test_xml_parm>
<clob_xml><users xmlns="">
<user>
<name>user-1</name>
<sex>M</sex>
<job>DBA</job>
</user>
<user>
<name>user-2</name>
<sex>F</sex>
<job>BPMS</job>
</user>
</users></clob_xml>
</op_test_xml_parm>
</body></soapenv:Body></soapenv:Envelope>
[2013-07-03 18:30:43,005] INFO - LogMediator text = ====================
The result I expect is:
<body xmlns="http://ws.apache.org/ns/synapse">
<op_test_xml_parm>
<clob_xml><![CDATA[<users xmlns="">
<user>
<name>user-1</name>
<sex>M</sex>
<job>DBA</job>
</user>
<user>
<name>user-2</name>
<sex>F</sex>
<job>BPMS</job>
</user>
</users>]]></clob_xml>
</op_test_xml_parm>
</body>
if any one can help me how to fix it.
Upvotes: 1
Views: 1748
Reputation: 12513
That's not an issue. The one you expect (i.e. with CDATA tag) and the one you get (i.e. with "& lt;"s) are the same, semantically.
You can proceed without worrying about that.
Upvotes: 0
Reputation: 9702
Issue is in your xslt script..there are number of resources on how to insert cdata using xslt..you can check them..
Upvotes: 0