I am trying to achieve an XML structure equivalent to this:
<worker>
<name>Adam</name>
<project>
<name>Foo</name>
</project>
<project>
<name>Bar</name>
</project>
</worker>
<worker>
<name>Eve</name>
<project>
<name>Foo</name>
</project>
</worker>
<worker>
<name>Lizzie</name>
<project>
<name>Bar</name>
</project>
</worker>
but without duplicating the tag contents. How can I introduce links between projects and workers in a way which would be validated by the parser and what would the required .xsd file look like?
XSD has support for identity relationships through the keyref and key elements. I was going to come up with an example but found this one covers it well. I’ve copied the sample below. Notice that each
itemhas a@numberthat corresponds to aproductin theproductssection of the document. This is enforced in the xsd through theOrderTypedefinition.