Hi Ken,

Xalan-C is conformant, and XML Spy is not, so there is no "work-around."
This has been a frequent question on many XSLT-related lists.  Here's the
relevant section of the XPath recommendation regarding the lexical
structure of XPath:

   http://www.w3.org/TR/xpath#exprlex

You'll see the production for numeric literals does not allow for
scientific notation.

There's even an entry in Dave Pawson's XSL FAQ:

   http://www.dpawson.co.uk/xsl/sect2/N5846.html#d6916e85

Dave



|---------+--------------------------->
|         |           "Ken Holladay"  |
|         |           <[EMAIL PROTECTED]|
|         |           edu>            |
|         |                           |
|         |           06/18/2004 06:13|
|         |           PM              |
|         |           Please respond  |
|         |           to xalan-c-users|
|---------+--------------------------->
  
>--------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                             
                                                         |
  |        To:      <[email protected]>                              
                                                         |
  |        cc:      (bcc: David N Bertoni/Cambridge/IBM)                        
                                                         |
  |        Subject: invalid math with scientific notation                       
                                                         |
  
>--------------------------------------------------------------------------------------------------------------------------------------|



After developing a transform with XML Spy and using the internal XSLT
engine, I was surprised when Xalan gave a different result.  It seems that
when a number includes scientific notation, any math with that number
returns a NAN.  For example, with this XML file

<sets>
    <tol>100</tol>
    <val>1000</val>
    <val>1.0E5</val>
</sets>

And this XSL file

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format";>
    <xsl:output method="text"/>
    <xsl:variable name="Tol" select="number(sets/tol)"/>
    <!-- Process the root element -->
    <xsl:template match="/">
        <xsl:apply-templates select="sets/val"/>
    </xsl:template>
    <xsl:template match="val">
        <xsl:variable name="low" select=". - $Tol"/>
        <xsl:value-of select="$low"/>
        <xsl:text>,</xsl:text>
        <xsl:variable name="high" select=". + $Tol"/>
        <xsl:value-of select="$high"/>
        <xsl:text>&#xa;</xsl:text>
    </xsl:template>
</xsl:stylesheet>





xalan nantest.xml nantest.xsl

The first <val> will yield an output of:   900,1100
The second <val> will yield an output of:   NaN,NaN

The XMLSpy engine correctly gives:  99900,100100





I am using Xalan version 1.8.0. Xerces version 2.5.0.

Any work around?

Ken.



+--------------------------------------+
Kenneth L. Holladay, PE
Southwest Research Institute
6220 Culebra Road, San Antonio, TX 78238
email: [EMAIL PROTECTED]
Voice: (210)522-3627; Fax: (210)522-2709
+--------------------------------------+






Reply via email to