Subject: RE: [xsl] Need Xpath Question (help). From: "Corey A. Spitzer" <cspitzer@xxxxxxxxx> Date: Tue, 29 Jan 2002 08:46:20 -0600 |
preceding goes all the way up to the first sibling and all of it's children. if you want just first the preceding sibling, do preceding-sibling::node()[1] At 05:51 AM 1/29/02 -0800, you wrote: >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: [xsl] 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 > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Need Xpath Question (help, Michael Kay | Thread | [xsl] include and import descriptio, Khalid |
RE: [xsl] Need Xpath Question (help, Sullivan, Dan | Date | [xsl] page-number-citation, DPawson |
Month |