OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Attributes v Elements

> Most times there is no definitive answer, it comes down to your
> preference.  I would refer to the FAQ that Robin mentioned.

This answer is completely bogus.

No one has posted an easy guide for this so I will forward a quick
explanation then I do suggest Robin's references as the definitive guide.

An Element is used for capturing a Noun, capable of standing alone as a

An Attribute is an Adjective,  describing something unique about the
instance of the noun (element) and would not normally appear in your
document by itself without the associated noun (element).

For instance,  using your currency example,  your first example has two
adjectives together as both an element and an attribute:

<currency type="USDollar">
>    10
> </currency>

You would be better off to use a more definitive description of what the
monetary value is.   "USDollar" is really the value for "Currency".  Try
something like this:

<Price currency="USD">10</Price>

Currency is really an adjective describing something unique about the price
that users of your XML would find useful.  The "<Price>" element is more
descriptive of what the PCDATA represents.

Please never use your element example:


The element "<type>" should not exist as such becuase it is an adjective
describing currency.  You would probably not use the "<type>" element all by
itself in your document becuase it is dependant.

Bad example:

If you have time to do so, a good book on UML would help.

Duane Nickull
CTO, XML Global Technologies