[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Matching the first text element in a subtree

Subject: Re: Matching the first text element in a subtree
From: Martin Holmes <mholmes@xxxxxxx>
Date: Wed, 19 Apr 2006 16:14:11 -0700
martin holmes
Michael Kay wrote:
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.

What a strange restriction. I wonder what the reasoning behind it is.


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])]

That works great -- it's exactly what I need. The whitespace issue isn't a problem -- I stupidly pretty-printed my example without thinking, trying to clarify the structure, but the original documents are clean.

Thanks to everyone for the helpful suggestions.

Cheers,
Martin

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/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.