W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2002

Problem with UNIQUE constraint

From: Gary Cramblitt <garycramblitt@comcast.net>
Date: Tue, 26 Mar 2002 19:56:25 -0500
To: xmlschema-dev@w3.org
Message-id: <3CA0D269.29536.3447D8@localhost>
I'm having a problem defining UNIQUE constraints.  When I 
validate my schema using Schema Quality Checker (SQC), it 

  <xs:field xpath="RadioService"/>

evaluates to

  <xs:element name="RadioService" maxOccurs="1" 
minOccurs="1" nillable="false" type="HasClassification"/> whose 
type is not a simple type.

Here's a fragment of my schema
  <xs:simpleType name="SecurityPickList">
    <xs:restriction base="xs:string">
      <xs:enumeration value="U"/> <!-- Unclassified -->
      <xs:enumeration value="C"/> <!-- Confidential -->
      <xs:enumeration value="S"/> <!-- Secret -->
      <xs:enumeration value="T"/> <!-- Top Secret -->
 <xs:complexType name="HasClassification">
      <xs:extension base="xs:string">
        <xs:attribute name="Class" type="SecurityPickList" 
  <xs:element name="Rec_SelRadioSrvc" minOccurs="0" 
        <xs:element name="LineID"/>
        <xs:element name="RadioService" type="HasClassification"/>
      <xs:attribute name="id" type="xs:string" use="required"/>
    <xs:unique name="ID_SelRadioSrvc">
      <xs:selector xpath="."/>
      <xs:field xpath="LineID"/>
      <xs:field xpath="RadioService"/> <!-- ERROR OCCURS HERE 
  </xs:element> <!-- Rec_SelRadioSrvc -->

Obviously, the error occurs because the field xpath resolves to a 
complexType called "HasClassification".  But HasClassification is 
an element with simpleContent and an optional attribute.  Basically, 
I'm trying to create a schema to describe a database export.  Most 
of the data items in the database have an optional attribute called 
"Class" which is the classification (Unclassified, Confidential, or 
Secret) of the data item.

Can anyone suggest a workaround?  Is there some way to define 
the xpath to resolve only to the RadioService element so that the 
schema will validate?

Gary Cramblitt
Received on Tuesday, 26 March 2002 19:57:05 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:55 UTC