xsl-list
[Top] [All Lists]

Re: string(9) = string(09) ... true or false?

2004-03-12 13:25:19
Hi Roger,

At 02:52 PM 3/12/2004, you wrote:
I ran this test with SAXON 7_8

<xsl:value-of select="string(9) = string(09)"/>

Output: true

Shouldn't the output be: false?

Mike or Jeni or someone will speak up if there's an XPath 2.0 angle to this (I apologize if that's what you're meaning to ask about) ... but in XPath 1.0, the two expressions are equal, since a number is cast to a string by the rule

if the number is an integer, the number is represented in decimal form as a Number with no decimal point and no leading zeros, preceded by a minus sign (-) if the number is negative [XPath 4.2]

So string(9) is "9", string(09) is "9"; as strings these are equal.

Now "string('9') = string('09')" is false, just as "'9' = '09'" is false (the strings are not the same).

I hope this helps,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list