我想将 XML 翻译为 CDATA,使用 XSLT 中介,
在客户端,将以下消息作为应用程序/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>
在代理服务中,
<inSequence xmlns="http://ws.apache.org/ns/synapse">
<xslt key="test_xslt"/>
<log level="full">
<property name="text" value="===================="/>
</log>
</inSequence>
和本地条目“test_xslt”的 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>
但是输出:
[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 = ====================
我期望的结果是:
<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>
如果有人可以帮助我如何解决它。