我是XML验证的新手,我遇到了一个我不明白的问题。我使用PythonXMLSchema
库根据我使用MS XSD工具生成的XSD文件验证XML文件。在创建了许多工作正常的XSD模式后,我在最新的XSD中遇到了以下问题
原因:位置1处标记为“app1:displayname”的意外子级。需要标记mstns:displayname。
架构:
实例:
路径:/manifest:mediaManifest/manifest:source/manifest:serviceprovider
如何修复此错误?
更新:它似乎在http://www.movielabs.com/schema/manifest/v1.8/manifest中寻找“displayname”,而据我所知,它实际上在http://www.movielabs.com/schema/md/v2.7/md中
XSD文件#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>
<?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>
md:displayname
元素显然位于错误的命名空间中。
您没有显示足够的模式,我们无法知道它应该在哪个命名空间中:我们需要查看包含xs:schema
元素的targetnamespace
和elementformdefault
属性。
我没有编写C++代码,因为我的首要任务是创建有效的xml和XSD。 xml: XSD: 为了验证,我转到:https://www.freeformatter.com/xml-validator-xsd.html 错误:s4s-att-invalid-value:元素“Element”中“type”的属性值无效。记录原因:cvc-datatype-valid.1.2.1:“xs:”不是“QName”
我在验证xml和xsd时遇到问题。我从xsd模式中得到这个错误。 src解决方案。4.2:解析组件“urn:id”时出错。检测到“urn:id”位于命名空间“urn:schemas microsoft com:xml-diffgram-v1”中,但此命名空间中的组件无法从架构文档中引用virtual://server/schema.xsd。如果名称空间不正确,可能需要更改“urn:id”的前缀。如
问题内容: 我需要使用给定的XSD文件验证XML文件。我只需要如果验证正常就返回true,否则返回false的方法。 问题答案: 仅返回true或false(也不需要任何外部库):
现在,我正在使用XSD进行XML验证。 由于我使用了SchemaFactory: 然后我尝试切换到apache xerces,得到这个错误(从导入xerces开始): 为什么在android studio中java.exe以值1退出
我正在使用Delphi10.2更新3。我按照这些说明验证生成的xml文档。 属性noNamespaceSchema位置对XML解析有什么影响? 使用Windows DOM和TXMLDocument验证XML:在某些计算机上不起作用 delphi中msxml的模式验证 但我有一个错误。“DTD/架构中未定义元素‘jegyzek\u adatok’上的属性‘noNamespaceSchemaLocat
谁能解释一下如何使用notepad++根据XSD验证xml文件。“XML Tools”插件下拉列表中没有提供指定XSD文件的选项。在plugins子目录中正确安装XML插件,并将3个DLL复制到notepad++EXE子目录。其他XML“验证”特性也可以工作,但无法针对XSD进行验证。