title: How to use elements of xsd type "inline"
body: <p>I have a type representing some tokens corresponding to colors that can be repeated as many times as desired, or not at all (<code>colorType</code>), and an element (<code>main</code>) that interleaves any number of occurrences of colors and arbitrary text:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  
    &lt;xs:complexType name="colorType"&gt;
      &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
        &lt;xs:element name="red" type="xs:string"/&gt;
        &lt;xs:element name="blue" type="xs:string"/&gt;
      &lt;/xs:choice&gt;
    &lt;/xs:complexType&gt;
  
    &lt;xs:element name="main"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
          &lt;xs:element name="color" type="colorType"/&gt;
          &lt;xs:element name="text" type="xs:string" minOccurs="0"/&gt;
        &lt;/xs:choice&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>So I can do this:</p>
  
  <pre><code>&lt;main&gt;
    &lt;text&gt;Beginning&lt;/text&gt;
    &lt;color&gt;&lt;red/&gt;&lt;blue/&gt;&lt;/color&gt;
    &lt;text&gt;Middle&lt;/text&gt;
    &lt;color&gt;&lt;red/&gt;&lt;/color&gt;
    &lt;text&gt;End&lt;/text&gt;
  &lt;/main&gt;
  </code></pre>
  
  <p>What I'd like to do is this:</p>
  
  <pre><code>&lt;main&gt;
    &lt;text&gt;Beginning&lt;/text&gt;
    &lt;red/&gt;&lt;blue/&gt;
    &lt;text&gt;Middle&lt;/text&gt;
    &lt;red/&gt;
    &lt;text&gt;End&lt;/text&gt;
  &lt;/main&gt;
  </code></pre>
  
  <p>In other words, keep <code>colorType</code> as a type definition so it can be re-used elsewhere in the schema, but put elements of that type "inline" as part of the definition of the <code>main</code> element's content (i.e., remove the need for the "<code>color</code>" container).  Eventually, the color types will become complex elements with their own attributes (e.g., "<code>&lt;red bright="true"/&gt;</code>").</p>
  
  <p>I'm still learning XSD, so any pointers in the right direction would be most helpful.</p>