|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XPath: following sibling/cousin n-times removed??
Hi all,
I have another XPath efficiency question.
Sample XML data:
<llcd:word>
<llcd:morpheme>1</llcd:morpheme>
<llcd:stretch><llcd:morpheme>2</llcd:morpheme></llcd:stretch>
<llcd:stretch>
<llcd:stretch><llcd:morpheme>3</llcd:morpheme></llcd:stretch>
<llcd:morpheme>4</llcd:morpheme>
</llcd:stretch>
</llcd:word>
<llcd:word>
<llcd:morpheme>5</llcd:morpheme>
</llcd:word>
What I want to do: when the current node is a morpheme, I want to
test whether it is the last morpheme in the current word or not.
As you can see, morphemes are always contained by words, though
perhaps not directly. There can be intervening container elements
such as "stretch".
Incidentally words do not have words as ancestors (but words can be
contained in stretches).
To make a long story short, words contain morphemes, but stretches
can intervene at any and every level.
My current test is:
"following::llcd:morpheme[1][generate-id(ancestor::llcd:word) =
generate-id(current()/ancestor::llcd:word[1])]"
This will be true if the current node (a morpheme) is not the last
morpheme in its word.
The question is, is there a better way? (Clearer or more efficient?)
Again, this is not a big deal, because I think I have a working expression.
Ideas are appreciated though.
Thanks,
Lars
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








