title: How to do XML cross referencing?
body: <p>I'm trying to do element cross reference in XML without success. Here's my schema:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xs:schema version="1.0"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         elementFormDefault="qualified"&gt;
  
  &lt;xs:complexType name="guestType"&gt;
      &lt;xs:sequence&gt;
          &lt;xs:element name="name" type="xs:string"/&gt;
          &lt;xs:element name="address" type="addressType"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name="id" type="xs:ID"/&gt;
      &lt;xs:attribute name="ref" type="xs:IDREF"/&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="addressType"&gt;
      &lt;xs:sequence&gt;
          &lt;xs:element name="houseNumber" type="xs:integer"/&gt;
          &lt;xs:element name="roadName" type="xs:string"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name="id" type="xs:ID" /&gt;
      &lt;xs:attribute name="ref" type="xs:IDREF"/&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:element name="event"&gt;
  &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
          &lt;xs:element name="time" type="xs:time"/&gt;
          &lt;xs:choice maxOccurs="unbounded"&gt;
             &lt;xs:element name="guest" type="guestType"/&gt;
          &lt;/xs:choice&gt;
      &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>The code for the XML document is:</p>
  
  <pre><code>&lt;eventxmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  xsi:noNamespaceSchemaLocation='src/tests/newXmlSchema.xsd'&gt;
      &lt;time&gt;14:00:00&lt;/time&gt;
      &lt;guest id="1"&gt;
          &lt;name&gt;John&lt;/name&gt;
          &lt;address id="add1"&gt;
             &lt;houseNumber&gt;222&lt;/houseNumber&gt;
             &lt;roadName&gt;Meat Street&lt;/roadName&gt;
          &lt;/address&gt;
      &lt;/guest&gt;
      &lt;guest id="2"&gt;
          &lt;name&gt;Henry&lt;/name&gt;
          &lt;address ref="add1"/&gt;
      &lt;/guest&gt;
  &lt;/event&gt;
  </code></pre>
  
  <p>I'm using Netbeans to validate. The validation throws an error in:</p>
  
  <pre><code>&lt;address ref="add1"/&gt;
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>cvc-complex-type.2.4.b: The content of element 'address' is not complete. One of '{houseNumber}' is expected.
  </code></pre>
  
  <p>What am I doing wrong? Thank you in advance.</p>
  
  <p>PS. I couldn't find any previous question with something as basic as this. The others were using XLS, is this what I should be using?</p>