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

RE: XPath: better way to check for text nodes that are

Subject: RE: XPath: better way to check for text nodes that aren't descendents of x or y nodes?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 14 May 2003 19:14:12 +0100
text check
> My requirement is to check for validity of certain XML data 
> as follows: all text() nodes descended from . must be 
> descendants of either llcd:vernac or llcd:gloss. (By the way, 
> if it helps, the llcd:vernac or llcd:gloss will be 
> descendants of . too, not ancestors.)
> 
> My current test is 
>  test=".//text()[not(ancestor::llcd:vernac | ancestor::llcd:gloss)]"
> 
> If this test is true, the data is invalid.
> 
> But is there a more efficient way to do this?

You could try

count(.//text()) = count(.//llcd:vernac//text() | .//llcd:glos//text())

Michael Kay


> Something that checks for llcd:vernac|llcd:gloss along the 
> way, instead of going down the descendant axis and then back 
> up the ancestor axis (twice)?  Something along the lines of
>   test="./(not(llcd:vernac|llcd:gloss)/)*/text()"
> where * means "0 or more times".
> 
> I guess I could do
>  test="count(.//text()) >
>        count(.//llcd:vernac//text() | .//llcd:gloss//text())" 
> but I'm not sure that's any more efficient.
> 
> This is not a big deal, just wanting to be as efficient as 
> reasonably possible.
> 
> Lars
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.