[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Attributes v Elements

  • From: Duane Nickull <duane@x...>
  • To: Paul Cody Johnston <pcj@i...>,"Conder, Tom D (N-MAXIM Group)" <tom.d.conder@l...>
  • Date: Thu, 17 May 2001 01:37:28 -0700

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

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:

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

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

Duane Nickull
CTO, XML Global Technologies
*************************************************
http://www.xmlglobal.com
*************************************************









PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.