I'm new to XML validation and I'm having an issue I don't understand.
I'm using the Python xmlschema
library to validate XML files against XSD files I generated using the MS xsd tool. After creating many XSD schemas that worked fine I'm having the following issue with the latest XSD
XML file C:/Users/xxxxxxxxxx/XMLfiles/ADAMIntegration/google\RLS22770.manifest.xml not valid: failed validating <Element '{http://www.movielabs.com/schema/manifest/v1.8/manifest}ServiceProvider' at 0x000001B4A7ADE458> with XsdGroup(model='sequence', occurs=[1, 1]):
Reason: Unexpected child with tag 'app1:DisplayName' at position 1. Tag mstns:DisplayName expected.
Schema:
<xs:complexType xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:sequence> <xs:element fixed="premiere" name="DisplayName" type="xs:string" msdata:Prefix="md" /> </xs:sequence> </xs:complexType>
Instance:
<manifest:ServiceProvider xmlns:manifest="http://www.movielabs.com/schema/manifest/v1.8/manifest" xmlns:md="http://www.movielabs.com/schema/md/v2.7/md"> <md:DisplayName>premiere</md:DisplayName> </manifest:ServiceProvider>
Path: /manifest:MediaManifest/manifest:Source/manifest:ServiceProvider
How can I fix this error?
Update: It seems it's looking for "DisplayName" in http://www.movielabs.com/schema/manifest/v1.8/manifest while, as far as I can tell, it is actually in http://www.movielabs.com/schema/md/v2.7/md
XSD file #1 episode_manifest.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="MediaManifest" targetNamespace="http://www.movielabs.com/schema/manifest/v1.8/manifest" xmlns:mstns="http://www.movielabs.com/schema/manifest/v1.8/manifest" xmlns="http://www.movielabs.com/schema/manifest/v1.8/manifest" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:app1="http://www.movielabs.com/schema/md/v2.7/md">
<xs:import namespace="http://www.movielabs.com/schema/md/v2.7/md" schemaLocation="episode_manifest_app1.xsd" />
<xs:element name="ContainerReference" msdata:Prefix="manifest">
<xs:complexType>
<xs:sequence>
<xs:element name="ContainerLocation" msdata:Prefix="manifest" type="containerLocation" msdata:Ordinal="0" />
</xs:sequence>
<xs:attribute name="type" form="unqualified" type="xs:string" fixed="common" />
</xs:complexType>
</xs:element>
<xs:element name="MediaManifest" msdata:IsDataSet="true" msdata:Locale="en-US" msdata:Prefix="manifest">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Compatibility" msdata:Prefix="manifest">
<xs:complexType>
<xs:sequence>
<xs:element name="SpecVersion" msdata:Prefix="manifest" type="xs:string" fixed="1.8" />
<xs:element name="Profile" msdata:Prefix="manifest" type="xs:string" fixed="MMC-1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Source" msdata:Prefix="manifest">
<xs:complexType>
<xs:sequence>
<xs:element name="ServiceProvider" msdata:Prefix="manifest" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="DisplayName" msdata:Prefix="md" type="xs:string" fixed="premiere" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Licensor" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="DisplayName" msdata:Prefix="md" type="xs:string" fixed="network" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Inventory" msdata:Prefix="manifest">
<xs:complexType>
<xs:sequence>
<xs:element name="Audio" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Type" msdata:Prefix="md" type="xs:string" fixed="primary" msdata:Ordinal="0" />
<xs:element ref="app1:Channels" minOccurs="0" msdata:Ordinal="2" />
<xs:element ref="app1:Encoding" />
<xs:element ref="app1:Language" />
<xs:element ref="ContainerReference" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="AudioTrackID" form="unqualified" type="audioTrackID" />
</xs:complexType>
</xs:element>
<xs:element name="Video" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Type" msdata:Prefix="md" type="xs:string" fixed="primary" msdata:Ordinal="0" />
<xs:element ref="app1:Encoding" />
<xs:element ref="app1:Picture" />
<xs:element ref="ContainerReference" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="VideoTrackID" form="unqualified" type="videoTrackID" />
</xs:complexType>
</xs:element>
<xs:element name="Subtitle" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="app1:Format" minOccurs="0" msdata:Ordinal="0" />
<xs:element name="Type" msdata:Prefix="md" type="xs:string" fixed="SDH" msdata:Ordinal="1" />
<xs:element ref="app1:Language" />
<xs:element ref="ContainerReference" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="SubtitleTrackID" form="unqualified" type="subtitleTrackID" />
</xs:complexType>
</xs:element>
<xs:element name="Image" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="app1:Purpose" minOccurs="0" msdata:Ordinal="0" />
<xs:element ref="app1:Width" minOccurs="0" msdata:Ordinal="1" />
<xs:element ref="app1:Height" minOccurs="0" msdata:Ordinal="2" />
<xs:element ref="app1:Encoding" />
<xs:element ref="app1:Language" />
<xs:element ref="ContainerReference" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="ImageID" form="unqualified" type="imageID" />
</xs:complexType>
</xs:element>
<xs:element name="Metadata" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="ContainerReference" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="ContentID" form="unqualified" type="contentID" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Presentations" msdata:Prefix="manifest">
<xs:complexType>
<xs:sequence>
<xs:element name="Presentation" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="TrackMetadata" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="TrackSelectionNumber" msdata:Prefix="manifest" type="xs:string" fixed="0" />
<xs:element name="VideoTrackReference" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="VideoTrackID" msdata:Prefix="manifest" type="videoTrackID" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="AudioTrackReference" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="AudioTrackID" msdata:Prefix="manifest" type="audioTrackID" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SubtitleTrackReference" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="SubtitleTrackID" msdata:Prefix="manifest" type="subtitleTrackID" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Purpose" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="WorkType" msdata:Prefix="manifest" type="xs:string" fixed="Episode" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="PresentationID" form="unqualified" type="presentationID" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Experiences" msdata:Prefix="manifest">
<xs:complexType>
<xs:sequence>
<xs:element name="Experience" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="ContentID" msdata:Prefix="manifest" type="contentID" minOccurs="0" msdata:Ordinal="1" />
<xs:element name="Region" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="app1:country" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Audiovisual" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Type" msdata:Prefix="manifest" type="xs:string" fixed="Main" msdata:Ordinal="0" />
<xs:element name="SubType" msdata:Prefix="manifest" type="xs:string" fixed="Episode" msdata:Ordinal="1" />
<xs:element name="PresentationID" msdata:Prefix="manifest" type="presentationID" minOccurs="0" msdata:Ordinal="2" />
</xs:sequence>
<xs:attribute name="ContentID" form="unqualified" type="contentID" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="ExperienceID" form="unqualified" type="experienceID" />
<xs:attribute name="version" form="unqualified" type="xs:string" fixed="1.0" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ALIDExperienceMaps" msdata:Prefix="manifest">
<xs:complexType>
<xs:sequence>
<xs:element name="ALIDExperienceMap" msdata:Prefix="manifest" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="ALID" msdata:Prefix="manifest" type="xs:string" minOccurs="0" />
<xs:element name="ExperienceID" msdata:Prefix="manifest" nillable="true" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent msdata:Prefix="manifest" msdata:ColumnName="ExperienceID_Text" msdata:Ordinal="1">
<xs:extension base="xs:string">
<xs:attribute name="condition" form="unqualified" type="xs:string" fixed="For-sale" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:simpleType name="containerLocation">
<xs:restriction base="xs:string">
<xs:pattern value="file://([A-z\-.0-9]+)" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="audioTrackID">
<xs:restriction base="xs:string">
<xs:pattern value="md:audtrackid:eidr-x:([A-z\-.0-9]+):episode.audio.en.20" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="videoTrackID">
<xs:restriction base="xs:string">
<xs:pattern value="md:vidtrackid:eidr-x:([A-z\-.0-9]+):episode.video" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="subtitleTrackID">
<xs:restriction base="xs:string">
<xs:pattern value="md:subtrackid:eidr-x:([A-z\-.0-9]+):episode.sdh.en" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="imageID">
<xs:restriction base="xs:string">
<xs:pattern value="md:imageid:eidr-x:([A-z\-.0-9]+):episode.thumbnail.en" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="contentID">
<xs:restriction base="xs:string">
<xs:pattern value="md:cid:eidr-x:([A-z\-.0-9]+):episode" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="presentationID">
<xs:restriction base="xs:string">
<xs:pattern value="md:presentationid:eidr-x:([A-z\-.0-9]+):episode" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="experienceID">
<xs:restriction base="xs:string">
<xs:pattern value="md:experienceid:eidr-x:([A-z\-.0-9]+):episode" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
XSD file #2 episode_manifest_app1.xsd
<?xml version="1.0" standalone="yes"?>
<xs:schema targetNamespace="http://www.movielabs.com/schema/md/v2.7/md" xmlns:mstns="http://www.movielabs.com/schema/manifest/v1.8/manifest" xmlns="http://www.movielabs.com/schema/md/v2.7/md" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:app1="http://www.movielabs.com/schema/md/v2.7/md">
<xs:import namespace="http://www.movielabs.com/schema/manifest/v1.8/manifest" schemaLocation="episode_manifest.xsd" />
<xs:element name="Encoding" msdata:Prefix="md">
<xs:complexType>
<xs:sequence>
<xs:element name="Codec" msdata:Prefix="md" type="xs:string" minOccurs="0" />
<xs:element name="ChannelMapping" msdata:Prefix="md" type="xs:string" minOccurs="0" fixed="Lt,Rt" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Language" msdata:Prefix="md" nillable="true">
<xs:complexType>
<xs:simpleContent msdata:Prefix="md" msdata:ColumnName="Language_Text" msdata:Ordinal="1">
<xs:extension base="xs:string">
<xs:attribute name="dubbed" form="unqualified" type="xs:string" fixed="false" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="Channels" msdata:Prefix="md" type="xs:string" fixed="2" />
<xs:element name="Picture" msdata:Prefix="md">
<xs:complexType>
<xs:sequence>
<xs:element name="AspectRatio" msdata:Prefix="md" type="xs:string" minOccurs="0" />
<xs:element name="WidthPixels" msdata:Prefix="md" type="xs:string" minOccurs="0" />
<xs:element name="HeightPixels" msdata:Prefix="md" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Format" msdata:Prefix="md" type="xs:string" fixed="SCC" />
<xs:element name="Purpose" msdata:Prefix="md" type="xs:string" fixed="thumbnail" />
<xs:element name="Width" msdata:Prefix="md" type="xs:string" />
<xs:element name="Height" msdata:Prefix="md" type="xs:string" />
<xs:element name="country" msdata:Prefix="md" type="xs:string" />
</xs:schema>