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

Re: Xalan equivalent for <msxsl:script>?

Subject: Re: Xalan equivalent for <msxsl:script>?
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 14 Feb 2001 12:51:14 +0000
xalan msxsl script
Hi Glen,

> 1) As a sanity check, is this pretty much the way to calculate the
> largest value in a list? Is there any quick XPath/XSLT instruction
> that would do the same thing without me needing to resort to
> functions or recursion?

Two ways. An XPath expression that only selects a book if there are no
other books that have a higher cost, and gets the cost of that one:

  <xsl:value-of select="book[not(../book/cost &gt; cost)]/cost" />

And a loop that only uses the first value from the sorted list:

  <xsl:for-each select="book">
     <xsl:sort select="cost" data-type="number" order="descending" />
     <xsl:if test="position() = 1">
        <xsl:value-of select="cost" />
     </xsl:if>
  </xsl:for-each>

If you only have a few books per author, then the first is nice and
simple.  If you have more, then the for each with the sort is more
efficient.  If you have lots then recursion or a function like you
have will be best.  Don't ask me what 'few', 'more' and 'lots' mean -
you should try it out with your particular source XML to see what
gives the best performance.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.