[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How do I process a result-tree fragment?
Currently I am using the following procedure (acquired from http://www.jenitennison.com) to escape apostrophe characters (I need to do this in order to place the resulting information in javascript): <xsl:template name="escape-apos"> <xsl:param name="string" /> <!-- create an $apos variable to make it easier to refer to --> <xsl:variable name="apos" select='"'"' /> <xsl:choose> <!-- if the string contains an apostrophe... --> <xsl:when test='contains($string, $apos)'> <!-- ... give the value before the apostrophe... --> <xsl:value-of select="substring-before($string, $apos)" /> <!-- ... the escaped apostrophe ... --> <xsl:text>\'</xsl:text> <!-- ... and the result of applying the template to the string after the apostrophe --> <xsl:call-template name="escape-apos"> <xsl:with-param name="string" select="substring-after($string, $apos)" /> </xsl:call-template> </xsl:when> <!-- otherwise... --> <xsl:otherwise> <!-- ... just give the value of the string --> <xsl:value-of select="$string" /> </xsl:otherwise> </xsl:choose> </xsl:template> This method works great when I pass it a string. However, when I pass it a result-tree fragment, I loose the mark-up language. For example: If I pass "<div><b>these word's are bold.</b></div>" I get "These word\'s are bold." When what I want is "<div><b>these word\'s are bold.</b></div>" I've tried replacing the 'xsl:value-of' commands with 'xsl:copy-of' commands. This solution works if the result-tree fragment doesn't contain any apostrophes (it just passes the variable through). However, when the result-tree fragment contains apostrophes, I loose the result-tree fragment. I think the contains(), substring-before(), and/or substring-after() statements are converting the result-tree fragment to a string. Any help is appreciated. Regards, Greg Bender XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|