Re: attribute vs value

Subject: Re: attribute vs value
From: "S.Ramaswamy" <srswamy@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 22 May 1999 12:04:37 +0530

John E. Simpson wrote:

>      At 01:49 PM 05/21/1999 -0700, Cote, Stephane wrote:
> >I was wondering if any one knows when to use an attribute
> >versus a value in a XML document.
> This verges on being the highest-scoring XML FAQ. :)
> My rule of thumb is that true content belongs in elements (what you call "values"), and that attributes are for somehow shading the "meaning" of the content in ways that probably aren't useful to be displayed. If you know HTML, you know that attribute values are almost never displayed (except for fringe things like the <img> tag's alt attribute); they're effectively "invisible."
> Check Robin Cover's SGML/XML site for good coverage of the question, at:
> -- in particular, Eliot Kimber's discussion at:

We are following these conventions with programming efficiency in mind

When we use DOM to represent XML in memory, an "atttribute" is associated with the "element node" as properties of that element. This means there is no extra object created for an attribute. Whereas, for a value there is an extra element, which means an extra object. As you know, in Java, most time-consuming part concerns object creation. Hence, our effort is to make it an attribute
as fas as possible (that is when there can be only one value per element)

For e.g. if let us say column <name> is an element, I prefer @last as one attribute and @first as another attribute. However, if <name> element has addresses then I am going to have

<name last="Gandhi" first="Mahatma">
   <address type="offfice">
   <address type="home">

Matrix Infotech Syndicate
D-7, Poorti, Vikaspuri, New Delhi, 110018, India
PHONE:    +91-11-5610050,   FAX: +91-11-5535103
WEB         http://MatrixInfotech.HyperMart.Net

 XSL-List info and archive:

Current Thread