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




Not sure if I misunderstood you but I think XML Schema CAN
constrain the contents of <Price> as well as specifying it to
have an attribute - there is a very similar
example in section 2.5.1 of the primer.

Regards
Michael



                                                                                                                                              
                    Iain W Fergusson                                                                                                          
                    <fergusson_iain@jpm        To:     duane@xmlglobal.com                                                                    
                    organ.com>                 cc:     Pcj@Inxar.Org, Tom.D.Conder@Lmco.Com, xml-dev@lists.xml.org                            
                                               Subject:     Re: Attributes v Elements                                                         
                    17/05/2001 08:25 PM                                                                                                       
                                                                                                                                              
                                                                                                                                              



>> 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:
>
>"<currency>
>    <type>USDollar</type>
>    <value>10</value>
></currency>"
>
>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
validated.

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.

Regards,

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.


------------------------------------------------------------------
The xml-dev list is sponsored by XML.org, an initiative of OASIS
<http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To unsubscribe from this elist send a message with the single word
"unsubscribe" in the body to: xml-dev-request@lists.xml.org