- 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">
<xslutput method="xml" indent="yes" ></xslutput>
<xsl:template name="stripSpecialChars">
<xslaram name="string" />
<xsl:value-of select="translate($string,'()*%$#@!~<>,.?[]=-+/\',' ')"/>
</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>
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">
<xslutput method="xml" indent="yes" ></xslutput>
<xsl:template name="stripSpecialChars">
<xslaram name="string" />
<xsl:value-of select="translate($string,'()*%$#@!~<>,.?[]=-+/\',' ')"/>
</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>