开发者

How do I match an element but avoid failing validation if attributes are present?

I have the 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>

And I want to validate the video element is present using an xsd schema but I really dont care what attributes it has (in fact I want to ignore the attributes). All I care about is the video element being present. Is开发者_运维百科 it possible to do this with xsd?

Currently the xsd is:

<?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>


Yes, just specify xs:anyAttribute in your complexType element, after the sequence: here's a link.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜