xsl-list
[Top] [All Lists]

Functions as data types with XSLT 2.0 (was: [xsl] Functional program for "list sum")

2005-06-08 23:49:08
I wish to know, is it possible to treat functions as
first class data types with XSLT 2.0 ..

Regards,
Mukul

--- Mukul Gandhi <mukul_gandhi(_at_)yahoo(_dot_)com> wrote:

I am trying to implement a "integer sum" function in
a
functional manner .. My stylesheet so far is -

<?xml version="1.0"?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
               
xmlns:xs="http://www.w3.org/2001/XMLSchema";
                xmlns:fn="http://whatever";
                version="1.0">
 
 <xsl:output method="text" /> 

 <xsl:template match="/">
    <xsl:variable name="result"
select="fn:listSum(null,(1,2,3))" />
    <xsl:value-of select="$result" />
 </xsl:template>
 
 <xsl:function name="fn:listSum" as="xs:integer">
    <xsl:param name="num" as="xs:integer" />
    <xsl:param name="list" as="xs:integer+" />
    <xsl:sequence
select="fn:listSum($num,$list[position() &gt; 1])"
/>
 </xsl:function>
 
</xsl:stylesheet>

But I am getting following error with Saxon 8.4 ..

"Warning: Running an XSLT 1.0 stylesheet with an
XSLT
2.0 processor
Error on line 10 of file:/C:/xml/xsleg/xslt/fp.xsl:
  XPTY0004: An empty sequence is not allowed as the
first argument of fn:listSum
()
Transformation failed: Run-time errors were
reported"
..

Can someone please help me ..?

Regards,
Mukul


              
__________________________________ 
Discover Yahoo! 
Have fun online with music videos, cool games, IM
and more. Check it out! 
http://discover.yahoo.com/online.html


--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--