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

Re: Need help with parameters and Indexes

Subject: Re: Need help with parameters and Indexes
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 27 Feb 2001 17:45:00 +0000
help with parameters
Hi Daniel,

> In my code you'll notice I pass the parameter $count. Now this is
> either 1 or 2. When I run this transformation, I always get the
> result of ANNUALFORECAST[1]/ESTIMATEDATA, even though when I print
> the value of $count on the page, the first time it's 1, and the
> second time it's 2. Also, if I manually ask for
> ANNUALFORECAST[2]/ESTIMATEDATA, I get it. So, why aren't the indexes
> responding to the value I'm asking for? Do you have to change the
> data type of $count or something?

When you put $count in a predicate, then it will be interpreted as a
boolean unless it's a number.

I bet that you're setting your parameter with:

  <xsl:with-param name="count">2</xsl:with-param>

or:

  <xsl:with-param name="count">
     <xsl:value-of select="..." />
  </xsl:with-param>

In these cases, the parameter $count is set to a result tree fragment.
When you test an RTF in a boolean context, it always returns true
(because it always has a root node).  So if you've set the value as
above then:

  ANNUALFORECAST[$count]

will always select all the ANNUALFORECAST children of the current
node.  If you take the *value* of this node set, then you get the
string value of the *first* node in it - the first ANNUALFORECAST
child.  So you get the same result whatever value you give $count.

Two ways around it: you can convert $count to a number explicitly
with:

  ANNUALFORECAST[number($count)]

and it will be interpreted as a position.

Or you can pass the parameter value using the select attribute, such
as:

  <xsl:with-param name="count" select="2" />

or:

  <xsl:with-param name="count" select="..." />

where ... is whatever you had in your xsl:value-of.

But be aware with either of the two above that the value *has* to
evaluate to a number to get it to work.  It's no good producing a
string or node set value, for example.
  
I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.