I’m not sure if this is possible with XML/XSD, and haven’t had much luck searching for it.
Can you specify an XSD, so that when you’re writing your XML, you can have an element that must reference one of the values contained in another XML element?
For example, if you had this XML:
<car>Audi</car>
<car>Ford</car>
<car>Honda</car>
<person>
<drives>Audi</drives>
</person>
How do you specify the XSD for drives so that it must be one of the values entered for car?
With XSD 1.1 you can use assertions.
You can use XPath 2.0 expressions to perform the validation/test in the assertion.
This example schema has an assertion for the
/docelement that ensures that the/doc/person/drivesvalue is equal to one of it’s/doc/carelements: