Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Determining when to use an attribute vs. an element

 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wondering if there are any rules of thumb/design principles regarding the use of attributes vs. elements to specify data in XML. As an example, below is a snippet of an XML file from an article (citation at the end of the post) and an alternate approach that I came up with that doesn't use attributes to specify the data.
From article:

Alternate:

I admit the alternate is probably not the best but I wanted to emphasize the use of elements, not attributes.
So is one approach better then the other and if so, why? What says "make this an attribute" vs "make this an element"?
The article is The Bean Generation by Claude Duguay in XML Magazine February 2002 v 3 no 1.
Thanks,
John
[ March 01, 2002: Message edited by: John Wetherbie ]
 
Kripal Singh
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please have a look at following discussion link
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=31&t=000637
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. That is a good thread. I'll need to search before I post next time!
John
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic