XML 'tradition' opinions


#1

This is a question of style and preference, and willingness to adhere to guidelines…

What do people here think of the rule that - in an XML document - DATA must be element text, and only METADATA should be attributes?

Personally, i despise using element text for all but ‘proper chunks’ of actual text. It just seems wasteful in my eyes, taking up so much more space with all those tags, so I put pretty much everything as an attribute. I can see the point of the guideline, but i can also see that it makes no actual difference.

I was just wondering how much everyone else here cares about such rulery; a part of the framework I’m gradually developing is entirely focused on XML, and I don’t want it to neglect guidelines that some people strongly agree with.


#2

i was developing a large web application, i had to choose something for my AJAX RPC, i had a choice between XML and JSON, after a lot of testing and seeing how api for each is done JSON became obvious, why is this relevant ? cause in my opinion XML is bloted, too much overhead of metadata and no real data, so using yet another [CDATA DATA tags just to enclose a YES/NO string sometimtes is just a waste of space and very often bandwidth.

i guess the only people that care about XML standards are Micrososft and companies like BEA or IBM that make large application servers, and XML is the basis of all of them.


#3

I’ve been pushing XML for interoperability’s sake at my place of work for some time. Because we are a research institution, tools are often built to solve a single problem, and project groups are small and largely disparate. By using XML for data, the overhead in size is more than made up for by the facility to quickly glue separate programs together into a larger automated whole. Equally, coming back to a datafile that is highly self-descriptive some years after the study for which it was generated has expired is priceless.

To your specific question Haydxn, my take on it is that I only use attributes for things that are none-critical. For example I might want to store whether a measurement was selected when a project was saved. This is purely a convenience thing for the user and does nothing to extend the data. As such, I’ll likely throw that in an attribute of the measurement element, rather than as an individual data tag. My reasoning is that other applications wont care about that data, and if they import and then export the xml, the loss of that tag changes nothing meaningful in the data.

For everything else I always adhere to the data/metadata guideline. It can make for some evil file sizes admittedly, but it is easier for others to read later, and makes for far cleaner schemas.


#4

Some very reasonable opinions indeed. I can certainly see why the guideline is there, and it does make sense.

The main reason it’s of such concern for me is that a big part of what I’m working on is using Xml for pretty much everything within a program (including userdata structures and internal communication). I know you might balk at the idea and overhead, but it allows for a tremendous amount of automation of general application behaviour (so less fiddly code), and also allows for a large portion of the content/design to be done via XML (which in turn means it can be ‘levelled up’ to a specialised editor tool). Also it allows for pretty much any aspect of the program data/operation to be easily communicated over a network. It’s sort of experimental, but it’s quicker than you’d imagine, and I figure it’s worth trying something a little different.

Obviously the overheads of using Xml for everything call for careful reductions. Using attributes doesn’t really take any less memory in terms of an XmlElement object (i guess it can be more if it’s just one attrib for an element), but it can when turned into a string (e.g. sending it across a network). In the back of my mind is a sort of general concern for maintaining a consistent approach to element makeup, keeping as efficient as possible and not belittling anyone’s views on Xml usage.

I guess it’s not too big a deal - on the whole it looks like a good idea to stick to the guidelines.