I am trying to filter out problem characters (quotes and slashes) while doing an XSLT translation but am unable to actually remove them. I've tried several proposed solutions here and they have been unsuccessful:
Replace special characters in XSLT
XSL: replace single and double quotes with ' and "
I would ideally like to replace the characters with some kind of marked word, like quotes or slash, but at this point I'd be fine just stripping them out for now.
I'm only running it on a couple selects, so it shouldn't be that hard. I'm not sure what is going wrong.
<xsl:value-of select="ns3:stepTitle"/>
EDIT:
Need to use XML 1.0.
XSLT:
<?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(., '\"', '*quote*')"/>
</xsl:template>
</xsl:stylesheet>
XML:
<test>
I need to remove "quotes" and slashes /\ from here.
</test>
The result was:
<?xml version="1.0" encoding="UTF-16"?>
<test>
I need to remove qquotesq and slashes /* from here.
</test>