DTD Question: Attributes vs Elements

Didier PH Martin martind at netfolder.com
Fri Mar 19 20:40:41 GMT 1999


Hi,

<YourComment>
What is the criteria for selecting when to define data as an attribute
or element in a DTD?

Simon says attributes are an "excellent tool for passing along extra
information about your element to an automated processor - a parser, a
browser, or a conversion tool.   They are NOT a good place to actually
store data".  Simon continues, "generally, you should use attributes to
store information that may not be useful to humans directly but may help
computers process the element properly."

Would anyone like to add or differ with this?
</YourComment>

<Reply>
To make some order in this world I created a mental model about this. Let's
imagine that a XML document is an object tree. At each node, the object is
associated to a set of properties (Do you see the tree of objects and each
object get a bag of properties attached to it). There is one property which
is more useful to human than to machines: the data content or what's in
between the markups.

the actual problem with XML is that the same hammer is used for all kinds of
works like feeding the cat, making the toast, etc. :-). At the beginning,
markups where used to bring structure to unstructured information. So to
speak add metadata or provide more information about what kind of
information this is. Not for human because we can extract the meaning from
the sentences themselves but for machines that are too young to speak human
language :-) So, with markup, the unstructured information became more
structured and machine could extract some meaning of a text. So, the markups
where for machines and text for humans. But, as you know, never let a kid
with a hammer in a house because everything becomes a nail :-) So, with
time, XML became the hope for the next Esperanto, the Microsoft hegemony
deliverance day, a release from not to have to learn 50 computer languages.
And we started to use it for other usage, some of it not for human at all
like exchange of data between machines. So in that case, the human vs.
machine part is quite confusing (for machine too, they prefer machine
language and they don't understand why humans are so convoluted :-).

In conclusion: If the information that you encapsulate in a XML substrate is
knwoledge or information for human consumption. What Simon said stands and
is a good rule of thumb. If your application is machine information exchange
and that you have to deal with firewalls, diverse platforms then you are
probably constrained to use something like XML or an object middleware which
is "firewall proof". In this case, the markup content could be seen as a
serialized variable or property and is not necessarily for humans. So we
just did some conceptual extension. I tell you, never let a child with a
hammer, everything becomes a nail :-))
</Reply>

Regards
Didier PH Martin
mailto:martind at netfolder.com
http://www.netfolder.com


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list