以下 xml 针对提供的 xsd 文档进行验证。但是,当我开始从 xml 中删除元素时,它仍然可以验证!?
如何编写强制包含元素的 xsd?
<?xml version="1.0" encoding="UTF-8"?>
<Video>
<Title>
</Title>
<Description>
</Description>
<Contributor>
</Contributor>
<Subject>
</Subject>
</Video>
然后我有xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="UploadXSD"
targetNamespace="http://tempuri.org/UploadXSD.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/UploadXSD.xsd"
xmlns:mstns="http://tempuri.org/UploadXSD.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Video">
<xs:complexType>
<xs:sequence>
<xs:element name="Title" minOccurs="1" type="xs:string"></xs:element>
<xs:element name="Description" minOccurs="1" type="xs:string"></xs:element>
<xs:element name="Contributor" minOccurs="1" type="xs:string"></xs:element>
<xs:element name="Subject" minOccurs="1" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>