Re: [xsl] Cast variable to node-set

Subject: Re: [xsl] Cast variable to node-set
From: "David B. Bitton" <david@xxxxxxxxxxxxxx>
Date: Wed, 13 Mar 2002 19:20:40 -0500
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.  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"/>


I would prefer to stay away from processor specific extensions.  This
template is used in our application by both MSXML 4.0 and Xalan 2.3.

--

David B. Bitton
david@xxxxxxxxxxxxxx
www.codenoevil.com

Code Made Fresh DailyT

----- Original Message -----
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, March 13, 2002 4:51 PM
Subject: Re: [xsl] Cast variable to node-set


> Hi David,
>
> you can use a processor-specific node-set() extension function to convert
> your result tree fragment to a nodeset. But mostly there are methods to do
> such things XSLT 1.0-standard conform. But for this I have to know a
little
> bit more.
>
> Joerg
>
> ----- Original Message -----
> From: "David B. Bitton" <david@xxxxxxxxxxxxxx>
> To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Wednesday, March 13, 2002 10:26 PM
> Subject: [xsl] Cast variable to node-set
>
> I have a template that I pass a node or node-set to.  Sometimes, I do some
> math prior to sending the data into the
> template.  Once I've done an addition or subtraction, it's no longer a
> node-set, and my template breaks because the
> variable that's passed in must resolve to a node-set.  What can I do?
>
> --
>
> David B. Bitton
> david@xxxxxxxxxxxxxx
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


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


Current Thread