I have an XML document, something like
<root> <item>_x0034_SOME TEXT</item> <item>SOME_x0020_TEXT</item> <item>SOME_x0020_TEXT_x0032_</item> </root>
I export it to HTML, but I'm having trouble replacing escape characters. I found several patterns on the Internet for replacing text, but they all look like this:
<xsl:template name="replaceString"> <xsl:param name="strOrig"/> <xsl:param name="strSearch"/> <xsl:param name="strReplace"/> <xsl:choose> <xsl:when test="contains($strOrig, $strSearch)"> <xsl:value-of select="substring-before($strOrig, $strSearch)"/> <xsl:value-of select="$strReplace"/> <xsl:call-template name="replaceString"> <xsl:with-param name="strOrig" select="substring-after($strOrig, $strSearch)"/> <xsl:with-param name="strSearch" select="$strSearch"/> <xsl:with-param name="strReplace" select="$strReplace"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$strOrig"/> </xsl:otherwise> </xsl:choose> </xsl:template>
I'm not sure how I can use this to make multiple replacements. I tried this:
<xsl:for-each select="PinnacleSys.PMC.Plugins.PVR.PvrChannelDescriptorWrapper/PinnacleSys.PMC.Plugins.PVR.DVBTPvrChannelDescriptor"> <xsl:variable name="var1" select="Text" /> <xsl:value-of select="replace($FeatureInfo,'Feature=','TESTING')"/> name=" <xsl:call-template name="replaceString"> <xsl:with-param name="strOrig" select="Name"/> <xsl:with-param name="strSearch" select="'_x0020_'"/> <xsl:with-param name="strReplace" select="' '"/> </xsl:call-template> <xsl:call-template name="replaceString"> <xsl:with-param name="strOrig" select="Name"/> <xsl:with-param name="strSearch" select="'_x0030_'"/> <xsl:with-param name="strReplace" select="'0'"/> </xsl:call-template> ..."
But this is just a string concatenation several times, each with a different replacement. I also studied variables; if I could assign the result of calling the template to a variable, I could get a dirty but working solution, which is enough for me. However, I could not and do not know if this is possible.
What is the best way to do this?
I am limited to 1.0 XSLT (with 2.0 I could call one replace () inside another).
raven source share