This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
saving a no-set reference in a varaible
- To: xsl-list <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] saving a no-set reference in a varaible
- From: Eric Vitiello <xsl-list at perceive dot net>
- Date: Thu, 1 Nov 2001 12:34:14 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi -
I have a situation where sometimes I need to get a piece of information from the XML that the XSL is currently parsing, and sometimes I need to get it from another document.
I currently decide where to get it from using an xsl:choose each time I need data, however, it would be much more efficient if I could save the correct node-set into a variable.
to give you a better idea, currently I do:
<xsl:choose>
<!-- check to see if we're in the same tree -->
<xsl:when test="/family-tree/@id = $persontree">
<b><xsl:value-of select="id($personid)/name/@first"/></b>
</xsl:when>
<xsl:otherwise>
<b><xsl:value-of select="document($persontree,/)/family-tree/person[@id=$personid]/name/@first"/></b>
<xsl:otherwise>
</xsl:choose>
I would rather it be something like
<xsl:variable name="thisNode">
<xsl:choose>
<!-- check to see if we're in the same tree -->
<xsl:when test="/family-tree/@id = $persontree">
<xsl:value-of select="id($personid)/name/@first"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="document($persontree,/)/family-tree/person[@id=$personid]/name/@first"/>
<xsl:otherwise>
</xsl:choose>
</xsl:variable>
<b><xsl:value-of select="$thisNode/name/@first"/></b>
is this possible? it would greatly help - currently every time I need some info, I have to determine where to get it from. too much code.
I have tried the code above for creating the variable, but I can't get it to work. what am I doing wrong?
-Eric
perceive designs
<www.perceive.net>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list