Published: Jul 03 2008 / 04:30
"Having Elements That Only Contain Attributes"
"Not Wrapping Repeated Elements"
What a BS.
Articles take less space than elements with their close tags. They are also meant to define properties that element can only have once. Elements should be used only when there can be multiple contained values.
Of course if you write your examples in different ways, one might look nicer.
Which one is better:
And wrapping elements is hideous. That's why XML has sequences. And think about the mess in object mapping.
Whole article is badly written.
"Why is this better? Firstly, it's the way it was intended"
According to whom?
I do have a reference link in there which states:
"Attributes are designed for expressing simple properties of the information represented in an element." http://www.ibm.com/developerworks/xml/library/x-eleatt.html
When to use attributes is very subjective, i personally think they should be used sparingly.
All XML readers i have used would style the XML in the way I've presented it, i haven't seen any that would style them in the way you have it. I will conceded that wrapper elements can cause nasty object models, however, JAXB now caters for this with the XmlElementWrapper annotation.
I completely disagree with:
Having Elements That Only Contain Attributes - There are cases where having only attributes is completely valid. I wouldn't restrict the tool to even more tagging. XML is hard enough to read as is.
Repeating Elements Names in Different Contexts - As long as the different elements are on different levels of the hierarchy, there shouldn't be an issue. Quit reading XML like HTML.
Otherwise, I agree with the rest.
Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.
Advertising - Terms of Service - Privacy - © 1997-2014, DZone, Inc.