Other XML Idiocy

Thanks lgrant. I like the quote of a commenter from this discussion.


The distinction between data and metadata is almost entirely subjective. One man's data is another's metadata. The "metadata in attributes" rule grew out of the markup world, where a rule of thumb was, if you remove all of the markup, and just leave the text, it should be a reasonable document. This meant attributes should be discardable, and elements essential. If you display XML in an uncomprehending browser, it will be treated this way.

But your XML (and most XML these days) likely won't be displayed to the user in an uncomprehending browser, so you can use better rules for how to design your XML
 
Here are good comments and arguments about attributes vs elements:

One of the comments in that article said: (William Walseth) "2 other classics to avoid. 1) NEVER name an element name <attribute>. 2) Avoid the following. <attribute name='Name' value='Douglas Adams'/>, use <author name='Douglas Adams'/>."

The Version One sprint-tracking tool was an interesting exception. It had basically two kinds of elements, <object> and <relationship>. So the entry for a team would start out like this:

<object type="team" name="Team 1">...</object>

This made it easy to add new types, because all the database knew about was objects and relationships.

The records were a bit cumbersome to use that way, so I would run the data through an XSLT or an XQuery program to change the above record to:

<team>
<name>Team 1</name>
...
</team>
 
Back
Top