0

XML スキーマに問題があります。XML ファイルに HTML コードを挿入する必要があり、xs:any が役立つことがわかりました。しかし、xmllint は次のようなエラーを返します。

example.xml:4: element h1: Schemas validity error : Element 'h1': This element is not expected. Expected is ( {http://www.w3.org/1999/xhtml}* ).

XML:

<?xml version="1.0" encoding="UTF-8"?>
<foo>
<bar>
    <h1>Lorem ipsum</h1>
</bar>
</foo>

スキーマ:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="foo">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="bar" minOccurs="1" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:sequence>
                        <xs:any namespace="http://www.w3.org/1999/xhtml" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>
</xs:schema>

私は何を間違っていますか?

4

1 に答える 1

3

スキーマによると、各bar要素にはhttp://www.w3.org/1999/xhtml名前空間にある要素を 1 つ含めることができますが、インスタンス ドキュメントh1では、名前空間にないという名前の要素を使用しています。xmlns="http://www.w3.org/1999/xhtml"を配置するかh1、ツリーのさらに上にプレフィックス宣言を配置して (例: <foo xmlns:h="http://www.w3.org/1999/xhtml">)、そのプレフィックスを XHTML 要素 ( <h:h1>) で使用する必要があります。

于 2014-02-17T09:39:59.307 に答える