I would like to create an XSD that defines an attribute which can be placed on elements from other schemas, or elements that are not in any schema. For example, the schema would look something like this:
<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>
And the document might look something like this:
<someElement xmlns="http://tempuri.org/OtherSchema" xmlns:m="http://tempuri.org/MySchema">
<someOtherElement someAttribute="value" m:myAttribute="value2" />
</someElement>
"OtherSchema" for this example looks like this:
<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>
A complete example, including a C# console application which performs validation, can be downloaded from http://dl.getdropbox.com/u/407740/SchemaTest.zip. My goal is to make this validate without having to modify "OtherSchema". Is this possible?
Thanks for your time!