Subject: RE: RE: [xsl] Finding the lowest 'price' element From: "Macaulay,Malcolm (US)" <Malcolm.Macaulay2@xxxxxxxxx> Date: Sat, 4 May 2002 19:44:37 -0500 |
The XPath says: ..locate the first Book element where the test [Price > other Book/Price] cannot be made true, for any other book. Sorry if that does not explain it well. The > represent ">" and ../ moves the XPath search up one parent. cheers Malcolm -----Original Message----- From: tinku [mailto:amegha1@xxxxxxxxxxxxxx] Sent: 04 May 2002 19:02 To: Macaulay,Malcolm (US) Subject: Re: RE: [xsl] Finding the lowest 'price' element I didn't understand the expression "/Books/book[not(price > ../book/price)]/price"/ you used. Please explain me. Thanks. On Sun, 05 May 2002 Macaulay,Malcolm (US) wrote : >Try this: > >XML: > ><?xml version="1.0" encoding="UTF-8"?> ><Books> > <book> > <price>20</price> > </book> > <book> > <price>10</price> > </book> > <book> > <price>5</price> > </book> > <book> > <price>100</price> > </book> ></Books> > >XSLT: > ><?xml version="1.0" encoding="UTF-8"?> ><xsl:stylesheet version="1.0" >xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:template match="/"> > <xsl:value-of select="/Books/book[not(price > >../book/price)]/price"/> > </xsl:template> ></xsl:stylesheet> > >cheers > >Malcolm > > > >-----Original Message----- > From: tinku [mailto:amegha1@xxxxxxxxxxxxxx] >Sent: 04 May 2002 18:15 >To: >Subject: [xsl] Finding the lowest 'price' element > > >Hi all, > > I have several book elements, in which each book element has >a >'price' child element. > > <book> > <price>20</price> > </book> > <book> > <price>10</price> > </book> > . > . > . > >Now, I need to find the lowest 'price' element using XSLT? > >One solution which i think is: > > 1. first sort the above xml document using <xsl:sort> > > 2. Now we get a new tree with all the price elements in >ascending order. > > 3. Now we will find the first 'price' element which is the >lowest using the "position()" function. > > Here the result tree is again fed with a new stylesheet(to >find >the first position), to the xslt processor. > >Is there any better solution than this? > >Thanks in advance!! >_________________________________________________________ >Click below to visit monsterindia.com and review jobs in India >or >Abroad >http://monsterindia.rediff.com/jobs > > > XSL-List info and archive: >http://www.mulberrytech.com/xsl/xsl-list > _________________________________________________________ Click below to visit monsterindia.com and review jobs in India or Abroad http://monsterindia.rediff.com/jobs XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Finding the lowest 'price, Macaulay,Malcolm (US | Thread | [xsl] Namespaces in XSLT, tinku |
RE: [xsl] Finding the lowest 'price, Macaulay,Malcolm (US | Date | [xsl] Namespaces in XSLT, tinku |
Month |