|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Finding the lowest 'price' element
> 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?
Here's the solution using FXSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:import href="maximum.xsl"/>
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:call-template name="maximum">
<xsl:with-param name="pList" select="/books/book/price"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the following source xml:
<books>
<book>
<price>20</price>
</book>
<book>
<price>10</price>
</book>
<book>
<price>30</price>
</book>
<book>
<price>15</price>
</book>
</books>
the result is:
30
Cheers,
Dimitre Novatchev.
__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








