Content v. attribute

david at david at
Mon Oct 26 16:49:04 GMT 1998

Dave Winer writes:

 > I consider it a flaw of XML that it has two ways to do hierarchy,
 > one much more powerful than the other. In working with other
 > companies about formats you can get into endless meaningless
 > debates about whether it's better to use attributes or just stick
 > with <tag> structures. When I design XML forms for our own internal
 > applications, I have generally found that if I use attributes, I
 > end up regretting it and switch over to straight tag hierarchy. You
 > always have the option of adding a structure where a scalar used to
 > be when you go that way. With attributes, you're at the end of the
 > road, no way to have structure, so I agree with John Cowan
 > entirely, you never know what's coming down the road, so it's
 > better to leave some room on either side. Dave

There was a long-running debate in the old SGML world about whether
attributes should be allowed at all.  Personally, I like them --
although Len's point about my data being someone else's metadata is
well-received, I still want to have the choice to use

  <section id="foo">


  <note security="confidential">Remember to close the panel.</note>


  <link href="">Megginson Technologies</link>

rather than



  <text>Remember to close the panel.</text>


  <label>Megginson Technologies</label>

There are, of course, many cases where the latter examples are

I agree with all of the posters that in general using elements rather
than attributes is a good design principle, but I do think that there
are useful data/meta-data distinctions to be made, even if they are
extremely fuzzy.

One of the reasons data people jump to attributes is the fact that

  <account number="345"
	   name="Accounts Receivable"

looks an awful lot like

  public interface Account
    public abstract int getNumber ();
    public abstract int getType ();
    public abstract String getName ();
    public abstract String getCurrency ();
    public abstract boolean isCurrent ();
    public abstract float getBalance ();


  create table Account (
    num int primary key,
    type int,
    name char(80),
    currency int,
    status bool,
    balance float

It's not easy to start thinking differently.

All the best,


David Megginson                 david at

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as:
To (un)subscribe, mailto:majordomo at the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list