remove specail character from xml using xslt

Joined
Nov 2, 2011
Messages
1
Reaction score
0
Hi All,

I have simple doubt in xml - xsl mapping
I need to remove a special character '&' , ';' from the XML using XSL.
My input XML will look like:
<Details>
<Name>xxx & yyy </Name>
</Details>
My output will look like:
<Person>
<Name> xxx yyy </Name>
</Person>
I am using a xsl where i am trying to convert all the special characters to empty space.
all other special characters are translted but whenever & come throwing error.
Could you please guide me how to handle & using xsl.
Thanks in advance.

This is my xsl sheet:
Code:
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version="1.0">
<xsl:eek:utput method="xml" indent="yes" ></xsl:eek:utput>
<xsl:template name="stripSpecialChars">
<xsl:param name="string" />
<xsl:value-of select="translate($string,'()*%$#@!~&lt;&gt;,.?[]=-+/\',' ')"/>
</xsl:template>
<xsl:template match="/">
<xsl:text><![CDATA[<Person>]]></xsl:text>
<xsl:text><![CDATA[<Name>]]></xsl:text>
<xsl:call-template name="stripSpecialChars">
<xsl:with-param name="string" select="/Details/Name"/>
</xsl:call-template>
<xsl:text><![CDATA[</Name>]]></xsl:text>
<xsl:text><![CDATA[</Person>]]></xsl:text>
</xsl:template>
</xsl:stylesheet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top