Lists Home |
Date Index |
Ramkumar Menon wrote:
> What was the fundamental motivation for having attributes in an XML
> Document ? Whatever that can be contained in an attribute of an
> element can be contained within a sub element. If I model an XML
> Document as a Java object, would I need to distinguish between the
> elements and attributes ? Moreover, why was it decided that attributes
> can only be of a simple type ?
Attributes were one of the big step forwards that SGML brought over
"Gencoding", one of the
previous formats in the 70s.
Consider the following questions:
"Why should batch files or shell commands have arguments, when all
information can be
put through standard input/output?"
"Why should functions or methods have more than one argument, when all
arguments can be
put into a single object, and (perhaps) all functions Curried to accept
"Why should natural languages have adjectives, when everything can be
verbs, nouns, adverbs etc.?"
"Why is context (path, font, position) important for keeping track of
the signifance of
some information in relation to other information?"
I believe the answers to each of those questions also applies to XML.
boils down to human amenability: there is a profound human factors
reason why the versions
of LISP that succeeded had keyword arguments and putprop/getprop (or
and why commands in shellscripts/batch files take arguments. People
things having named properties, and they appreciate it when there is a
differentiating between the properties of a thing and its parts or holders.
An element name is a function (ultimately defined by the recipient as a
semantic or presentational function) over its contents, and attributes
Attributes are a theory about which simple types will be used by
recipients to handle
their contents. It is encapsulation; it says "to use this element, you
need to also know some of these attributes; however you generally don't
know the contents or their attributes."
If you view XML as a way of sending relational data from A-B, none of this
probably will matter to you. But XML was not designed primarily to send