Re: [xsl] how to test previous node name

Subject: Re: [xsl] how to test previous node name
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 12 Feb 2007 11:16:21 +0100
Andrew Welch wrote:

select="parent::test1 or preceding::*[1][self::test1]"


(It could well be that you don't want to check the whole preceding
axis, just the preceding-sibling axis - its worth figuring that out
now based on the examples I've given.)


I am under the (vague) impression that he wants to test the first 'tag' that precedes the current 'tag', not being a closing 'tag'. In terms of nodes, that means, I think, the parent node if the current node is its first child, and the preceding sibling, if the current node is not the first child of its parent.


I.e.:

<test1>
  <test2>
    <item />
....

should return false.

<test1>
  <test2>
     <test1 />
     <text />
     <item />
...

should return true (text is its immediate preceding sibling).

<testX>
  <test1>
     <item />
     <test1 />
     <text />
     <item />
     <item />

should return true for the first and second item node, but false for the third.

Of course, it would be nice to have corrected and cleaned input from 'xslt.new' aka 'ms' aka 'mina' (see http://www.biglist.com/lists/xsl-list/archives/200701/msg00581.html and http://www.biglist.com/lists/xsl-list/archives/200701/msg00580.html). There have been four solutions so far, which each slightly different semantics; could the OP shed some light on what (s)he precisely wants?

-- Abel

Current Thread