I'm trying to do element cross reference in XML without success. Here's my schema:
<?xml version="1.0"?>
<xs:schema version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:complexType name="guestType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="addressType"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="ref" type="xs:IDREF"/>
</xs:complexType>
<xs:complexType name="addressType">
<xs:sequence>
<xs:element name="houseNumber" type="xs:integer"/>
<xs:element name="roadName" type="xs:string"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID" />
<xs:attribute name="ref" type="xs:IDREF"/>
</xs:complexType>
<xs:element name="event">
<xs:complexType>
<xs:sequence>
<xs:element name="time" type="xs:time"/>
<xs:choice maxOccurs="unbounded">
<xs:element name="guest" type="guestType"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The code for the XML document is:
<eventxmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation='src/tests/newXmlSchema.xsd'>
<time>14:00:00</time>
<guest id="1">
<name>John</name>
<address id="add1">
<houseNumber>222</houseNumber>
<roadName>Meat Street</roadName>
</address>
</guest>
<guest id="2">
<name>Henry</name>
<address ref="add1"/>
</guest>
</event>
I'm using Netbeans to validate. The validation throws an error in:
<address ref="add1"/>
The error is:
cvc-complex-type.2.4.b: The content of element 'address' is not complete. One of '{houseNumber}' is expected.
What am I doing wrong? Thank you in advance.
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?