私はそのようなフォーマットのXMLドキュメントを持っています:
<?xml version="1.0" encoding="utf-8"?>
<books-feed xmlns="{NS-URL}">
<generation-date>{DATE}</generation-date>
<book id="{BOOK-ID}">
<title>{BOOK-TITLE}</title>
<author>{BOOK-AUTHOR}</author>
.......................................... ← other information tags [any]
</book>
.............................................. ← other <book> elements
</books-feed>
そして、私はこのXSDスキーマでこのファイルを検証しようとしています:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="books-feed">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="generation-date" type="xsd:string"/>
<xsd:element name="book" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:any maxOccurs="unbounded" processContents="lax"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:integer" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
したがって、DOMDocument :: schemaValidate()はFALSEを返します。この問題は名前空間にありますか(books-feed xmlns = "{NS-URL}"はスキーマxmlnsと等しくありません)?または、xmlnsブックフィードのxsd:attributeをスキーマに挿入する必要があります(「無効なスキーマ」警告が発生します)。または何?