Subject: RE: [xsl] How do I process a result-tree fragment? From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Thu, 26 Sep 2002 11:46:56 +0100 |
You need to do: <xsl:template match="*" mode="escape-apos"> .. the identity template .. </xsl:template> <xsl:template match="text()" mode="escape-apos" name="escape-apos"> .. your recursive template .. </xsl:template> <xsl:apply-templates select="xx:node-set($RTF)" mode="escape-apos"/> Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Greg Bender > Sent: 25 September 2002 23:16 > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] 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 > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How do I process a result-tre, Greg Bender | Thread | RE: [xsl] How do I process a result, Andrew Welch |
RE: [xsl] binary-or, Michael Kay | Date | RE: [xsl] Problems rendering nbsp e, Michael Kay |
Month |