Subject: [xsl] How do I process a result-tree fragment? From: "Greg Bender" <greg@xxxxxxxxxxxxxxxxxx> Date: Wed, 25 Sep 2002 17:16:18 -0500 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Hitting the same node wit, David Carlisle | Thread | RE: [xsl] How do I process a result, Michael Kay |
[xsl] Hitting the same node with tw, Richard Rowell | Date | Re: [xsl] Partial Implementation of, Jeni Tennison |
Month |