You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2003/03/20 00:32:34 UTC

DO NOT REPLY [Bug 18173] New: - composite ids no longer allow the xs:unique constraint have optional fields.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18173>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18173

composite ids no longer allow the xs:unique constraint have optional fields.

           Summary: composite ids no longer allow the xs:unique constraint
                    have optional fields.
           Product: Xerces2-J
           Version: 2.3.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: XML Schema datatypes
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: twilight_fades57@hotmail.com


In schemas: The fields in a xs:unique constraints are optional, (which makes 
them different from the xs:key) however when composite fields are constructed, 
xerces treats the the fields as required. For example: 
using this schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           elementFormDefault="qualified" attributeFormDefault="unqualified"> 
   <xs:element name="Disney" type="Characters">
     <xs:unique name="complexTypeUniqueId">
       <xs:selector xpath="Name"/>
         <xs:field xpath="@UniqueId"/>
         <xs:field xpath="Color"/>
     </xs:unique>
   
   </xs:element>
   <xs:complexType name="Characters">
      <xs:sequence>
         <xs:element name="Name" type="CharacterType" minOccurs="0" 
maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>
   <xs:complexType name="CharacterType">
     <xs:sequence>
       <xs:element name="Color" type="xs:string"/>
     </xs:sequence>
     <xs:attribute name="UniqueId" type="xs:int" use="optional"/>
   </xs:complexType>
</xs:schema> 
-----------------------------------------------------
insert this document:
<Disney>
    <Name>
      <Color>red</Color>
    </Name>
    <Name UniqueId="5">
      <Color>red</Color>
    </Name>
</Disney>

----------------
In theory that document should work and be valid because UniqueId attribute is 
optional, and the unique constraint should be ok with it. However when this is 
entered it throws an exception:
SAXParseException: Not enough values specified for &lt;unique&gt; identity 
constraint specified for element &quot;Disney&quot;

I think this is wrong because nowhere in the schema spec says that compisite 
unique ids nullify the optionalality of nodes.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org