Re: MSXML Validation Fails - Error 1072898035

Hi Luca,

> While validating this file with XMLSpy I've no errors, but if I try
> to import the file with MSXML this error is returned:
>
> Error : -1072898035
> Line/Col: 2/218
>
> The element 'catalogue' is used but not declared in the DTD/Schema.
>
> Probably it could be a MSXML 4.0 bug... Could you help me to resolve
> it?

Actually, if XML Spy isn't giving you errors, then it's a bug in XML
Spy. Your schema isn't valid: in the complex type definition for the
<catalogue> element, you have:

  <xs:choice>
    <xs:sequence>
      <xs:element name="song">
        <xs:complexType>...</xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:sequence>
      <xs:element name="song">
        <xs:complexType>...</xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:choice>

Here, the two <song> elements have different types, and you're not
allowed to have that in a single content model in XML Schema.

If you changed the element declaration for the <catalogue> element to:

  <xs:element name="catalogue">
    <xs:complexType>                        
      <xs:sequence maxOccurs="unbounded">                                
        <xs:element name="song">                                                        
          <xs:complexType>
            <xs:sequence>
              <xs:element name="barcode" type="barcodeType"/>
              <xs:element name="volume" type="xs:positiveInteger"/>
              <xs:element name="track" type="xs:positiveInteger"/>
              <xs:element name="title" type="notNullStringType"/>
              <xs:element name="duration" type="xs:time"/>
              <xs:element name="price" type="xs:decimal"/>
              <xs:sequence minOccurs="0">
                <xs:element name="previewExpirationDate" type="xs:date"/>
                <xs:element name="previewPrice" type="xs:decimal"/>
              </xs:sequence>
            </xs:sequence>
            <xs:attribute name="ISRC" type="ISRCType" use="optional"/>
            <xs:attribute name="streaming30" type="xs:boolean" use="required"/>
            <xs:attribute name="preview" type="xs:boolean"/>
          </xs:complexType>                                                
        </xs:element>                                        
      </xs:sequence>                
    </xs:complexType>        
  </xs:element>

then your schema would be valid. With this element declaration, both
Xerces-J and MSXML give no errors for the instance that you provided.

I know that this schema isn't exactly the same as what you wanted,
because you want to express the co-occurrence constraint that the
'preview' attribute controls whether the <previewExpirationDate> and
<previewPrice> elements are present or not, but I'm afraid that it's
the closest that you can get with XML Schema. If you need stricter
validation, you need to add some Schematron validation, or switch to
RELAX NG.

Of course you might still get an error with MSXML, for example if it
can't locate the schema, but I suspect that it was just complaining
because it couldn't locate a *valid* schema for the element (and not
giving you a very helpful error message).
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Tuesday, 9 September 2003 11:52:08 UTC