Re: xmlspy validation bug with cos-element-consistent

Hi Scott,

> As a C++ programming my overloading instincts make me want the
> funtionality
> displayed in these examples.  Help me understand why XmlSpy validates
> one
> way in schema view and another way in text view; and also help me
> understand
> why my examples should not be valid. Please.

I can't answer why XML Spy validates in one view and gives errors in another but I can
confirm that your schema is in fact invalid. The reason is the following:

     <xs:complexType>
      <xs:choice>
       <xs:element name="mydate" type="xs:date">
        <xs:annotation>
         <xs:documentation>date</xs:documentation>
        </xs:annotation>
       </xs:element>
       <xs:element name="mydate" type="xs:dateTime">
        <xs:annotation>
         <xs:documentation>date time</xs:documentation>
        </xs:annotation>
       </xs:element>
      </xs:choice>
     </xs:complexType>

In XML Schema you can't have two element declarations with the same name but different
types in the same content model.

Cheers,
/Eddie


>
>
> BEGIN EXAMPLE
> --------------------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- edited with XML Spy v4.3 U (http://www.xmlspy.com) by Scott-->
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" attributeFormDefault="unqualified">
>  <xs:element name="root">
>   <xs:complexType>
>    <xs:sequence>
>     <xs:element name="example1">
>      <xs:annotation>
>       <xs:documentation>Example of the W3C error:
> cos-element-consistent</xs:documentation>
>      </xs:annotation>
>      <xs:complexType>
>       <xs:choice>
>        <xs:element name="mydate" type="xs:date">
>         <xs:annotation>
>          <xs:documentation>date</xs:documentation>
>         </xs:annotation>
>        </xs:element>
>        <xs:element name="mydate" type="xs:dateTime">
>         <xs:annotation>
>          <xs:documentation>date time</xs:documentation>
>         </xs:annotation>
>        </xs:element>
>       </xs:choice>
>      </xs:complexType>
>     </xs:element>
>     <xs:element name="example2">
>      <xs:annotation>
>       <xs:documentation>More subtle version</xs:documentation>
>      </xs:annotation>
>      <xs:complexType>
>       <xs:choice>
>        <xs:sequence>
>         <xs:element name="mydate" type="xs:date">
>          <xs:annotation>
>           <xs:documentation>date</xs:documentation>
>          </xs:annotation>
>         </xs:element>
>         <xs:element name="myValue" type="xs:double"/>
>        </xs:sequence>
>        <xs:sequence>
>         <xs:element name="mydate" type="xs:dateTime">
>          <xs:annotation>
>           <xs:documentation>date time</xs:documentation>
>          </xs:annotation>
>         </xs:element>
>         <xs:element name="myValue" type="xs:double"/>
>        </xs:sequence>
>       </xs:choice>
>      </xs:complexType>
>     </xs:element>
>    </xs:sequence>
>   </xs:complexType>
>  </xs:element>
> </xs:schema>
> ------------------------------------------------------------------
> END EXAMPLE

Received on Thursday, 25 April 2002 20:10:06 UTC