0

XML ファイルを検証するためのblog.xmlBlog.xsdがあります。http://www.xmlvalidation.com/?L=0を使用して両方のファイルを検証していますが、エラーが発生しています。

何が悪いのか教えていただけますか?

エラー: ここに画像の説明を入力

ブログ.xml:

http://pastebin.com/He3xCxxC (申し訳ありませんが、pastebin に投稿する必要がありました (SO の文字数制限のため)

ブログ.xsd:

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="blog">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="post" maxOccurs="unbounded" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element type="xs:string" name="ptitle"/>
              <xs:element type="xs:string" name="psubtitle"/>
              <xs:element type="xs:anyURI" name="image"/>
              <xs:element type="xs:string" name="author"/>
              <xs:element type="xs:string" name="date"/>
              <xs:element type="xs:string" name="par"/>
              <xs:element type="xs:anyURI" name="source"/>
              <xs:element type="xs:string" name="comments"/>
            </xs:sequence>
            <xs:attribute type="xs:byte" name="id" use="optional"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
4

1 に答える 1

1

スキーマのtargetNamespace(つまり、" http://www.w3schools.com ") が設定されていません。

<xs:schema attributeFormDefault="unqualified" targetNamespace="http://www.w3schools.com" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

名前空間とschemalocationスキーマを指定する必要があります。これが、 に偶数の要素が必要な理由ですschemaLocation

<a:blog xmlns:a="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com ./Blog.xsd">
于 2013-01-29T15:18:01.760 に答える