xsl-list
[Top] [All Lists]

RE: RE: RE: Setting values for variable

2004-09-10 09:16:07
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />

  <xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="Trade">
    <xsl:variable name="R-type-with-Payment" 
select="sum(Record[Account='R']/Payment)" />
    <xsl:variable name="I-type-with-Payment" 
select="sum(Record[Account='I']/Payment)" />
    <xsl:variable name="R-type-without-Payment" 
select="sum(Record[Account='R'][not(Payment)]/Balance) * 0.02" />
    <xsl:variable name="I-type-without-Payment" 
select="sum(Record[Account='I'][not(Payment)]/Balance) * 0.02" />
    <xsl:text>
    </xsl:text>
    R Account totals: <xsl:value-of select="$R-type-with-Payment + 
$R-type-without-Payment" />
    <xsl:text>
    </xsl:text>
    I Account totals: <xsl:value-of select="$I-type-with-Payment + 
$I-type-without-Payment" />
  </xsl:template>

</xsl:stylesheet>
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     john lee <excel_man(_at_)hotmail(_dot_)com>
Sent:     Fri, 10 Sep 2004 15:47:02 +0000
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  RE: RE: [xsl] Setting values for variable

Thanks for all the replies.
This is my situation:

<Trade>
<Record>
<Account>R</Account>
<Payment>10000</Payment>
<Balance>50000</Balance>
</Record>
<Record>
<Account>R</Account>
<Balance>40000</Balance>
</Record>
<Record>
<Account>I</Account>
<Payment>5000</Payment>
<Balance>50000</Balance>
</Record>
<Record>
<Account>I</Account>
<Balance>50000</Balance>
</Record>
</Trade>

I need to run the total based on the account Type. If there is <Payment> Tag 
coming back, I'll calculate the total based on the payment, but if there 
isnt, I will substitute the amount with 2% of the value in the <Balance>. So 
I need to go into all the Record, look to see if there is Payment tag coming 
back. If yes, use it. If no, use 2% of the Balance value.
Anybody can help me with this problem ?

Thanks

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--