名前空間を使用するときにスキーマを参照するときの正しい構文は何ですか?
問題
指定されたスキーマを使用して XML ドキュメントを作成します。
エラー
.xml:9.20: Element '{http://example/buildings/1.0}old_buildings': No matching global declaration available for the validation root.
oldbuildings.xml - invalid
Problem
XML ドキュメント
<?xml version="1.0" encoding="UTF-8"?>
<buildings:old_buildings xmlns:buildings="http://example/buildings/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example/buildings/1.0 oldbuildings_schema.xsd">
<building>
<name>Name</name>
<year_built era="BC">2000</year_built>
<story>...<story>
</building>
</buildings:old_buildings>
XSD ドキュメント
<?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="http://example/buildings/1.0/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://example/buildings/1.0/ "> <xs:element name="old_buildings"> <xs:complexType> <xs:シーケンス> <xs:element ref="建物"/> </xs:シーケンス> </xs:complexType> </xs:要素> <xs:要素名="建物" タイプ="建物タイプ"></xs:要素> <xs:complexType name="建物の種類"> <xs:シーケンス> <xs:要素名="名前" タイプ="xs:文字列"/> <xs:element name="year_built" type="yearType"/> <xs:element name="story" type="xs:string"/> </xs:シーケンス> </xs:complexType> <xs:complexType name="yearType"> <xs:シンプルコンテンツ> <xs:extension base="xs:positiveInteger"> <xs:attribute name="era" type="xs:string"/> </xs:拡張子> </xs:シンプルコンテンツ> </xs:complexType> </xs:スキーマ>