Arguments for and against storing data in attributes

F

Falcolas

I personally feel that it's a bad idea. I've got to convince
managerial types of this.

Would some of you mind posting comments for and against the concept of
storing data in XML attributes? If you've got nothing good to say for
it, I'm OK with that too.

Thanks ahead of time for your input.

~G
 
R

roy axenov

Falcolas wrote:

[storing data in attributes]
I personally feel that it's a bad idea. I've got to
convince managerial types of this.

Would some of you mind posting comments for and against
the concept of storing data in XML attributes? If you've
got nothing good to say for it, I'm OK with that too.

Storing data in attributes is perfectly fine, as long as
it's plain old data, and as long as you keep in mind that
attribute value normalization applies (the standard uses
MUST there, so you can't work around that in a sensible
way).
 
J

Joe Kesselman

Falcolas said:
I personally feel that it's a bad idea.

There are sometimes reasons not to do it, eg if you expect the data may
need to support sub-structure later on. But it isn't automatically a bad
idea, especially if the purpose of the data is to help describe the role
the element is playing (which is the classic use for attributes).

Tools for tasks.
 
F

Falcolas

There are sometimes reasons not to do it, eg if you expect the data may
need to support sub-structure later on. But it isn't automatically a bad
idea, especially if the purpose of the data is to help describe the role
the element is playing (which is the classic use for attributes).

Thank you for all your responses, and for the faq link. Some good
reading.

To clarify for the above comment, *all* the data is being stored in
attributes; the leaf elements contain no data themselves, just
attributes. I'm in full agreement that metadata belongs in attributes.
I'm just of the opinion that barring a remotely good reason (which we
have not received), data should be stored in elements.

~G
 
J

Joseph Kesselman

Falcolas said:
I'm just of the opinion that barring a remotely good reason (which we
have not received), data should be stored in elements.

There really is no clear consensus on that.

As I say, the main remotely good reason for keeping the main data as
content is that data in attributes it can't be later enhanced to have
substructure. Depending on what kinds of data you're dealing with, that
may or may not become an issue.

The other remotely good reason for not putting it all in attributes is
that XML's usual definition of an element's string value is the
concatenated value of all the text nodes contained within it and its
descendants. If your markup is oriented toward documents (as opposed to
data structures), this can sometimes be a convenient shortcut. "I don't
care about all the prettifying detail, just tell me what I said here."
On the other hand, the richer the markup becomes, the less useful that
tends to be (except as a debugging tool).

Basically: This is very much like all the other coding style debates.
There are localized reasons for preferring one solution over the other,
but the reason both are supported is that both are reasonable. The most
important thing is generally for everyone working on the project to
agree on one consistant choice; which choice may be less important.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top