Hiya,

I was wondering if anyone had any thoughts on the conventions we should use in 
our xml files. Essentially when should we use attributes and when should we 
use elements. 

One school of thought saids we always use attributes if the value can only 
appear once. The negative aspect of this is that you can get elements with 
massive numbers of attributes like

<component 
   name="X"
   impl="com.biz.X"
   version="1.0.2"
   displayName="The magnificent X"
   description="X is a ...."
   ...
 />

This is fairly common in document centric descriptors.

Another school of though saids that you never use attributes. Like most of 
descriptors that come out of Sun. It is easier to extend, but this ends up 
with fairly verbose files like the following. The other problem is that if 
you want to validate using DTDs you end up with stupid names like 
<component-name> in an element <component> (see servlet/ejb descriptors for 
an example).

<component>
  <name>X</name>
  <impl>com.biz.X</impl>
  <version>1.0.2</version>
   ...
</component>

The other pattern I have noticed is that some people prefer to store "meta" 
data about element as attributes while they store "content" data as elements.

So any preferences among these alternatives? My current thinking is that we 
should probably go with the Sun-style (no attributes) just because it is more 
common in java world. Thoughts?

-- 
Cheers,

Peter Donald
--------------------------------
 These aren't the droids you're 
 looking for. Move along. 
-------------------------------- 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to