[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

saving a no-set reference in a varaible

Subject: saving a no-set reference in a varaible
From: Eric Vitiello <xsl-list@xxxxxxxxxxxx>
Date: Thu, 1 Nov 2001 12:34:14 -0500
xsl choose reference
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.