RE: [xsl] resolving variables out of context?

Subject: RE: [xsl] resolving variables out of context?
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Tue, 11 Sep 2001 15:19:05 +0100
> <xsl:if test="@to">
> <xsl:variable name="toID" select="concat('B.', ../@src, '.',
> substring-before(substring-after(@to, 'ID('), ')'))"/>
> </xsl:if>
>
> Is the $toID limited to use *only* within the <xsl:if>?

yes.

>  Is
> there any way to declare it so that it can be used anywhere
> within the <xsl:template match="//xptr"> as a whole?
>
Try:

<xsl:variable name="toID">
   <xsl:if test="@to"><xsl:value-of select="concat('B.', ../@src, '.',
      substring-before(substring-after(@to, 'ID('), ')'))"/>
   </xsl:if>
</xsl:variable>

It's now a result tree fragment rather than a string, but you can use an RTF
to all intents and purposes as it it were a string.

Mike Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread