This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

saving a no-set reference in a varaible


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]