[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: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Wed, 14 May 2003 13:20:07 -0400
RE:  XPath: better way to check for text nodes that are
[ Lars Huttar]

> But is there a more efficient way to do this?
> 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".
> 

You could use

test='not(.//*[local-name() != "vernac" and local-name() !=
"gloss"]/text()[1]
		| text())'

or

test='count(.//*[local-name() != "vernac" and local-name() !=
"gloss"]/text()[1]
		| text()) > 0'

These might be more efficient because you do not bother to examine
elements that will not cause a false result, and of the ones that are
examined, you only have to look at one text node.

Whatever expression you use, remember to use 

<xsl:strip-space elements='*'/>

Otherwise you will be counting whitespace-only nodes between elements,
which you most likely do not intend.

Cheers,

Tom P

 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.