This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Convert the sign of a number
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Convert the sign of a number
- From: "Daniel Newman" <daniel dot newman at bis-web dot net>
- Date: Thu, 5 Jul 2001 11:59:19 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
I've been doing some research into how to do what I want in ASP, but not
sure if this is possible in XSL.
I'm going to need to have a recursive template, that is passed a
transaction, and the previous balance.
Now lets assume I do this in VBscript, and I'll run through what each thing
does.
sub PrintDetails(transaction, balance)
'// print some stuff in here
Response.write transaction 'print out this transaction
Response.write balance 'print out the balance
'Move to next Node(), and if it exists, perform recursion.
Call PrintDetails(nextTransaction, balance + convertSign(balance))
end sub
function convertSign(balance)
dim sign
sign = sgn(balance) '1 indicates positive, -1 indicates negative
if sign = 1 then
convertSign = "-" & balance '// make this positive number a negative
number
elseif sign = -1 then
convertSign = Abs(balance) '// make this negative number a positive
number. Abs removes the - element.
end if
end function
It's a bit messy, but the idea is sound. Transaction will be a number,
preceded by a - if it's a negative. As I'm starting with the most recent
transaction at the top, I need the balance to be calculated (it's not in the
XML!!!) based on the money in or out.
-57,500 0
+40,000 57,500
-14,000 17,500
-7,500 31,500
+2,000 39,000
+25,000 37,000
+12,000 12,000
within the XML will be each of the transactions, and also the most recent
balance.
<RetrieveTransactionHistory2RSResponse>
<Result>0</Result>
<NoOfItems>2</NoOfItems>
<CurrentBalance>0</CurrentBalance> <-- I'll need to add this, but assume it
will be here!!!
<Items>
<Item id="1">
<TradeReference>27799G6381</TradeReference>
<Date>03081999</Date>
<ClassCode>ORD</ClassCode>
<Description>CREST STOCK DEPOSIT</Description>
<FromToFlag>F</FromToFlag>
<RunNumber>135</RunNumber>
<TransTypeCode>RGSTD</TransTypeCode>
<Certificate>00037438</Certificate>
<Register>GBR</Register>
<TransferNumber>900006</TransferNumber>
<UnitsTraded>-00000001000</UnitsTraded>
<MoneyTrade>0</MoneyTrade>
<BrokerCode>277</BrokerCode>
<TradeHolderIdentifier>G0100033241</TradeHolderIdentifier>
<SerialDate>36375</SerialDate>
</Item>
</Items>
</RetrieveTransactionHistory2RSResponse>
So first off, I know the transaction was to sell 57,500 shares, and my
balance is now nothing. So my previous balance must have been 0 + 57,500. So
I need to turn -57,500 into +57,500. Is this possible using XSL? I hope so,
otherwise I'm going to have to use ASP to create this html code :-(
Thanks if you can help.
Daniel Newman.
Bis-Web Ltd.
Tel: 01993 880614
Fax: 01993 881625
****************************************************************************
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the
material from any computer.
****************************************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list