Re: [xsl] Getting variable yet most immediate parentNode

Subject: Re: [xsl] Getting variable yet most immediate parentNode
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 28 Sep 2007 19:21:28 +0200
Wendell Piez wrote:
At 11:56 AM 9/28/2007, Steve wrote:
<!-- Doesn't work. Ignores all @name -->
<xsl:value-of select="(@name|.)[1]" />

This won't work since the current node will always precede any @name attribute in document order. Try select="(.|@name)[last()]" (which adds the value of the @name attribute, if there is one, in preference to the value of the node) or the more explicit (but slightly different)



Indeed, thanks for making that clear to Steve, Wendell. I changed my XSLT 2.0 code (@name, .)[1] to XSLT 1.0 code (@name | .)[1], which is of course too hastily. Using last() is what he needs there.


Cheers,
-- Abel Braaksma

Current Thread