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

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
hall pass templates
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:choose>
  <xsl:when test="$expire > $bb">
    <CONDITION>expired</CONDITION>
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="CONDITION" />
  </xsl:otherwise>
</xsl:choose>

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" />
  ...
</xsl:template>

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" />
</xsl:apply-templates>

I hope this helps.

Cheers,

Jeni

Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email
jeni.tennison@xxxxxxxxxxxxxxxx



 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.