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

RE: How to specify document order location path for id

Subject: RE: How to specify document order location path for identical elements with different parents?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 2 Apr 2004 21:29:39 +0100
help id document path
> -----Original Message-----
> From: Alan Stein [mailto:as@xxxxxxxxxxx] 
> Sent: 02 April 2004 19:38
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  How to specify document order location path 
> for identical elements with different parents?
> 
> Thanks much for the help with my previous posting. 
> 
> I think I've better articulated my question in the following example:
> 
> Given the following XML:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <reportlist>
>     <report>
>         <codelist>
>             <code type="a"/>
>         </codelist>
>         <codelist>
>             <code type="b"/>
>             <code type="c"/>
>         </codelist>
>     </report>
>     <report>
>         <codelist>
>             <code type="a"/>
>             <code type="b"/>
>         </codelist>
>         <codelist>
>             <code type="a"/>
>         </codelist>
>     </report>
>     <report>
>         <codelist>
>             <code type="z"/>
>             <code type="a"/>
>             <code type="d"/>
>         </codelist>
>     </report>
>     <report>
>         <codelist>
>             <code type="a"/>
>             <code type="e"/>
>             <code type="f"/>
>         </codelist>
>     </report>
>     <report>
>         <codelist>
>             <code type="e"/>
>         </codelist>
>     </report>
> </reportlist>
> 
> 
> How do I perform the following queries?
> 
> 1)  What is the number of reports which are coded with either 
> an "a" or 
> "b" where the last "a" or "b" code of the report (in document 
> order) is 
> an "a"?
> 
> (correct number is 3.  Yes, this has been double checked.)

count(report[(.//code[@type="a" or @type="b")][last()][@type="a"]])
> 
> 
> 2)  What is the number of reports which are coded with either 
> an "a" or 
> "b" where the last "a" or "b" code of the report (in document 
> order) is 
> a "b".
> 
> (correct number is 1.  Yes, this has been double-checked.)

count(report[(.//code[@type="a" or @type="b")][last()][@type="b"]])

Not tested.

Michael Kay

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.