Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can <strong>redefine</strong> schema, extending them however you like. In this way, you can modify the definitions of an existing schema without actually changing the file. BUT IT WON'T WORK FOR YOUR EXAMPLE as given, because one can't redefine elements (only complexTypes, etc. see <a href="http://www.w3.org/TR/xmlschema-1/#element-redefine" rel="nofollow noreferrer">http://www.w3.org/TR/xmlschema-1/#element-redefine</a>). Therefore, I've broken your example into explicit complexTypes, so they are exposed for redefinition.</p> <p><strong>RedefineOtherSchema.xsd:</strong></p> <pre><code>&lt;xs:schema id="RedefineOtherSchema" targetNamespace="http://tempuri.org/OtherSchema" elementFormDefault="qualified" xmlns="http://tempuri.org/OtherSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m="http://tempuri.org/MySchema"&gt; &lt;!-- for the ref --&gt; &lt;xs:import schemaLocation="MySchema.xsd" namespace="http://tempuri.org/MySchema"/&gt; &lt;!-- import --&gt; &lt;xs:redefine schemaLocation="OtherSchema.xsd"&gt; &lt;!-- redefine --&gt; &lt;xs:complexType name="SomeOtherElement"&gt; &lt;xs:complexContent&gt; &lt;xs:extension base="SomeOtherElement"&gt; &lt;xs:attribute ref="m:myAttribute" /&gt; &lt;!-- the ref --&gt; &lt;/xs:extension&gt; &lt;/xs:complexContent&gt; &lt;/xs:complexType&gt; &lt;/xs:redefine&gt; &lt;/xs:schema&gt; </code></pre> <p><strong>OtherSchema:</strong></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" type="SomeElement"/&gt; &lt;xs:complexType name="SomeElement"&gt; &lt;xs:sequence&gt; &lt;xs:element minOccurs="0" maxOccurs="unbounded" name="someOtherElement" type="SomeOtherElement"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="SomeOtherElement"&gt; &lt;xs:attribute name="someAttribute" /&gt; &lt;/xs:complexType&gt; &lt;/xs:schema&gt; </code></pre> <p><strong>MySchema:</strong> (unchanged)</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><strong>Why <code>&lt;complexContent&gt;</code>?</strong> The redefinition must be an extension (or restriction) of the existing type - that's how it modifies the previous definition. Extension must be in <code>&lt;complexContent&gt;</code> (I believe).</p> <p><strong>Why <code>&lt;import&gt;</code>?</strong> You can't define things in more than one namespace in a xsd (there is only one "targetNamespace"). But you can get around this by importing a definition from another xsd (then you've not "defining" it). [is there is another way?]</p> <p>HTH :-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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