Link Details

Link 92164 thumbnail
User 221012 avatar

By o_sam_o
Published: Jul 03 2008 / 04:30

User 108814 avatar

aj16780 replied ago:

0 votes Vote down Vote up Reply


"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:

name="Arcade Fire"

<artist><type>band</type><name>Arcade Fire</name><country>Canada</country></artist>

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?

User 221012 avatar

o_sam_o replied ago:

0 votes Vote down Vote up Reply

I do have a reference link in there which states:
"Attributes are designed for expressing simple properties of the information represented in an element."
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.

User 256617 avatar

dragmire replied ago:

0 votes Vote down Vote up Reply

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.

Add your comment

Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java