HI
I am trying to calculate the difference between the first and last
elements in a node set.
In the template PartyList/When[1] i have declared a global variable
firstN, and i am passing it as a parameter to the template
PartyList/When[last()].
The problem; in the template PartyList/When[last], the parameter
(first) does not have a value associated with it.
My xml file:
<PartyTime>
<PartyListType="Energy">
<When DateTime="Thursday 12 November 2002 11:51"
Attendance="50"/>
<When DateTime="Thursday 09 November 2002 11:53"
Attendance="51"/>
<When DateTime="Thursday 28 November 2002 11:58"
Attendance="56"/>
<When DateTime="Thursday 30 November 2002 16:55"
Attendance="57"/>
</PartyList>
</PartyTime>
Mt xsl file:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Party List</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="party.css"
/>
</HEAD>
<BODY>
<H1>Party Report</H1>
<H3>From <xsl:value-of select="//DateFrom"/> To
<xsl:value-of select="//DateTo"/></H3>
<H3></H3>
<xsl:apply-templates />
</BODY>
</HTML>
</xsl:template>
<xsl:template match="PartyList">
<H3>PartyList</H3>
<xsl:apply-templates select="When [(_at_)Attendance]">
<xsl:sort select="@Attendance" order="ascending"
data-type="number"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="PartyList/When [last()]">
<xsl:param name = "first"/>
<xsl:param name = "last"><xsl:value-of
select="@Attendance"/></xsl:param>
<xsl:variable name="difference"><xsl:value-of select = "$last -
$first"/></xsl:variable>
<TD><xsl:value-of select="$first"/></TD>
<TD><xsl:value-of select="$last"/></TD>
<TD><xsl:value-of select="$difference"/></TD>
</xsl:template>
<xsl:template match="PartyList/When [1]">
<xsl:variable name="firstN"><xsl:value-of
select="@Attendance"/></xsl:variable>
<TD><xsl:value-of select="$firstN"/></TD> <!-- I included
this to test if the variable has a value - and it does-->
<xsl:apply-templates select="PartyList/When [last()]">
<xsl:with-param name="first"><xsl:copy-of
select="$firstN"/></xsl:with-param>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
I know there are many parameter problems in the list, but can't seem to
find the answer.
Any help would be much appreciated.
Kind Regards
marsha
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list