W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2003

Re: MSXML Validation Fails - Error 1072898035

From: Jeni Tennison <jeni@jenitennison.com>
Date: Tue, 9 Sep 2003 16:51:58 +0100
Message-ID: <38-2114838637.20030909165158@jenitennison.com>
To: "EVANGELISTA Luca" <luca@webmediastrategy.com>
Cc: xmlschema-dev@w3.org

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:39 GMT