Skip to Content
avatar image
Former Member

Escape character handling in xslt map

Hello Experts,

I'm very new to xslt mapping. I got this requirement here, that receiver web application need escape characters in XML entity replacement. i.e. if PO xml has '&' it should get convert it to & like this...

I tried below code, but certainly it is not working

-----------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xhtml" indent="yes"/> 
<xsl:template match="@*|node()">
<xsl:copy> <xsl:apply-templates select="@*|node()"/>
</xsl:copy> </xsl:template> <xsl:template match="*/text()"> <xsl:value-of select="replace(., '&', '&')"/> </xsl:template>
</xsl:stylesheet>

----------------------------------------------------------------------------

Input:

<Root>

<Test>ABC & DEF</Test>

</Root>

Desired Output:

<Root>

<Test>ABC & DEF</Test>

</Root>

-----------------------------------------------------------------------------

Please tell me where i'm getting wrong, and a code will be highly appreciated.

Thanks a lot.

PS. Can't use JAVA mapping, it'd have been much easier though...

Add comment
10|10000 characters needed characters exceeded

  • Former Member

    the code actually <xsl:value-ofselect="replace(., '& amp;', '& amp;')"/>

    and

    Desired Output:

    <Root>

    <Test>ABC & amp; DEF</Test>

    </Root>

  • Get RSS Feed

1 Answer

  • Nov 30, 2016 at 05:53 AM

    Hi Debtirtha!

    Does your XSL transformation raise any error?

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded