[xsl] XPath: following sibling/cousin n-times removed??

Subject: [xsl] XPath: following sibling/cousin n-times removed??
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Wed, 14 May 2003 15:17:42 -0500
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


Current Thread