[ODE] XODE -Attributes vs. elements

Jani Laakso jani.laakso at itmill.com
Fri Mar 19 09:14:21 MST 2004


William Denniss wrote:

>I have used attributes in many places - but I just figured that they
>arn't suited for everything.  Visualisation wise, personally, if I see
>an element with only a value and no child elements, I assume it is a
>property of the parent element anyway.
>  
>
I want to comment about this XML attributes vs. elements case as it 
affects XODE definition bigtime!

This debate is a never ending story for all XML users but I suggest you 
check more information e.g. from:
http://www-106.ibm.com/developerworks/xml/library/x-eleatt.html?ca=dnt-59
It's good stuff for starters..

Simple summary:
1. attributes cannot contain any markup and they are _atomic_
2. elements are hierarchical and _extensible_

Generally speaking, attributes are somewhat faster and simpler to use 
with SAX / DOM / XSLT (XPath), but I wouldn't use this of a design 
factor. Put all atomic stuff in attributes but if there's a possibility 
that the data in question needs to be extended someday or you are not 
absolutely sure if it's really atomic, then put it into element.

I skimmed through xode.txt and here's my comments:
-<box> can have only one atomic sizex,y,z, use attributes
-<cylinder> can have only one atomic radius, use attributes
-<body> can have only one atomic mass, use attributes
These are all atomic 1 to 1 cases don't you agree?

About the visual side of the XODE definition:
XODE defines quite technical data, mainly lot's of parameters for 
objects if you will and less hierarchial structures but these too also, 
so it tends to use quite a lot of attributes imho. I wouldn't bother 
with the visual "issues" too much.

One more thing, I share my thoughts with the guy that reminded me of 
<ext> tag's pitholes. Having
<tag type="anything">
  <!-- content anything -->
</tag>
should be avoided as much as possible. Sure people can add anything to 
XML document if allowed but if we already know even some of the optional 
tags that can be used with XODE, why not to define them properly so they 
are consistent. Could optional tags like mesh-file-location and color be 
defined also? IMHO it's better to define these examples than to leave 
them as examples using universal <ext> element. If the definition is not 
suitable for someone, then this someone can use the dreaded <ext> tag.

Sorry that my comments are coming a bit late..


Cheers, Jani!

-- 
Jani Laakso / IT Mill Ltd | Tel. +358 40 5898086 | http://www.itmill.com




More information about the ODE mailing list