定義により:
noNamespaceSchemaLocation属性は、ターゲット名前空間を持たないXMLスキーマドキュメントを参照します。
この属性は、解析の結果をどのように変更しますか?
たとえば、次のXMLを使用します。
<?xml version="1.0"?>
<name
xmlns="http://www.example.com/name"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.com/name schema/schema.xsd"
title="Mr.">
<first>John</first>
<middle>M</middle>
<last>Doe</last>
</name>
このスキーマを参照する:
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:target="http://www.example.com/name"
targetNamespace="http://www.example.com/name" elementFormDefault="qualified">
<element name="name">
<complexType>
<sequence>
<element name="first" type="string"/>
<element name="middle" type="string"/>
<element name="last" type="string"/>
</sequence>
<attribute name="title" type="string"/>
</complexType>
</element>
</schema>
これらの名前空間宣言をスキーマから削除しました。
xmlns:target="http://www.example.com/name"
targetNamespace="http://www.example.com/name"
参照するXMLでnoNamespaceSchemaLocation属性を使用しなくても、エラーはスローされませんでした。そもそもなぜこの属性が必要なのですか?