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.

IMO there is no definitive answer.  Your suggestion is not definitive.
For one thing, it prevents full use of XML Schema.

><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>

In the above example <price> has to be described in XML Schema using a
<complexType>, because of the presence of the currency attribute.
There is then no way of constraining the contents of <price> to be a number.

If you need to validate that <price> is a number, it has to be a <simpleType>,
which cannot have attributes.

>Please never use your element example:
>    <type>USDollar</type>
>    <value>10</value>
>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:

Good example - because <value> can be described using a <simpleType>, so can be

I'm not suggesting that XML Schema is perfect, just that there is no single
answer to
the attributes vs. elements questions that is right in all situations.


Iain Fergusson
JP Morgan European Technology Centre.

This communication is for informational purposes only.  It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data
and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan Chase & Co., its
subsidiaries and affiliates.