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

Re: sequence as function parameter

Subject: Re: sequence as function parameter
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 4 Jul 2011 07:59:14 -0700
Re:  sequence as function parameter
The correct type for the $serie parameter is xs:double*


Cheers,
Dimitre

On Mon, Jul 4, 2011 at 7:46 AM, Fabien Tillier <f.tillier@xxxxxxxx> wrote:
> Hi List.
> I am trying to create a simple function to multiply each item in a
> sequence by each other (like a sum()).
> My problem is that I am unable to have the parameter treated as a node
> sequence (using saxon, so XSL2.0)
>
> I have
> <xsl:template name=" multiplie">
> B  B  B  B <xsl:param name="serie"/>
> B  B  B  B <xsl:param name="result" as="xs:double"/>
> B  B  B  B <!--some test output -->
> B  B  B  B <xsl:value-of select="$serie"/>-<xsl:value-of
> select="$result"/>--
> B  B  B  B ###<xsl:value-of select="count($serie)"/>###
> B  B  B  B <!-- -->
> B  B  B  B <xsl:choose>
> B  B  B  B  B  B  B  B <xsl:when test="count($serie) gt 1">
> B  B  B  B  B  B  B  B  B  B  B  B <!-- make the multiplication between
result and
> the first item in the serie, then remove it and call again -->
> B  B  B  B  B  B  B  B  B  B  B  B <xsl:variable name="comp">
> B  B  B  B  B  B  B  B  B  B  B  B  B  B  B  B <xsl:value-of
select="number($serie[1])
> * $result"/>
> B  B  B  B  B  B  B  B  B  B  B  B </xsl:variable>
> B  B  B  B  B  B  B  B  B  B  B  B <xsl:call-template name=" multiplie">
> B  B  B  B  B  B  B  B  B  B  B  B <xsl:with-param
name="serie"><xsl:copy-of
> select="subsequence($serie,2)"/></xsl:with-param>
> B  B  B  B  B  B  B  B  B  B  B  B <xsl:with-param
name="result"><xsl:value-of
> select="$comp"/></xsl:with-param>
> B  B  B  B  B  B  B  B  B  B  B  B </xsl:call-template>
> B  B  B  B  B  B  B  B </xsl:when>
> B  B  B  B  B  B  B  B <xsl:otherwise>
> B  B  B  B  B  B  B  B  B  B  B  B <xsl:value-of select="number($serie[1])
*
> $result"/>
> B  B  B  B  B  B  B  B </xsl:otherwise>
> B  B  B  B </xsl:choose>
> </xsl:template>
>
> That I can call (for testing) with
> <xsl:variable name="seq" select="(6.8E-06,5.5E-06,7.1E-06,7.3E-06)"/>
> <xsl:value-of select=" multiplie($seq)"/>
>
> And the output I get
> #############################################
> 6.8E-06 5.5E-06 7.1E-06 7.3E-06
> #############################################
> 0.0000068 0.0000055 0.0000071 0.0000073-1--
> ####
> NaN
>
> #############################################
>
> So, the part where I do a count gets me 1, when I should have 4...
> I have tried with
> <xsl:param name="serie" as="node()*"/> but I have an error message
> XTTE0790: Required item type of first argument of multiplie() is node();
> supplied
> B value has item type xs:double
>
> I am a bit out of ideas....
> Thank you in advance for any help.
>
> Best regards,
> Fabien
>
>



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

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.