Modelling enumeration of complex types and use of duplicated elements

Hi,

We're having problems with the constraint in XML Schema that element
names must be unique in type definitions.

Sorry for the long examples, but we wanted to show that this isn't a
obscure case, but one which occurs in a number of places.  Two examples
are provided of where this need has been encountered.


Problem 1: The first problem involves providing an enumerated list of
complex types. We've got the following definition for a medical term,
where it is necessary to provide codes for the term itself and the
medical term set (or thesaurus) where the codes come from. (So there is
no ambiguity of meaning.)

<complexType name="TERM_TEXT">
 <element name="value" type="string"/>
 <element name="term_set" type="string"/>
 <element name="primary" type="TERM_REF"/>
 <element name="qualifier" type="TERM_REF"
          minOccurs="0" maxOccurs="unbounded"/>
</complexType>

<complexType name="TERM_REF">
 <element name="code" type="string"/>
 <element name="expansion" type="string"/>
</complexType>

An example term text is:

<term>
 <value>right ear</value>
 <term_set>UMLS</term_set>
 <primary>
  <code>0012</code>
  <expansion>ear</expansion>
 </primary>
 <qualifier>
  <code>0013</code>
  <expansion>right</expansion>
 </qualifier>
</term>

In our schema, we need to place a constraint on the possible terms that
can be used for a certain field. For example, a "patient_position" field
in a blood pressure test must be "sitting", "lying", or "standing",
where these values are term texts. That is, the element is a term, but
must only be one of those three rather than any other term.

What we'd like to do is constrain the schema to just these three choices:

<choice>
 <element name="patient_position" type="LyingTerm"/>
 <element name="patient_position" type="SittingTerm"/>
 <element name="patient_position" type="StandingTerm"/>
</choice>

<complexType name="LyingTerm" base="TERM_TEXT" derivedBy="restriction">
 <element name="value" fixed="Lying"/>
 <element name="term_set" fixed="UMLS"/>
 <element name="primary">
  <complexType base="TERM_REF" derivedBy="restriction">
   <element name="code" fixed="0011"/>
   <element name="expansion" fixed="Lying"/>
  </complexType>
 </element>
</complexType>
(ditto for SittingTerm and StandingTerm)

But this is not allowed in XML Schema because element names must be
unique.

The best solution we've come up with uses groups:

<complexType name="TERM_TEXT">
 <group ref="TERM_TEXT_GROUP"/>
</complexType>

<group name="TERM_TEXT_GROUP">
 <element name="value" type="string"/>
 <element name="term_set" type="string"/>
 <element name="primary" type="gom:TERM_REF"/>
 <element name="qualifier" type="gom:TERM_REF"
          minOccurs="0" maxOccurs="unbounded"/>
</group>

<element name="patient_position" type="PositionTerm"/>

<complexType name="PositionTermTmp" base="TERM_TEXT" derivedBy="extension">
 <group ref="TERM_TEXT_GROUP" minOccurs="0" maxOccurs="0"/>
</complexType>

<complexType name="PositionTerm" base="PositionTermTmp" derivedBy="extension">
 <choice>
  <group ref="p:LyingTermGroup"/>
  <group ref="p:SittingTermGroup"/>
  <group ref="p:StandingTermGroup"/>
 </choice>
</complexType>

<group name="LyingTermGroup">
 <element name="value" type="Lying"/>
 <element name="term_set" fixed="UMLS"/>
 <element name="primary">
  <complexType="gom:TERM_REF">
   <element name="code" fixed="0011"/>
   <element name="expansion" fixed="Lying"/>
  </complexType>
 </element>
</group>
(ditto for SittingTermGroup and StandingTermGroup)


Is this solution valid?  If not, how can this be made to work?
Is there a better solution that we've missed?



Problem 2: The second problem is restricting a generic list of elements
to a list of specific elements. The example is from the metadata
domain. We define a metadata record as the following:

<complexType name="Record">
 <element name="tuple" type="Tuple" minOccurs="0" maxOccurs="unbounded"/>
</complexType>

<complexType name="Tuple">
 <element name="name" type="string"/>
 <element name="value"/>
 <element name="qualifier" type="Qualifier"
          minOccurs="0" maxOccurs="unbounded"/>
</complexType>

<complexType name="Qualifier">
 <element name="name" type="string"/>
 <element name="value"/>
</complexType>

We'd like to create a metadata record for a specific standard such as
Dublin Core which as a fixed set of types. So, we'd like to do the
following:

<complexType name="DublinCoreRecord" base="Record" derivedBy="restriction">
 <element name="tuple" type="DC.Identifier"/>
 <element name="tuple" type="DC.Title"/>
 <element name="tuple" type="DC.Date"/>
 ... etc ...
</complexType>

<complexType name="DC.Identifier" base="Tuple" derivedBy="restriction">
 <element name="name" type="string" fixed="DC.Identifier"/>
 <element name="value" type="string"/>
 ... etc ...
</complexType>

Again, we cannot do so because the names of the element in the first
complex type are not unique.

Is there anyway to do this with XML Schema?

Thanks.

Hoylen
-- 
__________________________________________________ Dr Hoylen Sue
h.sue@dstc.edu.au                        http://www.dstc.edu.au/
DSTC Pty Ltd --- Australian W3C Office           +61 7 3365 4310

Received on Wednesday, 13 September 2000 02:37:15 UTC