Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Repeating elements with fixed attribute values

From: Boris Kolpackov <boris@-------------.--->
To: "King, Jeffrey (Mission Systems)" <Jeff.King@---.--->
Date: 1/5/2008 7:21:00 PM
Hi Jeffrey,

King, Jeffrey (Mission Systems) <Jeff.King@n...> 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:

<root>
  <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>
  <word name="two">
    <field4 number="4">any string here</field>
    <field5 number="5">any string here</field>
    <field6 number="6">any string here</field>
    ...
  </word>
</Thanks>

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
name).

Boris

-- 
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
XML Parsing and XML Schema Validation for Embedded Systems

From mike@s... Sat Jan 05 16:10:06 2008
Received: from lisa.w3.org ([128.30.52.41])


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent