Monday, January 23, 2006

Where does XML Data Belong?

"This raises the question of when and whether one should use child elements or attributes to hold information. This is a subject of heated debate. Some informaticians maintain that attributes are for metadata about the element while elements are for the information itself. Others point out that it's not always so obvious of what's data and what's metadata. Indeed the answer may depend on where the information is put to use.

What's undisputed is that each element may have no more than one attribute with a given name. That's unlikely to be a problem for a birth date or death date; it would be an issue for profession, name, address, or anything else of which an element might plausibly have more than one. Furthermore, attributes are quite limited in structure. The value of the attribute is simply undifferentiated text. An element-based structure is a lot more flexible and extensible. Nonetheless, attributes are certainly more convenient in some applicaitons. Ultimately, if you're designing your own XML-vocabulary, it's up to you to decide which to use."

from O'Reilly's XML in a Nutshell

No comments: