1

I am using XSL 1.0, I have this kind of XML-

<ID>"7080"</ID>
<NAME>"Media"</NAME>
<ADDRESS>
    <STREET_1>"400 Street"</STREET_1>
</ADDRESS>

The values are coming with Double Quotes. I am trying to remove these double quotes in XSL 1.0 and show up my Result as:

 <ID>7080</ID>
    <NAME>Media</NAME>
    <ADDRESS>
        <STREET_1>400 Street</STREET_1>
    </ADDRESS>

Also, I have tried it to apply translate function to the root element of the XML but it isn't working. Any suggestion would help!

DG1209
  • 47
  • 2
  • 6

1 Answers1

4

You can use translate to replace the (escaped) double quote with an empty char.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" 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="translate(., '\&quot;', '')"/>
    </xsl:template>

</xsl:stylesheet>

When used with the identity transform above and a shoutcase XML root element wrapper, this returns:

<XML>
    <ID>7080</ID>
    <NAME>Media</NAME>
    <ADDRESS>
        <STREET_1>400 Street</STREET_1>
    </ADDRESS>
</XML>
StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • Thanks Stuart for the template. It worked very well with the complete XML. I additionally worked for the attributes also like this : – DG1209 Nov 05 '14 at 07:42