A lot of times we don't pay attention to it, but in many instances, data, to be meaningful, requires more context than we often give it. For instance, character data, to be meaningful, needs to have some character encoding specified. Like, you can give someone a text file, but is it ASCII, Unicode (UTF-8, UTF-16 (BE, LE, or BOM-distinguished)), SHIFT-JIS, EBCDIC, etc. etc.
Same goes for times (is it UTC, or some other time zone?). I was thinking about this in the context of my data being stored in MySQL. There're no time zones associated with my dates and times, and there's no character encoding information stored with my character data. That makes me uncomfortable. For instance, without being really careful about what date it was when a time was entered, I can't even go back and figure out what time something was really written or entered into my database... was it daylight savings time or not during that time? So, if I were to convert it all to UTC (GMT), I'd have to be careful about whether DST was in effect. And then, for instance, if I were to display a past weblog entry, the time displayed might not actually be the time the post was written.
There are other times data needs context... for instance, a data file format might need a version number for it to be meaningful. Also think of the problem that RSS had, where the <description> field was never well defined. Some people started put HTML in there and applications were built to match, so if you put plain text and had something that looked like HTML in it you'd have a problem.
By the way, this is the criterion by which I usually decide whether something in XML has to be an attribute or a value. If it's "context", and describes the value, then it should be an attribute. If it's the main data you want then it should be a value. Of course, there are times when something could be either, but I see often see cases where the I think the designer made the wrong choice according to this criterion.
What other cases of this are there?
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):