title: How to traverse XML schema ref attributes with JDOM
body: <p>I'm trying to do something like a depth-first traversal of the dom produced by JDOM based on the following XSD. The problem is, the tree constructed by JDOM does not take into account the 'ref' references. In other words, the element with name='xs:element'  and ref='BaseData' has 0 children, according to the JDOM tree, because looking at it as just another XML file, it indeed doesn't have any children.</p>
  
  <pre><code>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"&gt;
      &lt;xs:element name="XDEX"&gt;
          &lt;xs:annotation&gt;
              &lt;xs:documentation&gt;Version 20 of 2013-08-21&lt;/xs:documentation&gt;
          &lt;/xs:annotation&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element ref="BaseData"/&gt; &lt;-- getChildren returns 0 Elements!!
                  &lt;xs:element ref="Shipment"/&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
      &lt;xs:element name="BaseData"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element ref="Mandator"/&gt;
                  &lt;xs:element ref="MandatorVATNumber"/&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
      &lt;xs:element name="Mandator" type="Char3"&gt;
          &lt;xs:annotation&gt;
              &lt;xs:documentation&gt;number identifying the current mandator&lt;/xs:documentation&gt;
          &lt;/xs:annotation&gt;
      &lt;/xs:element&gt;
  
  ... and so on
  </code></pre>
  
  <p>I really need to traverse the schema in such a way as the references would be followed, so that for instance with a recursive algorithm (for depth-first), 'Mandator' would be visited directly after 'BaseData', and not 'Shipment', as is now the case. Does anyone know how this can be done with JDOM or perhaps a different library?</p>
  
  <p>Thanks is advance.</p>