他のスキーマの要素、またはどのスキーマにもない要素に配置できる属性を定義する XSD を作成したいと考えています。たとえば、スキーマは次のようになります。
<xs:schema id="MySchema"
targetNamespace="http://tempuri.org/MySchema"
elementFormDefault="qualified"
xmlns="http://tempuri.org/MySchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:attribute name="myAttribute" />
</xs:schema>
ドキュメントは次のようになります。
<someElement xmlns="http://tempuri.org/OtherSchema" xmlns:m="http://tempuri.org/MySchema">
<someOtherElement someAttribute="value" m:myAttribute="value2" />
</someElement>
この例の「OtherSchema」は次のようになります。
<xs:schema id="OtherSchema"
targetNamespace="http://tempuri.org/OtherSchema"
elementFormDefault="qualified"
xmlns="http://tempuri.org/OtherSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:element name="someElement">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="someOtherElement">
<xs:complexType>
<xs:attribute name="someAttribute" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
検証を実行する C# コンソール アプリケーションを含む完全な例は、http://dl.getdropbox.com/u/407740/SchemaTest.zipからダウンロードできます。私の目標は、「OtherSchema」を変更せずにこれを検証することです。これは可能ですか?