RE: Attribute and Element

Subject: RE: Attribute and Element
From: "Beckers, Marc" <Marc.Beckers@xxxxxxxxxxxxxx>
Date: Fri, 19 May 2000 10:03:52 +0200

> 	The confusion I am having now is, should I put the Price (or
> ValidBefore) as an attribute of the Ticket or put it as an 
> element under
> the Ticket. What is the difference, and what is the benefits?
> 
The decision "element or attribute?" is often a very fine one.
I tend to use an attribute if the value represents a certain "type"
or "flavour" of the element, and I use elements for fragments of
content.

In your example of the ticket element, "price" sounds like
it should be an element, allowing you to specify currency
in an attribute of "price". This being the case, I would make everything
else elements, too, to avoid later confusion "which ones were the
attributes, and which the elements". Also using elements allows you
to control the order in which they should appear (if you are using a DTD).

>From a pure instance generation and (XSL) processing point of view,
it makes no difference, but I am willing to be corrected.

A good source of tips is "Developing SGML DTDs" by Eve Maler and 
Jeanne Al Andaloussi. Though appearing in 1996 makes the book ancient
given the speed of developments, the chapters on docvument type modelling
are still useful in designing XML structures.

Hope this helps,
Dr. Marc Beckers
Documentation Consultant
Software AG
Uhlandstraße 12
D-64297 Darmstadt
Phone +49-6151-92-1322
Fax              -1612
mailto:Marc.Beckers@xxxxxxxxxxxxxx
http://www.softwareag.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread