RE: [xsl] Parameter problem

Subject: RE: [xsl] Parameter problem
From: Americo Albuquerque <melinor@xxxxxxxx>
Date: Thu, 2 Oct 2003 18:04:35 +0100

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Marsha Salo
> Sent: Thursday, October 02, 2003 4:12 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Parameter problem
> Hi Michael
> >Does $firstN have a value in the PartyList/When [1] template?
>  yes.
> >Is the PartyList/When [last()] template actually being called?
>  yes.
> >If so, something very odd is going on. Tell us which 
> processor you are 
> >using, and post a complete stylesheet + source document so 
> we can debug 
> >it for you.
> 	 I am using MSXML not sure about the processor. If i 
> have an xml parser do i automatically have a processor aswell?
> 	I am using xmlSpy to step through the transformation 
> process. At the bottom of this mail is the html output i am getting.

The problem is not the param but where it is passed

On the <xsl:template match="PartyList"> template
You have <xsl:apply-templates select="When[@Attendance]">
This will select ALL <When> elements with a @Attendance attribute

In your <xsl:template match="PartyList/When[1]"> template you allso have
A <xsl:apply-templates select="following-sibling::When [last()]">
This will select the last following-sibling::When element

In the output you'll have:
 When[1] - firstN set
 When[last] - firstN set
 When[last] - firstN not set - this one is selected in the PartyList
template and, as sush, doesn't have the param set

You could set the parameter in the PartyList templates like:
  <xsl:apply-templates select="When[@Attendance]">
    <xsl:sort data-type="number" order="ascending"
    <xsl:with-param name="first" select="When[1]/@Attendance"/>

Or you can change the select so you only select the first When like:
  <xsl:apply-templates select="When[@Attendance][1]">
    <xsl:sort data-type="number" order="ascending"
And let the When[1] template call the last one

Americo Albuquerque

 XSL-List info and archive:

Current Thread