Subject: Re: Get preceding sibling name issue
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 14 Apr 2008 15:54:12 +0100
|
On 14/04/2008, Don Don <progwihz@xxxxxxxxx> wrote:
> Hi all I am trying to get the last preceding sibiling
> name for the <atext> element using the following xsl
> code
>
>
> The example in senario 1 works but that of senario 2
> dosent work. Anyway I can fix this ? I need to get
> the preceding name of the <atext> element in senario 2
> (which should be spara1)
>
> Cheers
>
> senario 1
> -----------------------------
>
> <xsl:variable name="precedeName" select
> ="(name(./preceding-sibling::apara1 [last()]))" />
> Value: <xsl:value-of select="$precedeName" />
>
> <docg>
> <apara1>xxx<apara1>
> <apara1>xxx<apara1>
> <apara1>xxx<apara1>
> <atext>hello</atext>
> </docg>
>
> senario 2
> -----------------------------
>
> <xsl:variable name="precedeName2" select
> ="(name(./preceding-sibling::spara1 [last()]))" />
> Value: <xsl:value-of select="$precedeName2" />
>
> <docg>
> <apara1>
> <spara1>xxx</spara1>
> <spara1>xxx</spara1>
> <spara1>xxx</spara1>
> <spara1>xxx</spara1>
> <atext>hello</atext>
> <apara1>
> </docg>
Odd examples for 2 reasons:
- You're asking for the name of the element that you've selected by name
- The first and last elements on the preceding-sibling axis have the
same name, so how will your example show that you have selected the
correct element?
Anyway, the likely answer is that the context node in scenario 2 is
different because the elements are a level deeper - they are children
of <apara1> rather than <docg> as in the first example.
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
|