title: How to Programmatically Update and Add Elements to an XSD
body: <p>I need to programatically update an an existing XSD in java that looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xs:schema xmlns="com/company/common" xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="com/company/common/" elementFormDefault="qualified"&gt;
      &lt;xs:include schemaLocation="DerivedAttributes.xsd" /&gt;
      &lt;xs:element name="MyXSD" type="MyXSD" /&gt;
      &lt;xs:complexType name="Containter1"&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="element1" type="element1" minOccurs="0"
                  maxOccurs="unbounded" /&gt;
              &lt;xs:element name="element2" type="element2" minOccurs="0"
                  maxOccurs="unbounded" /&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
      &lt;xs:complexType name="Containter2"&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="element3" type="Type1" minOccurs="0" /&gt;
              &lt;xs:element name="element2" type="Type2" minOccurs="0" /&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>How can programatically and add an element that has (name="element3" type="element 3" minOccurs="0" maxOccurs="unbounded") to Container 1?</p>
  
  <p>I've looked into DOM, Xerces, JAXB...but there is no really clear "right" way iterate though an XSD and append an element. Xerces seems promising but there is little documentation for it..</p>
  
  <p>Thanks!</p>