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

Parameter problem

Subject: Parameter problem
From: "Marsha Salo" <Marsha@xxxxxxxxxxxxx>
Date: Thu, 2 Oct 2003 12:47:35 +0200
xsl parameter
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 [@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


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.