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

RE: Need Xpath Question (help).

Subject: RE: Need Xpath Question (help).
From: "Sullivan, Dan" <dsullivan@xxxxxxxxxxx>
Date: Tue, 29 Jan 2002 05:51:33 -0800
rice krispy.com
Doesn't the preceding axis specifically exclude all ancestors, so
//Price[.='49.95']/preceding::node()
would not include the root anyhow?

Dan

-----Original Message-----
From: Michael Kay [mailto:michael.h.kay@xxxxxxxxxxxx]
Sent: Tuesday, January 29, 2002 4:40 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Need Xpath Question (help).


> > I am looking for the XPath that will :
> >
> >      1) Return the "LineItem" with the lowest Price "in
> each LineItems"
> > (hint:  the parent axis is easier to get working in this
> case than the
> > sibling axes)

If you want a single XPath expression, then:

/Invoices/Invoice/LineItems/LineItem/Price[not(. > ../Price)]

A more efficient approach is likely to be a recursive XSLT template.

> >
> >      2) Select all the text nodes, comment nodes,
> processing instruction
> > nodes, and element nodes that come before the 49.95 Price node,
> >         except the ancestors of that Price node.
> >

//Price[.='49.95']/preceding::node()

This is almost right: it also includes the root node. If you want to get
rid
of the root, add the predicate [generate-id(.)!=generate-id(/)].

Mike Kay


> >
> <?xml version="1.0" encoding="UTF-8"?>
> <Invoices>
> <Invoice ID='1000'>
>  <CustomerName>Jane Smith</CustomerName>
> <LineItems>
>  <LineItem>
>  <Sku>134</Sku>
>  <Description>Dons Boxers</Description>
>   <Price>9.95</Price>
> </LineItem>
> <LineItem>
>  <Sku>153</Sku>
>  <Description>Rice Krispy COM Object</Description>
> <Price>10000.00</Price>
> </LineItem>
>  <LineItem>
> <Sku>72</Sku>
> <Description>Red Vines</Description>
> <Price>4.95</Price></LineItem></LineItems></Invoice>
> <Invoice ID='1010'>
> <CustomerName>Storm Phillips</CustomerName>
> <LineItems>
> <LineItem>
> <Sku>171</Sku>
> <Description>COM is LOVE T-shirt</Description>
> <Price>9.95</Price></LineItem>
> <LineItem>
> <Sku>200</Sku>
> <Description>ATL Internals</Description>
> <Price>49.95</Price></LineItem></LineItems></Invoice>
> <Invoice ID='1020'>
> <CustomerName>John Stockton</CustomerName>
> <LineItems>
> <LineItem>
> <Sku>53</Sku>
> <Description>Caffeinated Beverages</Description>
> <Price>0.50</Price></LineItem>
> <LineItem>
> <Sku>22</Sku>
> <Description>Friday Pizza</Description>
> <Price>0.00</Price></LineItem>
> <LineItem>
> <Sku>201</Sku>
> <Description>MFC Internals</Description>
> <Price>39.95</Price></LineItem></LineItems></Invoice></Invoices>
>
>
>
>
>
>
>   Mitch K. Ragan
>     Boeing Commercial Aircraft Group
>     Global Electronic Commerce
>     Senior Systems Analyst  425-266-3155
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 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.