[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: calculating pow of numbers and a final sum

Subject: Re: calculating pow of numbers and a final sum
From: "Andreas Mecky" <andreasmecky@xxxxxxxx>
Date: Wed, 22 Jan 2003 12:04:53 +0100
andreas mecky
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.