veeman said:
How to specify value of 3 for example? When I parse it, will I get 3 as an
integer or as a string?
XML protocol itself only uses string types, not integers (URLs, NAMEs,
IDREFs and maybe binary too, but not an integer)
XML Schema specifies data typing, which means that the "string" in XML
must represent an integer. A non-integer string would thus still be
well-formed (good as far as XML goes) but would stop being valid (good
for both XML and the relevant DTD or Schema)
If you use a simple non-Schema aware parser, then you'll get the string
"3"
If you use a smarter parser that understands Schema and has an
appropriate DOM interface to it, then it may also offer you a method
that could retrieve 3 as a typed integer value. Probably it would also
have some low-level string interface that returned it as "+3.00" or
however the string had literally been supplied.
For a dumb parser to recognise a string "3" as a potential integer and
return it as the integer 3 _without_ having been told to do this by a
data type in the Schema would be an error.
If the intelligent parser can retrieve the document but not the Schema,
then it has to treat the string as a string and not do anything about
data typing. It's fundamental that XML (unlike SGML) keeps working even
when you don't have the Schema to hand, but obviously it has to lose
some of the extra, smarter features.
So to get integers as integers, then you need three things: a Schema
that defines the type, a parser and DOM smart enough to understand
this, and an accessible connection between the two.