xsl-list
[Top] [All Lists]

[xsl] Handling position in non-atomic sequences

2020-05-02 05:52:25
Hi folks,

if a sequence stored in a variable consists of elements, we can not use the 
nice function index-of().

Also, if the variable is typed as="element()*" I cannot use the axes 
preceding-sibling or following-sibling. I can solve that by not typing the 
variable or use  as="document-node()" after adding <xsl:document> to the 
variable's sequence constructor.

My current solution finding the position of the first <h1> in a sequence would 
be something like:

count($seq/h1[1]/preceding-sibling::*) + 1

with $seq being a sequence typed as document-node().

Are there better methods to get the position of a certain element in the 
sequence?

In my scenario I collect a certain set of elements using xsl:copy-of and want 
to process them in the context of that sequence (regarding position) and not in 
the context of their original document location.

Thanks a lot for any pointers,

- Michael
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

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