2
我有XML:如何匹配元素,但如果存在属性,则避免验证失败?
<video contenttype="asf" fileextension=".wmv" hascontent="no" lang="en-GB" length="1800" pid="3678738364972" sid="">
<title>A vid with Pete</title>
<description>Petes vid</description>
<contributor>Pete</contributor>
<subject>Cat 2</subject>
</video>
我要验证的视频元素存在使用XSD架构,但我真的不关心什么属性有(其实我想忽略的属性)。我关心的是视频元素的存在。是否有可能用xsd做到这一点?
目前XSD是:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="UploadXSD"
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" type="xs:string"></xs:element>
<xs:element name="contributor" type="xs:string"></xs:element>
<xs:element name="subject" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>