Re: Pass variables from template to another template

Subject: Re: Pass variables from template to another template
From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx>
Date: Thu, 25 May 2000 17:23:42 +0100
Hi Cheun,

Still worried about the state of your milk?  Dear me ;)

>	Now I have an XSL codes to pass in the expire date (<xsl:param
>name="expire" />) and read the values at the tag <EXPIREDATE>... Now I am
>not sure how to compare two variables, and change the <CONDITION> value?

In the mail I sent you before, I showed you how to compare two variables:

<xsl:if test="$expire > $bb"> ... </xsl:if>

I also talked you through outputting a different CONDITION value on its
basis (remember, you're not *changing* the CONDITION, you're creating a new
XML file that's the same as the first but with a different CONDITION):

  <xsl:when test="$expire > $bb">
    <xsl:copy-of select="CONDITION" />

You're obviously having problems, but I'm not sure you're asking the right
questions.  It would help us to help you if you showed us what the relevant
part of your stylesheet looks like and explain what it is you want it to
give you.  Telling us the various things you've tried would also help us
isolate the source of any misunderstanding you might have. 

>I am not sure
>how to pass the two variables into the <CONDITION> template in XSL.

You can define parameters to be passed to templates in the same way as you
can define parameters to be passed to the stylesheet.  There are two steps:

1. declare within the template that you're passing the parameter into that
you expect a parameter.  You can specify as many parameters as you want,
and you can give them defaults if you like.

<xsl:template match="CONDITION">
  <xsl:param name="expire" />
  <xsl:param name="bb" />

2. when you call or apply that template, make sure that you pass it those
parameters.  This involves using the xsl:with-param element within the
xsl:apply-templates or xsl:call-template element.  The xsl:with-param
element defines a value for the parameter in just the same way as
xsl:variable does.

<xsl:apply-templates select="CONDITION">
  <xsl:with-param name="expire" select="$expire" />
  <xsl:with-param name="bb" select="$bb" />

I hope this helps.



Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email

 XSL-List info and archive:

Current Thread