XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] [Summary] XML is text-only ... why?

Philippe Poulard wrote:

> An application such as XSLT that consider that the string "32" is in 
> fact the integer 32 because it appears in a mathematical operation
"32 + 
> $foo" for example applies some convention to get an integer from a 
> sequence of digits.

Hi Philippe, I tried that and it didn't seem to work.

----------------------------
Here's my XML document:

<?xml version="1.0"?>
<x> </x>

----------------------------
Here's my XSLT document:

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

    <xsl:template match="x">
        <html>
            <head>
                <title>Treating a Space as an Integer</title>
            </head>
            <body>
                Value * 2 = <xsl:value-of select="xs:integer(.) * 2" />
            </body>
        </html>
    </xsl:template>

</xsl:stylesheet>

----------------------------
I ran this using SAXON, and I got this error message:

    Cannot convert zero-length string to an integer

----------------------------
Removing the cast to integer:

    Value * 2 = <xsl:value-of select=". * 2" />

I don't get an error, but I get this result:

    Value * 2 = NaN

----------------------------
Am I doing something wrong?

/Roger

-----Original Message-----
From: Philippe Poulard [mailto:philippe.poulard@sophia.inria.fr] 
Sent: Friday, September 28, 2007 3:26 AM
To: Costello, Roger L.
Cc: XML DEV
Subject: Re: [xml-dev] [Summary] XML is text-only ... why?

Costello, Roger L. a écrit :
> Hi Philippe,
> 
> I enjoy reading your posts.  You provide lots of excellent
information.

Thanks Roger

> 
> You have me stumped on this message (below), but I am intrigued.
Would
> you explain please?

An application such as XSLT that consider that the string "32" is in 
fact the integer 32 because it appears in a mathematical operation "32
+ 
$foo" for example applies some convention to get an integer from a 
sequence of digits.

Another application could apply some other (very silly, I do admit) 
convention to consider that the character inside "<x> </x>" would be 
convert to an integer from the unicode code point of that character ; 
space => 32 ; it's a very stupid convention, as XML doesn't allow 
characters < 32 (except tab, cr, lf) ; perhaps with XML 1.1 ?

The fact that "32" will be understand as an integer or as a string 
depends just on the application that will process it ; at the XML
level, 
it's text

> 
> /Roger 
> 
> -----Original Message-----
> From: Philippe Poulard [mailto:philippe.poulard@sophia.inria.fr] 
> Sent: Thursday, September 27, 2007 11:56 AM
> To: Costello, Roger L.
> Cc: xml-dev@lists.xml.org
> Subject: Re: [xml-dev] [Summary] XML is text-only ... why?
> 
> Costello, Roger L. a écrit :
>> Hi Folks,
>>
>> Thank you very much for your excellent comments!  I learned a lot! 
>>
>> I incorporated your comments (or, what I interpreted to be the
> essence
>> of your comments):
>>
>> http://www.xfront.com/xml-is-text/
>>
>> Please let me know of any inaccuracies or confusing parts.
>>
>> /Roger 
>>
> 
> Consider this last document :
> <?xml version="1.0"?>
> <x> </x>
> Does it contain a space inside the x element ? Not at all, it
contains 
> the integer 32
> 
> I let you write the end of the story :)
> 


-- 
Cordialement,

               ///
              (. .)
  --------ooO--(_)--Ooo--------
|      Philippe Poulard       |
  -----------------------------
  http://reflex.gforge.inria.fr/
        Have the RefleX !


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS