[Date Prev] [Date Next] [Thread Prev] [Thread Next] Indexes: Main | Date | Thread | Author

Re: [ba-ohs-talk] Fwd: [xml-dev] Penance for misspent attributes

Dead on. Comments below.    (01)

Jack Park wrote:    (02)

> This post seems like a great way to think about elements and attributes.
> Here's an example of using attributes for data:
>          <someTag name="Joe" age="33" />
> Here's the same example using elements
>          <someTag>
>                  <name>Joe</name>
>                  <age>33</age>
>          </someTag>
> >From: "Simon St.Laurent" <simonstl@simonstl.com>
> >To: xml-dev@lists.xml.org
> > ...
> >The problem with using attributes for data is that there is no direct
> >way to associate metadata with attribute content.  There is a very easy
> >direct way to associate metadata with element content - it's called
> >attributes....
> >
> >....it seems like many of the PSVI-representation difficulties
> >could be relieved by a best practice of using elements for the
> >information contained in a document and using attributes exclusively to
> >provide additional information about the element.
> >
> >Separating markup from content - and putting attributes squarely in the
> >markup side - seems like one means of at least alleviating the headache.    (03)

To paraphrase his pithy summary:    (04)

    "Use elements for the information *contained* in a document
     and use attributes exclusively to provide additional information
     *about* those elements."    (05)

This is basically the recommendation I put forward in Sun's XML
tutorial, which has unfortunately become very difficult to find
online. The truly persevering, howver, if they have fortified themselves
with a big lunch, will have managed it to track it down to here
http://java.sun.com/webservices/docs/ea2/tutorial/doc/IntroXML4.html#65003    (06)

The relevant part of that discussion, under "Container vs. Contents" is
    "Another way of thinking about elements and attributes is to think of
     an element as a container. To reason by analogy, the contents of the
     container (water or milk) correspond to XML data modeled as
     elements. On the other hand, characteristics of the container (blue
     or white, pitcher or can) correspond to XML data modeled as
     attributes. Good XML style will, in some consistent way, separate
     each container's contents from its characteristics."    (07)

It's been there for a couple of years now.
(It's nice to be ahead of the curve once in a while.)
:_)    (08)