Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Get minimum value for nodes with a given attribute value [Thread Next] Re: Get minimum value for nodes with a given attribute valueTo: NULL Date: 1/4/2007 8:48:00 AM That is great Martin - thanks very much. Really appreciate it. Regards Darren Martin Honnen wrote: > Darren.Ratcliffe@g... wrote: > > > If my xml were structured like this: > > > > <hotels> > > <hotel rating="2*" price="123.00" /> > > <hotel rating="2*" price="125.00" /> > > <hotel rating="1*" price="100.00" /> > > <hotel rating="4*" price="180.00" /> > > </hotels> > > Here is an example, the XML > <http://home.arcor.de/martin.honnen/xslt/test2007010201.xml> > the stylesheet showing two different ways to find the minimum: > <http://home.arcor.de/martin.honnen/xslt/test2007010201Xsl.xml> > One way is as already suggested to sort with xsl:sort on @price and to > output only the first element in the sort. > The other way uses an XPath alike > /hotels/hotel[@rating = '2*][not(@price > /hotels/hotel[@rating = > '2*]/@price])]/@price > > You might also want to look into > <http://www.exslt.org/math/functions/min/index.html> > the EXSLT implementation of a math:min template (and math:min extension > function). > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
