W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2003

Attributes vs. Elements for Code values

From: Jack Lindsey <Jack@Ottawa.com>
Date: Wed, 16 Apr 2003 21:09:31 -0400
Message-ID: <000801c3047e$00fbd3c0$dfa27018@slnt.phub.net.cable.rogers.com>
To: <xmlschema-dev@w3.org>

I want to use XML attributes to hold terse code values (e.g. "CA-BC", "312120", "23") that are replaced by text in the language of your choice from lookup tables in XML files (e.g. "Colombie-Britannique",  "Breweries", "Cul-de-sac") when the XML data is rendered on a web page.  However, some of my colleagues suffer from generalized attribute phobia and want to do everything with XML elements.  I don't see the danger.  Here are my pros and cons.  What do you think?

1. Attributes mean much more compact XML data
2. Processing attributes is much more efficient in XSLT and DOM
3. Everybody does codes this way

1. Other people's schemas can't just reuse your codes without also using the surrounding element, unless you declare your code attributes globally? Is that right?
2. If an element can have multiple values of a code (like Disability in Being in the example below), you have to create an element for it anyway so it can occur multiply, and that is the worst option, performance-wise (according to Scott Bonneau, XML Design handbook, p. 43)
3. You don't get that nice XML schema diagrammatic documentation for your attributes in XML Spy.

Sample Data:

<Being beingSerialNumber="0002345" genderID="3" speciesID="42"> 
  <Disability disabilityID="17"/> 
  <Disability disabilityID="24"/>   
  <MedicalConditionNarrative medicalConditionID="23">Not responding to
  <MedicalConditionNarrative medicalConditionID="16">Clearing up

Cheers Jack
Received on Wednesday, 16 April 2003 21:13:48 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:10 UTC