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]
XML is text-only ... why?

Hi Folks,

Below are a few notes I put together concerning the text-only nature of
XML. At the bottom of this message are a few questions that I would
very much appreciate your thoughts on. /Roger

------------------------------------
XML IS TEXT

An XML document is comprised purely of text. That is, the contents of
an XML document is just a string of characters. There are no integers
in an XML document. There are no floating point values in an XML
document. There are only characters.

------------------------------------
EXAMPLE 

Here is a simple XML document. It would appear that the value of the
<x> element is an integer:

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

However, that is not the case. The 23 represents two characters, 2 and
3.

You can see that they are indeed characters by viewing the hex values
of the XML document:

http://www.xfront.com/hex-values-of-a-simple-XML-document.gif  

In the graphic you see that the hex values of 23 are x32 and x33, which
corresponds to the character 2, and the character 3.

Compare with an integer value 23; it's binary value is 00010111, which
has a hex value 17. 

Thus, XML is just text. And you use a "text" editor to create an XML
document.

------------------------------------
MANIPULATING XML

Consider manipulating an XML document using XSLT. Here is shown an XSLT
statement which multiplies the value of the <x> element by the number
2:

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

How can the two characters 23 be multiplied by an integer 2?

Answer: the XSLT processor first converts the two characters into an
integer:

    Convert these two hex values: 32 33 into this hex value: 17

After doing the conversion then the XSLT processor performs the
multiplication.

------------------------------------
DECLARING AN ELEMENT'S DATATYPE IN A SCHEMA

Consider an XML Schema that declares the element <x> as an integer:

    <element name="x" type="integer"/>

This is not stating: 

    "The value of the element x in an XML instance document is an
integer." 

Rather, it is stating: 

    "The value of the element x in an XML instance document may be
converted to an integer."

------------------------------------
QUESTIONS

1. Is the above accurate?

2. Is there such a thing as a document which contains both text and
integers?

3. Do different platforms represent, say, integers differently? Is that
why XML decided to be text-only?

------------------------------------
Note: I found a very nice editor that enables you to view the hex
version of a text file: PSPad at http://www.snapfiles.com/get/spad.html



[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