This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Determining when to use an attribute vs. an element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Determining when to use an attribute vs. an element" Watch "Determining when to use an attribute vs. an element" New topic
Author

Determining when to use an attribute vs. an element

John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1441
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 ]

The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
Kripal Singh
Ranch Hand

Joined: Jul 26, 2001
Posts: 254
Please have a look at following discussion link
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=31&t=000637


# Help an unprivileged kid.<br /> Whatever u do will make a difference...<br /> ...to a child's life & ur own #<br /><a href="http://www.cry.org/" target="_blank" rel="nofollow">www.cry.org/</a>
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1441
Thanks. That is a good thread. I'll need to search before I post next time!
John
 
wood burning stoves
 
subject: Determining when to use an attribute vs. an element
 
Similar Threads
hi
API for Reading XML Schema
XHTML documents vs. XHTML syntax in HTML documents
JNDI Port number issue while strating JBoss server 4.2.2.GA
Unable to find setter method for attribute: locale