HOPEX UML : HOPEX XML Schemas : Creating an XML Schema : References : Creating a bidirectional reference (XML Schema)
   
Creating a bidirectional reference (XML Schema)
It is possible to reference two tag definitions with the same association.
Simply create a bidirectional association (navigable in both directions) between the two classes representing the schema and the referenced element.
You must also specify multiplicities for the two roles (by default, the multiplicity value is *).
To create a bidirectional reference:
1. Open a diagram by right-clicking the schema and selecting New > Class diagram.
2. Drag the two elements from the schema editor into the diagram.
3. Right-click the non-navigable role of the association and select isNavigable > Yes.
The arrow disappears from the link: the reference has become bidirectional.
4. Save and close the diagram.
 
Function
In a bidirectional association, an attribute of type IDREF (or IDREFS) is generated for every tag based on the two connected types. In the instance document, the value of this attribute references the ID attribute of the other tag.
Example:
In the example below, each book references its authors, and each author references his/her books.
In the generated source, only the attributes used to reference books from an author are indicated in bold. The attributes used for the reverse reference are easily spotted.
XSD
<xsd:complexType name="Book" abstract="false" mixed="false">
<xsd:sequence>
<xsd:element name="Summary" abstract="false" minOccurs="1" maxOccurs="1" type="Summary">
</xsd:element>
<xsd:element ref="comment"/>
</xsd:sequence>
<xsd :attribute name="category" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:anyType">
<xsd:enumeration value="Practical"/>
<xsd:enumeration value="Science Fiction"/>
<xsd:enumeration value="Literature"/>
<xsd:enumeration value="Music"/>
<xsd:enumeration value="Educational"/>
<xsd:enumeration value="Children"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="ISBN" type="xsd:ID" use="required"/>
</xsd:attribute>
<xsd:attribute name="BibliographicReferences" use="required" type="IDREF"/>
<xsd:attribute name="Author" use="required" type="IDREF"/>
</xsd:complexType>