Subject: Re: calculating pow of numbers and a final sum
From: "Andreas Mecky" <andreasmecky@xxxxxxxx>
Date: Wed, 22 Jan 2003 12:04:53 +0100
|
I have to thank for your input.
The next problem I have is to choose which solution I take ;-)
All of them are working.
Thanx
----- Original Message -----
From: "Francis Norton" <francis@xxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, January 22, 2003 11:34 AM
Subject: Re: calculating pow of numbers and a final sum
> Hi Andreas,
>
> I think that this is one of those occasions wher you do need to use
> recursion - I can't (at this time of morning) see any way of doing it
> with a simple XPath maths expression, or even XPath numeric expressions
> inside a loop.
>
> Try something like this -
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="text"/>
> <!-- case conversion variables -->
> <xsl:variable name="abc">abcdefghijklmnopqrstuvwxyz</xsl:variable>
> <xsl:variable name="ABC">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
> <!-- kick off recursive transform -->
> <xsl:template match="logging">
> <xsl:apply-templates select="target[1]"/>
> </xsl:template>
> <!-- simple tail-end recursive transform -->
> <xsl:template match="target">
> <xsl:param name="base" select="1" />
> public static final int <xsl:value-of select="translate(@name,
> $abc, $ABC)" /> = <xsl:value-of select="$base" />;
> <xsl:apply-templates select="following-sibling::target[1]">
> <xsl:with-param name="base" select="$base * 2" />
> </xsl:apply-templates>
> </xsl:template>
> </xsl:stylesheet>
>
> Using recursion to step through a sequence of elements, one by one, is
> in fact a helpful in many cased where you need to perform arbitrary
> cumulative operations which can't be done using numeric operators,
> sum(), position() or xsl:number, for instance in reports.
>
> Francis.
>
> --
> "Never mind manoeuvre, go straight at 'em." - Admiral Horatio Nelson
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
__________________________________________________________________
Gesendet von Yahoo! Mail - http://mail.yahoo.de
Bis zu 100 MB Speicher bei http://premiummail.yahoo.de
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|