on 07-23-2008 7:29 PM
Hi
I have to send an XML message inside a XML tag of a Message Type TestRQ_MT defined as String type.
XML message is going to be embedded in my message Type TestRQ_MT
<TestRQ><POS><Source Currency="USD"/> </POS></TestRQ>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:TestRQ_MT xmlns:ns0="http://test.com/Test">
<![CDATA[<TestRQ><POS><Source Currency="USD"/> </POS></TestRQ>]]></ns0:TestRQ_MT>
I want that target message should be free from CDATA
<TestRQ><POS><Source Currency="USD"/> </POS></TestRQ>
Please help me in how to remove CDATA in XSLT mapping
Gabriel,
See if the below helps..
Source XML
<doc>
<p>This is some text.</p>
<programlisting><![CDATA[This is a paragraph
with some newlines
does it work?]]></programlisting>
</doc>
xsl StyleSheet
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html>
<head/>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="p">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="programlisting">
<span style="font-family:monospace">
<xsl:call-template name="br-replace">
<xsl:with-param name="word" select="."/>
</xsl:call-template>
</span>
</xsl:template>
<xsl:template name="br-replace">
<xsl:param name="word"/>
<!-- </xsl:text> on next line on purpose to get newline -->
<xsl:variable name="cr"><xsl:text>
</xsl:text></xsl:variable>
<xsl:choose>
<xsl:when test="contains($word,$cr)">
<xsl:value-of select="substring-before($word,$cr)"/>
<br/>
<xsl:call-template name="br-replace">
<xsl:with-param name="word"
select="substring-after($word,$cr)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$word"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Returns
<html>
<head>
</head>
<body>
<p>This is some text.</p>
<span style=
"font-family:monospace">This is a paragraph<br> with some
newlines<br> does it work?</span>
</body>
</html>
Hope that helps
Regards
Ravi Raman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.