I'm creating a XSD schema for validating a XML file.
The schema is correct for the W3C XML Schema (XSD) Validation page, while for QXmlSchema there's an error. This is a minimal XSD part that generates the error:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://standards.ieee.org/IEEE1516-2010" xmlns:ns="http://standards.ieee.org/IEEE1516-2010" targetNamespace="http://standards.ieee.org/IEEE1516-2010" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2010">
<xs:element name="objectModel" type="objectModelType">
</xs:element>
<xs:complexType name="objectModelType">
<xs:sequence>
<xs:element name="modelIdentification" type="modelIdentificationType">
<xs:annotation>
<xs:documentation>documents certain key identifying information within the object model description</xs:documentation>
</xs:annotation>
</xs:element>
<xs:any namespace="##other" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="modelIdentificationType">
<xs:sequence>
<xs:element name="name" type="NonEmptyString">
<xs:annotation>
<xs:documentation>specifies the name assigned to the object model</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="glyph" minOccurs="0">
<xs:annotation>
<xs:documentation>specifies a glyph to visually represent the model</xs:documentation>
</xs:annotation>
<xs:complexType mixed="true">
<xs:simpleContent>
<xs:extension base="glyphType"/>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:any namespace="##other" minOccurs="0"/>
</xs:sequence>
<xs:attributeGroup ref="commonAttributes"/>
</xs:complexType>
<xs:complexType name="String">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attributeGroup ref="commonAttributes"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="NonEmptyString">
<xs:simpleContent>
<xs:extension base="nonEmptyString">
<xs:attributeGroup ref="commonAttributes"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="glyphType" mixed="true">
<xs:simpleContent>
<xs:extension base="xs:base64Binary">
<xs:attributeGroup ref="commonAttributes"/>
<xs:attribute name="href" type="xs:anyURI"/>
<xs:attribute name="type" type="glyphTypeUnion"/>
<xs:attribute name="height" type="xs:short"/>
<xs:attribute name="width" type="xs:short"/>
<xs:attribute name="alt" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="IdentifierType">
<xs:simpleContent>
<xs:extension base="xs:NCName">
<xs:attributeGroup ref="commonAttributes"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="nonEmptyString">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="glyphTypeUnion">
<xs:union memberTypes="glyphTypeEnumerations xs:string"/>
</xs:simpleType>
<xs:simpleType name="glyphTypeEnumerations">
<xs:restriction base="xs:string">
<xs:enumeration value="BITMAP"/>
<xs:enumeration value="JPG"/>
<xs:enumeration value="GIF"/>
<xs:enumeration value="PNG"/>
<xs:enumeration value="TIFF"/>
</xs:restriction>
</xs:simpleType>
<xs:attributeGroup name="commonAttributes">
<xs:attribute name="notes" type="xs:IDREFS" use="optional"/>
<xs:attribute name="idtag" type="xs:ID" use="optional"/>
<xs:anyAttribute namespace="##other"/>
</xs:attributeGroup>
</xs:schema>
If I copy and paste this schema to the W3C page, it says that's ok.
I create the schema in my program this way:
QXmlSchema schema;
// text is a char array containing the XML file.
schema.load(text);
When i call the load
method, the following message appears in the debug console window:
Error XSDError in Unknown location, at line 52, column 22: complexType element with simpleContent child element must not have a mixed attribute.
If I go to the line number shown in the message I can see that the complexType is the following one:
<xs:complexType name="glyphType" mixed="true">
<xs:simpleContent>
<xs:extension base="xs:base64Binary">
<xs:attributeGroup ref="commonAttributes"/>
<xs:attribute name="href" type="xs:anyURI"/>
<xs:attribute name="type" type="glyphTypeUnion"/>
<xs:attribute name="height" type="xs:short"/>
<xs:attribute name="width" type="xs:short"/>
<xs:attribute name="alt" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
The error message seems clear to me by seeing this part of the XSD, but I don't know why this should be an error.
So for the W3C page this is correct, for Qt is wrong. Which one has the correct interpretation of the complex type with simple content?
This is a minimal example of XML that should be validated (it is in the web page):
<?xml version="1.0" encoding="utf-8"?>
<objectModel xmlns="http://standards.ieee.org/IEEE1516-2010" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://standards.ieee.org/IEEE1516-2010 http://standards.ieee.org/downloads/1516/1516.2-2010/IEEE1516-DIF-2010.xsd">
<modelIdentification>
<name>New</name>
</modelIdentification>
</objectModel>