wood burning stoves 2.0*
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
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: 1449
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: 1449
Thanks. That is a good thread. I'll need to search before I post next time!
John
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Determining when to use an attribute vs. an element