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

Xalan equivalent for <msxsl:script>?

Subject: Xalan equivalent for <msxsl:script>?
From: "Mazza, Glen" <glen.mazza@xxxxxxx>
Date: Mon, 12 Feb 2001 18:30:16 -0500
ex msxsl xslt.process
Hello,

Given an XML of authors and their books:

<authors>
	<author name="Author1">
		<books>
			<book title="Book#1">
				<cost>12.00</cost>
			</book>
			<book title="Book#2">
				<cost>21.00</cost>
			</book>
			<book title="Book#3">
				<cost>18.00</cost>
			</book>
		</books>
	</author>
	<author name="Author2">
	...
	</author>
</authors>

I wish to identify the most expensive book of each author.  I've seen the
recursion example (#11 in http://www.dpawson.co.uk/xsl/N8090.html) in the
FAQ, but to avoid recursion, I used a msxml:script function:

<msxsl:script implements-prefix="user">
<![CDATA[
    function mostExpensive(e) 
	{
	  	var maxVal = 0;
		var bookCost = 0;
		var node = e.nextNode();

		while (node != null) 
		{
		   bookCost = parseInt(node.selectSingleNode("cost").text);
		   if (bookCost > maxVal)
			  maxVal = bookCost;
	       node = e.nextNode();
		} 
		return maxVal;
	}
]]>
</msxsl:script>

My code above works fine:

<td align = "right"><xsl:value-of
select="user:mostExpensive(./books/book)"/></td>


Two questions here:

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?

2)  I would like to move my XSL to a Java application, using Xalan to take
my XML and XSL and output HTML.  But the <msxsl:script> tag is
Microsoft-specific.  Is there a Xalan equivalent for XSLT-process-time
<msxsl:script>?  I'm just starting to learn Xalan, so if you can just give
me a pointer of where I need to look in its documentation, it would be
appreciated.

Thanks,
Glen Mazza

 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.