This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cast variable to node-set



--GID0FwUMdk1T2AWN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Jeni,
	Some how, it started working.  I think it was case of I was editing the wr=
ong 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,
>=20
> > Ok, here is a sample of what's going on (a bit dumbed down for brevity):
> >
> > <xsl:variable name=3D"cr_amt"
> > select=3D"/Transactions/Transaction/CreditAmount"/>
> > <xsl:variable name=3D"cr_under_amt" select=3D"MinAmt/CRUnderMinAmt"/>
> >
> > <td style=3D"text-align:right;">
> >     <xsl:call-template name=3D"displaycurrency">
> >         <xsl:with-param name=3D"node" select=3D"$cr_amt + $cr_under_amt=
"/>
> >         <xsl:with-param name=3D"total">1</xsl:with-param>
> >     </xsl:call-template>
> > </td>
> >
> > Then inside "displaycurrency":
> >
> > <xsl:variable name=3D"output">
> >     <xsl:value-of select=3D"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=3D"$cr_amt | $cr_under_amt"
> >
> > But that didn't work.
>=20
> Hmm... that's weird. If the call looks like:
>=20
>   <xsl:call-template name=3D"displaycurrency">
>     <xsl:with-param name=3D"node" select=3D"$cr_amt | $cr_under_amt"/>
>     <xsl:with-param name=3D"total">1</xsl:with-param>
>   </xsl:call-template>
>=20
> 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.
>=20
> In what way didn't it work? Did you get an error message, or just not
> the result that you expected to see?
>=20
> > Also, there is one additional requirement, when I pass a node into
> > the template like this:
> >
> > <td align=3D"right">
> >     <xsl:call-template name=3D"displaycurrency">
> >         <xsl:with-param name=3D"node" select=3D"$cr_under_amt"/>
> >         <xsl:with-param name=3D"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=3D"currency_code" select=3D"$node/@currency_code"/>
> > <xsl:param name=3D"minor_unit" select=3D"$node/@minor_unit"/>
>=20
> 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.
>=20
> Cheers,
>=20
> Jeni
>=20
> ---
> Jeni Tennison
> http://www.jenitennison.com/

--=20

David B. Bitton
david@codenoevil.com

Diversa ab illis virtute valemus.

--GID0FwUMdk1T2AWN
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8kkKpMNOMzNRRk50RAgWiAJ4jb5KD3VZO9PTyck/EGaGVTaeqoACgizfq
Qqct+29iZDOlp5epnY0ALkM=
=HOiM
-----END PGP SIGNATURE-----

--GID0FwUMdk1T2AWN--

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]