xsl-list
[Top] [All Lists]

Re: [xsl] Get preceding sibling name issue

2008-04-14 07:54:37
On 14/04/2008, Don Don <progwihz(_at_)yahoo(_dot_)com> 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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>