xsl-list
[Top] [All Lists]

RE: [xsl] Matching the first text element in a subtree

2006-04-19 00:18:20
 
oXygen complains that "Axis in pattern must be child or 
attribute", meaning presumably that only element nodes, not 
text nodes, can be selected using this axis. 

No, it means what it says. You can use "//" in a pattern, but you can't use
the descendant axis, or any axis other than "child" or "attribute". It's an
irritating restriction when you hit it, but it doesn't come up sufficiently
often to have been fixed in 2.0.


Can anyone suggest how to go about selecting the first text 
node which is a descendant of the p tag?

In 2.0:

p//text()[. is ancestor::p[1]/descendant::text()[1]]

In 1.0:

p//text()[generate-id(.) =
generate-id(ancestor::p[1]/descendant::text()[1])]

But most people, I think, end up doing the work at the apply-templates level
rather than in the match pattern.

Michael Kay
http://www.saxonica.com/


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