Subject: Re: [xsl] Cast variable to node-set From: "David B. Bitton" <david@xxxxxxxxxxxxxx> Date: Fri, 15 Mar 2002 13:51:21 -0500 |
Jeni, Some how, it started working. I think it was case of I was editing the wrong file. As for setting those values as xsl:param's, it just gives me some flexibility if I need to pass them in manually. Thanks. On Fri, Mar 15, 2002 at 06:39:33PM +0000, Jeni Tennison wrote: > Hi David, > > > Ok, here is a sample of what's going on (a bit dumbed down for brevity): > > > > <xsl:variable name="cr_amt" > > select="/Transactions/Transaction/CreditAmount"/> > > <xsl:variable name="cr_under_amt" select="MinAmt/CRUnderMinAmt"/> > > > > <td style="text-align:right;"> > > <xsl:call-template name="displaycurrency"> > > <xsl:with-param name="node" select="$cr_amt + $cr_under_amt"/> > > <xsl:with-param name="total">1</xsl:with-param> > > </xsl:call-template> > > </td> > > > > Then inside "displaycurrency": > > > > <xsl:variable name="output"> > > <xsl:value-of select="sum($node)"/> > > </xsl:variable> > > > > The $total xsl:param tells the template to prepend the currency code > > to the value (we only show currency code for totals). The reason for > > the sum() is that I can pass either a single node or a node-set. I > > always want to sum a node-set that is passed to the template. I > > tried this: > > > > select="$cr_amt | $cr_under_amt" > > > > But that didn't work. > > Hmm... that's weird. If the call looks like: > > <xsl:call-template name="displaycurrency"> > <xsl:with-param name="node" select="$cr_amt | $cr_under_amt"/> > <xsl:with-param name="total">1</xsl:with-param> > </xsl:call-template> > > then assuming that $cr_amt and $cr_under_amt are node sets containing > CreditAmount and CRUnderMinAmt elements as you've said, the $node > parameter should be a node set and the sum($node) function should > provide you with the sum of those nodes. > > In what way didn't it work? Did you get an error message, or just not > the result that you expected to see? > > > Also, there is one additional requirement, when I pass a node into > > the template like this: > > > > <td align="right"> > > <xsl:call-template name="displaycurrency"> > > <xsl:with-param name="node" select="$cr_under_amt"/> > > <xsl:with-param name="total">1</xsl:with-param> > > </xsl:call-template> > > </td> > > > > The node has two attributes, @currency_code and @minor_unit (you've > > seen these in my last thread). What are the chances of getting them > > into the template without using seperate params? I have them set as > > xsl:param's now: > > > > <xsl:param name="currency_code" select="$node/@currency_code"/> > > <xsl:param name="minor_unit" select="$node/@minor_unit"/> > > You don't need to set those as parameters -- just use normal > variables. You're passing the node itself, so you can do anything to > it you can normally do - get its attributes, children, ancestors, > whatever you need. > > Cheers, > > Jeni > > --- > Jeni Tennison > http://www.jenitennison.com/ -- David B. Bitton david@xxxxxxxxxxxxxx Diversa ab illis virtute valemus.
Attachment:
pgp00003.pgp
Description: PGP signature
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Cast variable to node-set, Jeni Tennison | Thread | [xsl] EXSLT in ASP.NET?, Jonathan C. Dietrich |
Re: [xsl] xsl:with-param, Jeni Tennison | Date | Re: [xsl] node-id set <-> result do, Jeni Tennison |
Month |