xsl-list
[Top] [All Lists]

Re: [xsl] Pattern question: first child of first descendant

2009-03-24 12:45:46
match="entry[. is
ancestor::table[1]/descendant::entry[1]]/*[self::title|self::para][1]"

This will match the first title or para child of a first entry
descendant of a table, but if you have

<entry>
  <label/>
  <title/>
  <para/>
</entry>

the title will be matched.

I think the spec needs a bit of clarification. :-)

Sorry for being imprecise, the intent is to match the first title or
para in a cell, whichever comes first. It doesn't matter whether there
are other elements before it (label in your example).

But actually, that part was not the most difficult part - I had the
difficulties in matching only the first descendant in document order of
some other element.

I'm not answering to the many helpful posts on this individually.
Andrew's link on "//" was very interesting (the gotcha would have resp.
has got me for sure). I'll try to summarize the idea behind the solution:

1. Patterns are limited. If you cannot do it directly, shove the logic
into predicates.

2. In the predicate, use the ancestor axis to "go back" to the element
you wanted to start from originally, then formulate your path as you
would have done without patterns' limitations and check for node
identity on the target.

Hope I got that sufficiently right, though it reads not much clearer :-
( Another try:

Instead of

  match="anchor/unsupported_pathspec_to/target"

use

  match="target[. is pathspec_to/anchor/unsupported_pathspec_to/target]"

-Christian


--~------------------------------------------------------------------
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>
--~--