xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip Nye" <phi...@engarts.com>
Subject Re: Attribute and Element
Date Fri, 19 May 2000 08:47:00 GMT
Clark C. Evans wrote:

>Attributes:
>  * unordered
>  * non-nestable
>  * usually implemented as an array or hash-table
>  * a bit briefer
>  * good for really short stuff (longer stuff gets ugly)
>  * all attributes are delivered together as one
>    unit in the SAX api.
>
>Elements:
>  * ordered
>  * nestable
>  * usually implemented as a linked-list
>  * a bit more verbose
>  * good for longer stuff
>  * elements are delivered seperately, sequentially
>    in the sax api.


The other consideration is uniqueness (only one instance of a particular
attribute for any one element).

I would assess it thus:

Unique:
   Elements: Up to schema designer
   Attributes: Must be unique

Ordered:
   Elements: Up to schema designer - APIs generally preserve order.
   Attributes: original spec does not say but most standard APIs
       will not guarantee to preserve order.

Nestable:
   Elements: yes
   Attributes: no

As Clark says - in raw terms you can do pretty much anything with elements
that you can do with attributes but not vice versa.

Many implementations and designers make all sorts of assumptions about
attributes vs elements which are not expressed in the XML spec and these
assumptions may not be explicit or even shared with others so you need to be
wary.

Philip



Mime
View raw message