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

Re: Recursion performance (fibonacci numbers)

Subject: Re: Recursion performance (fibonacci numbers)
From: omprakash.v@xxxxxxxxxxxxx
Date: Tue, 17 Jan 2006 11:47:57 +0530
fibonacci with recursion
Hi,
           Is your question related to the below thread? If not, you need
to go through the XSL list guidelines. You need to start a new thread when
you want to ask a new question.

Having said that, an XSL stylesheet is plain text and hence is not
executable by itself. But if you have a XSLT processor like saxon, xalan
etc, they can load your stylesheet and execute them for you. The command to
execute under each processor is as follows:

saxon 6.5:
java com.icl.saxon.StyleSheet [options] source-doc style-doc
{param=value}... > xslt.out

xalan 2.9
java com.sun.org.apache.xalan.internal.xslt.Process -IN  infile.xml -XSL
infile.xsl -OUT outfile


You would need to have the relevant jars in your classpath before you can
run your commands though.

Hope this helps.

cheers,
prakash












                                                                                                                                       
                      jeb501@sanmargro                                                                                                 
                      up.com                   To:      xsl-list@xxxxxxxxxxxxxxxxxxxxxx                                                
                                               cc:      (bcc: omprakash.v/Polaris)                                                     
                      01/17/2006 09:31         Subject: Re:  Recursion performance (fibonacci numbers)                            
                      AM                                                                                                               
                      Please respond                                                                                                   
                      to xsl-list                                                                                                      
                                                                                                                                       
                                                                                                                                       




Hi all,

Can anybody tell me,  how to execute the xsl stylesheet in the command
prompt.

Regards
Eugene



Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
17.01.2006 09:16 AM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
Re:  Recursion performance (fibonacci numbers)






Thanks Mike. I was using the wrong namespace. With
saxon:memo-function="yes" its quite fast.

Regards,
Mukul

On 1/17/06, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> saxon:memo-function="yes" works for me. I get
>
> n      time
> 1000   90msecs
> 2000   610msecs
>
> It's not linear at large values of "n" because BigInteger arithmetic
takes
> longer the larger "n" becomes; but the use of a memo function certainly
> solves the XSLT-level problem.
>
> Are you sure you used the right namespace http://saxon.sf.net/ ?
>
> Michael Kay
> http://www.saxonica.com/
>
> > -----Original Message-----
> > From: Mukul Gandhi [mailto:gandhi.mukul@xxxxxxxxx]
> > Sent: 16 January 2006 15:08
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  Recursion performance (fibonacci numbers)
> >
> > Dear All,
> >    I am running this XSLT stylesheet with Saxon b 8.6.1. This prints
> > 1st n Fibonacci numbers, where n is supplied as a stylesheet
> > parameter.
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >                 xmlns:xs="http://www.w3.org/2001/XMLSchema"
> >                 xmlns:myfunc="http://dummy"
> >                 version="2.0">
> >
> > <xsl:output method="text" />
> >
> > <xsl:param name="n" />
> >
> > <xsl:template match="/">
> >   <xsl:for-each select="1 to $n">
> >     <xsl:value-of select="myfunc:fibonacci(position())"
> > /><xsl:text> </xsl:text>
> >   </xsl:for-each>
> > </xsl:template>
> >
> > <xsl:function name="myfunc:fibonacci" as="xs:integer">
> >   <xsl:param name="n" as="xs:integer" />
> >
> >   <xsl:sequence select="if (($n = 1) or ($n = 2))
> >                         then
> >                           1
> >                         else
> >                           (myfunc:fibonacci($n - 1) +
> > myfunc:fibonacci($n - 2))"
> >                        />
> >
> > </xsl:function>
> >
> > </xsl:stylesheet>
> >
> > The problem is, that it takes long time for large values of n. I
> > observed the following timing
> >
> > n=32 -> 35.5 secs
> > n=33 -> 55.2 secs
> > n=34 -> 1 min 27.3 secs
> > n=35 -> 2 mins 20.1 secs
> >
> > Is it possible I can improve the performance of this stylesheet for
> > large values of n?
> >
> > Regards,
> > Mukul





This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

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.