[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Attributes v Elements
- From: "Thomas B. Passin" <tpassin@home.com>
- To: xml-dev@lists.xml.org
- Date: Wed, 16 May 2001 20:23:12 -0400
[Conder, Tom D (N-MAXIM Group]
> Is there a good reference on the Web offering advice about various design
> decisions I have to make while developing a DTD (or XMLSchema)?
>
> For example, it is not immediately obvious when to use attributes and when
> to make an element a complex type.
>
As you have seen from other posts, there isn't one right answer. For a
different take on it, look in Wrox's Pro XML Databases (iIforget which
chapter, but early in the book). The author makes a fairly reasonable case
that attributes are prefereable for typical row data such as you might get
from a relational database. To sum it up, he finds that atributes would
take somewhat fewer bytes and less processing than keeping the same data as
child elements.
As for the supposed extra difficulty of processing attributes, it depends on
your language and processing model. If you are hacking it yourself without
a parser, it's certainly easier without attributes. If you are using an
event stream like SAX, chances are you will have to maintain more state
information for all-element data, and the SAX processor hands you the
attributes in a nice little package. For the DOM, probably no difference.
Cheers,
Tom P