xsl-list
[Top] [All Lists]

Failed conversion of xs:integer to xs:double by Saxon 8.11B

2004-12-17 04:54:18
I have the following code:

testFunc-Map3.xsl
==============

<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:f="http://fxsl.sf.net/";
exclude-result-prefixes="f xs"

   <xsl:import href="func-map.xsl"/>
   <xsl:import href="func-exp.xsl"/>

   <xsl:output omit-xml-declaration="yes" indent="yes"/>
   <xsl:strip-space elements="*"/>
   
   <xsl:template match="/">
     <xsl:value-of select="f:map(f:exp(), 1 to 10)" separator="&#xA;"/>
   </xsl:template>

</xsl:stylesheet>

func-exp.xsl (the relevant part only):
==========================

<!-- reference to exp()-->  
  <f:exp/>

<!--
 f:exp() -      convenience function,
                returns a reference to f:exp()                                  
                when called with no arguments                                
-->  
  <xsl:function name="f:exp" as="node()">
    <xsl:sequence select="document('')/*/f:exp[1]"/>
  </xsl:function>

  <xsl:template match="f:exp" mode="f:FXSL">
     <xsl:param name="arg1" as="xs:double"/>
     <xsl:param name="arg2" as="xs:double" select=".00000001E1"/>
    
    <xsl:sequence select="f:exp($arg1, $arg2)"/>  
  </xsl:template>


func-map.xsl
==========

<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:f="http://fxsl.sf.net/";
exclude-result-prefixes="f"

    <xsl:import href="func-apply.xsl"/>
    
    <xsl:function name="f:map" as="item()*">
      <xsl:param name="pFun" as="element()"/>
      <xsl:param name="pList1" as="item()*"/>

      <xsl:sequence select=
       "for $this in $pList1 return
          f:apply($pFun, $this)"
      />
    </xsl:function>
</xsl:stylesheet>



The result of performing the transformation as specified in
testFunc-Map3.xsl is:

"Saxon 8.1.1 from Saxonica
Java version 1.4.2_04
Stylesheet compilation time: 703 milliseconds
Processing 
file:/C:/xml/msxml/XML%20SDK/Samples/Tests/Generic/FP/Fxsl/XSLT2/marrowtr.xml
Building tree for
file:/C:/xml/msxml/XML%20SDK/Samples/Tests/Generic/FP/Fxsl/XSLT2/marrowtr.xml
using class net.sf.saxon.tinytree.TinyBuilder
Tree built in 0 milliseconds
Tree size: 22 nodes, 20 characters, 0 attributes
Building tree for
file:/C:/xml/msxml/XML%20SDK/Samples/Tests/Generic/FP/Fxsl/XSLT2/func-exp.xsl
using class net.sf.saxon.tinytree.TinyBuilder
Tree built in 47 milliseconds
Tree size: 167 nodes, 3 characters, 217 attributes
Error at function f:map() on line 8 of
file:/C:/xml/msxml/XML%20SDK/Samples/Tests/Generic/FP/Fxsl/XSLT2/func-map.xsl:
  Required type of value of variable $arg1 is xs:double; supplied
value has type xs:integer
Transformation failed: Run-time errors were reported"


When I change the code of  f:exp()  to the following:

<!--
 f:exp() -      convenience function,
                returns a reference to f:exp()                                  
                when called with no arguments                                
-->  
  <xsl:function name="f:exp" as="node()">
    <xsl:sequence select="document('')/*/f:exp[1]"/>
  </xsl:function>

  <xsl:template match="f:exp" mode="f:FXSL">
     <xsl:param name="arg1" as="item()"/>
     <xsl:param name="arg2" as="xs:double" select=".00000001E1"/>
    
    <xsl:sequence select="f:exp(number($arg1), $arg2)"/>  
  </xsl:template>

then the transformation succeeds and produces the expected results.


Now, on page 395 of Mike Kay's XSLT 2.0 book (describing xsl:param and
the allowed type conversions) it is written:

"In summary, this means that the only conversions allowed are:
  <first-bullet/>
 <second-bullet>
   Numeric promotion, for example conversion of xs:integer to xs:double.
</second-bullet>
"

Of course, this is what makes sense and what I expected -- not the
runtime error.

My question is whether this is a Saxon 8.11B bug, or whether the book
is wrong,... or whether neither is wrong, but I completely fail to
understand both.


Cheers,
Dimitre.

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>
  • Failed conversion of xs:integer to xs:double by Saxon 8.11B, Dimtre Novatchev <=