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

RE: extracting preceding nodes with certain exceptions

Subject: RE: extracting preceding nodes with certain exceptions
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 17 Sep 2003 04:43:10 +0100
ancestor row position last
> 
> Hello all,
>   I need some help with the following:
> I have (but could be variable):
> <tokens>
>     <token position="1"/>
>     <token position="2"/>
>     <token-group>
>          <row>
>              <token position="3"/>
>              <token posistion="4"/>
>           </row>
>           <row>
>               <token position="5"/>
>               <token position="6"/>
>            </row>
>      </token-group>
> </tokens>
> 
> I would like to sum the values of all preceding nodes of 
> <token> #6 that 
> are <token>s, but which are not descendants of the preceding 
> sibling of 
> its ancestor <row>, that is I want to exclude <token>s #3 and 
> #4. 

In XPath 2.0 you can write

preceding::token except ancestor::row/preceding-sibling::token

Unfortunately XPath 1.0 has no direct equivalent of the "except"
operator. Some processors offer the EXSLT set:difference() extension
function or an equivalent, or you can do "A except B" by writing the
rather expensive construct:

  A[count(.|B) != count(B)]

Michael Kay


I have sum(ancestor::row//token[@position &lt; 
> $token-position]) where 
> in this case $token-position = 6, but that excludes the tokens in 
> positions 1 and 2.   I think I am missing something simple here, but 
> suggestions are welcome.
> thanks in advance,
> Matthew L. Avizinis
> Gleim Publications, Inc.
> 
> 
>  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.