Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I create an XSD schema that places an attribute on all complex types?
    text
    copied!<p>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:</p> <pre><code>&lt;xs:schema id="MySchema" targetNamespace="http://tempuri.org/MySchema" elementFormDefault="qualified" xmlns="http://tempuri.org/MySchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" &gt; &lt;xs:attribute name="myAttribute" /&gt; &lt;/xs:schema&gt; </code></pre> <p>And the document might look something like this:</p> <pre><code>&lt;someElement xmlns="http://tempuri.org/OtherSchema" xmlns:m="http://tempuri.org/MySchema"&gt; &lt;someOtherElement someAttribute="value" m:myAttribute="value2" /&gt; &lt;/someElement&gt; </code></pre> <p>"OtherSchema" for this example looks like this:</p> <pre><code>&lt;xs:schema id="OtherSchema" targetNamespace="http://tempuri.org/OtherSchema" elementFormDefault="qualified" xmlns="http://tempuri.org/OtherSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" &gt; &lt;xs:element name="someElement"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element minOccurs="0" maxOccurs="unbounded" name="someOtherElement"&gt; &lt;xs:complexType&gt; &lt;xs:attribute name="someAttribute" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; </code></pre> <p>A complete example, including a C# console application which performs validation, can be downloaded from <a href="http://dl.getdropbox.com/u/407740/SchemaTest.zip" rel="nofollow noreferrer">http://dl.getdropbox.com/u/407740/SchemaTest.zip</a>. My goal is to make this validate without having to modify "OtherSchema". Is this possible?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload