[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: attribute vs value

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

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:
> http://www.oasis-open.org/cover/elementsAndAttrs.html
> -- in particular, Eliot Kimber's discussion at:
> http://www.oasis-open.org/cover/attrKimber9711.htm
>

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">
<addresses>
   <address type="offfice">
       .....
   </address>
   <address type="home">
       ....
   </address>
</addresses>


==--==--==--==--==--==--==--==--==--==--==--==--==--==
S.Ramaswamy
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:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.