W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2008

Re: Repeating elements with fixed attribute values

From: Boris Kolpackov <boris@codesynthesis.com>
Date: Sat, 5 Jan 2008 17:20:40 +0200
To: "King, Jeffrey (Mission Systems)" <Jeff.King@ngc.com>
Cc: xmlschema-dev@w3.org
Message-ID: <20080105152040.GA22909@karelia>

Hi Jeffrey,

King, Jeffrey (Mission Systems) <Jeff.King@ngc.com> writes:

> However, I am wondering that if XML Schema 1.0 does not support it,
> then maybe it's trying to tell me it's not good approach.  Are there
> any reasons (other than XML Schema 1.0 does not support it) why using
> the design I presented below is poor?

You are overloading the same entity (the 'field' element) with many
"roles" (e.g., it can be field1, field2, etc.). The different roles
are distinguished by a combination of values in attributes/elements.
A simpler design would be to have one element for one and only one
role and make this role explicit in element's name, for example:

  <word name="one">
    <field1 number="1">any string here</field>
    <field2 number="2">any string here</field>
    <field3 number="3">any string here</field>
  <word name="two">
    <field4 number="4">any string here</field>
    <field5 number="5">any string here</field>
    <field6 number="6">any string here</field>

Now you can use the XML Schema 1.0 mechanisms to make the 'number'
attribute fixed to a specific value. In fact, because there appears
to be a 1-to-1 relationship between element's name and attribute's
value, you can get rid of the attribute all together since it does
not carry any useful information (its value is implied by element's


Boris Kolpackov
Code Synthesis Tools CC
XML Parsing and XML Schema Validation for Embedded Systems
Received on Saturday, 5 January 2008 15:34:54 UTC

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