cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT Mapping

GabrielSagaya
Active Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

ravi_raman2
Active Contributor
0 Kudos

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

GabrielSagaya
Active Contributor
0 Kudos

Hi

Thanks for your help

But i want to have the xml element as it is between in CDATA.

because i am getting like

&lt;TestRQ&gt;&lt;POS&gt;&lt;Source Currency="USD"/&gt; &lt;/POS&gt;&lt;/TestRQ&gt;

instead of

<TestRQ><POS><Source Currency="USD"/> </POS></TestRQ>

Answers (0)