News for hackers. Stuff that matters.
Re:The havoc the XML purists wrought by billpg on Wednesday May 19, 2010 @01:07PM (#1361561)
When I've designed XML files in the past, I use the "tags and attributes" principle. The entire file is tags, and ignored whitespace between the tags. All the data is in attributes. Looks a lot nicer IMO.

What I don't get, with XML in the real world, is why people prefer this...

<A><B>1</B><C>2</C></A>

instead of my preference...

<A B="1" C="2" />

With the first form, you need to write out each tag name twice, and there's ambiguity when whitespace appears between tags. Yet that's what most XML out there looks like. Maybe I'm just odd,

Re:The havoc the XML purists wrought by cema on Wednesday May 19, 2010 @01:37PM (#1361673)
A choice between a node and an attribute is not always clear, but there are helpful guidelines out there. A search for xml nodes versus attributes will give you a list of articles to ponder -- sorry for not being more detailed, but I am away from my archives, or else I could have given you links to the places that helped me to visualize it better. Here is one classic, though, from as far back as 1992: http://xml.coverpages.org/attrSperberg92.html

EDIT: ok, the first link is to an IBM Research article which I recall having been useful: http://www.ibm.com/developerworks/xml/library/x-eleatt.html

Re:The havoc the XML purists wrought by sesqu on Thursday May 20, 2010 @05:06AM (#1363573)
There's a semantic difference between an element and an attribute. Unfortunately, XML is specifically used to model element-as-attribute relationships, so a lot of people start wondering about the exact, nebulous, distinction. Elements are the more flexible of the two, but possessing of some quality that you (and many others) wish to avoid.

The difference is much the same as that between native datatypes and objects. Some languages explicitly expose everything as objects, while others contend that, for example, boolean-objects are overkill and downright problematic.

Generally, I use attributes for strongly typed data, and elements for untyped or (semi)structured data. Schemas are vital for typing.