title: Is it possible to create an XSD schema for an XSD schema, or place restrictions on element definitions? How?
body: <p>My goal is to place a simple restriction on my XSD element definitions: I want to define an element so that </p>
  
  <ol>
  <li><code>&lt;xs:annotation&gt;&lt;xs:documentation&gt;</code> is reqired for all element definitions<code>&lt;/xs:documentation&gt;&lt;/xs:annotation&gt;</code> </li>
  <li>"declared" and "last_modified" attributes are added to the <code>&lt;xs:element&gt;</code> and "note_author" and "note_added" attributes are added to the <code>&lt;xs:documentation&gt;</code> element.</li>
  </ol>
  
  <p>With what I have below, I am able to get Schema 2 to validate, but I am unable to enforce the rules that I mentioned above, which I would like to declare in Schema 1.</p>
  
  <p>Example of what I want to achieve with the modified, validated XSD schema (Schema 2):</p>
  
  <p>Schema2.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
             xmlns:ds="http://documentation_schema"&gt;
  
    &lt;xs:import namespace="http://documentation_schema" 
               schemaLocation="documentation_schema.xsd"/&gt;
  
    &lt;xs:element name="document" 
                ds:created="2013-06-20" 
                ds:last_modified="2013-06-20"&gt;
  
      &lt;xs:annotation&gt;
        &lt;xs:documentation ds:note_author="xsd_user1" 
                          ds:note_added="2013-06-20"&gt;
        The root element for a document
        &lt;/xs:documentation&gt;
      &lt;/xs:annotation&gt;
  
      &lt;xs:complexType&gt;
        &lt;xs:sequence maxOccurs="unbounded"&gt;
          &lt;xs:element ref="subelement"/&gt;
        &lt;/xs:sequence&gt;    
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  
    &lt;xs:element name="subelement" type="xs:string"  
                ds:created="2013-06-20" 
                ds:last_modified="2013-07-20"&gt;
  
      &lt;xs:annotation&gt;
        &lt;xs:documentation ds:note_author="xsd_user1" 
                          ds:note_added="2013-06-20"&gt;
        A subelement child of document
        &lt;/xs:documentation&gt;
  
        &lt;xs:documentation ds:note_author="xsd_user2" 
                          ds:note_added="2013-07-20"&gt;
        changed from complex to string type
        &lt;/xs:documentation&gt;
      &lt;/xs:annotation&gt;`
    &lt;/xs:element&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>Schema 1 (documentation_schema) -- the schema that I want to do the validating of Schema 2:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
             targetNamespace="http://documentation_schema"&gt;
  
    &lt;xs:attribute name="created" type="xs:date"/&gt;
  
    &lt;xs:attribute name="last_modified" type="xs:date"/&gt;
  
    &lt;xs:attribute name="note_added" type="xs:date"/&gt;
  
    &lt;xs:attribute name="note_author"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:token"&gt;
          &lt;xs:enumeration value="xsd_user1"/&gt;
          &lt;xs:enumeration value="xsd_user2"/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:attribute&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>