Skip to Content

XSLT Mapping

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"?>

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 07:14 PM

    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

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.