473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

integer type

Can someone please write an example containing one element which value is
integer type, and one attribute which value is also integer type:

Is it something like this:

<SomeAttribute AttrType:type="integer"

How to specify value of 3 for example? When I parse it, will I get 3 as an
integer or as a string?

thank you very much!
Sep 21 '06 #1
3 1741
Hi,

It is not clear from your post what exactly you are looking for. For
instance

<OneElement oneAttribute="1">2</OneElement>

is an example containing OneElement whose value is 2 (that is integer)
and oneAttribute whose value is 1 (again integer).

The common APIs for parsing XML documents DOM and SAX do not offer a
method that returns Integer to get the value of an attribute or of an
element. You can however try to convert the attribute value or the
value of the text content of an element to Integer and see if that
fails or not. Also if you use a schema then you can specify there that
you want integer values and if the document is valid against that
schema then you know that you will be able to convert those values to
Integer.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
veeman wrote:
Can someone please write an example containing one element which value is
integer type, and one attribute which value is also integer type:

Is it something like this:

<SomeAttribute AttrType:type="integer"

How to specify value of 3 for example? When I parse it, will I get 3 as an
integer or as a string?

thank you very much!
Sep 21 '06 #2
veeman wrote:
When I parse it, will I get 3 as an integer or as a string?
That depends on the tool you're using to parse it. Most parsers will
return the string, but converting string to integer is trivial and some
tools (eg XPath/XSLT) do so automagically if it's clear from context
that this is your intent. A schema-aware parser, or a data-binding
parser, may return the value directly as integer if they know from the
schema or binding that this is what you expected back.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Sep 21 '06 #3

veeman wrote:
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.

Sep 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Timothy Madden | last post by:
Hello I've read here that only C language has a standard 64bit integer. Can you please tell me what are the reasons for this ? What is special about C language ? Can you please show me some...
20
by: GS | last post by:
The stdint.h header definition mentions five integer categories, 1) exact width, eg., int32_t 2) at least as wide as, eg., int_least32_t 3) as fast as possible but at least as wide as, eg.,...
21
by: Frederick Gotham | last post by:
I set about trying to find a portable way to set the value of UCHAR_MAX. At first, I thought the following would work: #define UCHAR_MAX ~( (unsigned char)0 ) However, it didn't work for me....
1
by: charles_gero | last post by:
Hi all, I had a question about the topics in the subject and posted to comp.std.c, but feel it may also be appropriate here. Please excuse this crosspost if it is in bad form. I have a...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
7
by: Spoon | last post by:
Hello everyone, In my code, I use uint16_t (exactly 16-bit-wide unsigned integer type) and I need to print their value in base 10. ...
130
by: euler70 | last post by:
char and unsigned char have specific purposes: char is useful for representing characters of the basic execution character set and unsigned char is useful for representing the values of individual...
30
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Let's say we had a simple function for returning the amount of days in a month: unsigned DaysInMonth(unsigned const month) { switch (month) { case 8: case 3: case 5:
12
by: lithiumcat | last post by:
Hi, I bothered you a while back about storing integer values in void*. Now in a completely unrelated context, I'm trying to store pointer values in an integer type. So the basic question is,...
9
by: tsuyois | last post by:
Hi, I just signed in to this excellent network. I hope I could get some answers to many questions I have in writing C compilers. My first question is: Is "integer demotion" required in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.