Subject: Re: [xsl] Pattern question: first child of first descendant From: "Christian Roth" <roth@xxxxxxxxxxxxxx> Date: Tue, 24 Mar 2009 17:45:17 +0100 |
>>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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Pattern question: first c, Wendell Piez | Thread | Re: [xsl] Pattern question: first c, Wendell Piez |
Re: [xsl] Identity Tranlate, too ma, Karl Stubsjoen | Date | [xsl] Compound filter in for-each, Alan Hale |
Month |