[xsl] newbie questions (calculating sums on ranges of values)

Subject: [xsl] newbie questions (calculating sums on ranges of values)
From: "Mazza, Glen" <glen.mazza@xxxxxxx>
Date: Mon, 22 Jan 2001 18:27:31 -0500
Hello, let's say I have an XML showing, for a library, the number of books
that were a given number of days overdue:

<libraries>
	<library name = "City Library">
		<overdue days = "1" count = "15"/>
		<overdue days = "4" count = "2" />
		<overdue days = "5" count = "4" />
		<overdue days = "6" count = "7" />
	</library>
	<library name = "Branch Library #1">
		<overdue days = "2" count = "12" />
		<overdue days = "7" count = "5"  />
		<overdue days = "18" count = "2" />
	</library>
	...
</libraries>

I want to create a three-column HTML table, showing for each library, the
number of books that were 1-4 days overdue and the number of books that were
5 days overdue:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<HTML><BODY>
<table border="border">
<tr><th>Name</th><th>1-4days</th><th>5+ days</th></tr>
<xsl:for-each select="libraries/library">
<tr>
<td><xsl:value-of select="@name"/></td>
<td>WHAT GOES HERE???</td>
<td>WHAT GOES HERE???</td>
</tr>
</xsl:for-each>
</table>
</BODY></HTML>
</xsl:template>
</xsl:stylesheet>

1)  Question:  what is the syntax for the sum where "1 < overdue days < 4"
and "overdue days > 4"?

2)  Also, if I were to break out the count into separate tags (perhaps
because I had other types of overdue information):

<library name = "Branch Library #1">
	<overdue days = "2">
		<count>12</count>
	</overdue>
	<overdue days = "7">
		<count>5</count>
	</overdue>
	<overdue days = "18">
		<count>2</count>
	</overdue>
</library>

How would the syntax in #1 above change?

Thanks,
Glen

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread