I have an XML document (minimum reproducible example) that looks like this:
<root start="baz">
<child name="foo">...</child>
<child name="bar">...</child>
<child name="baz">...</child>
</root>
I would like my schema to enforce the fact that the start attribute on the root element must reference an existing child node with that name. If there is no child node with a name attribute with that value, validation should fail. In other words the above should validate, but this should not:
<root start="baz">
<child name="foo">...</child>
<child name="bar">...</child>
</root>
What is a good way to do this? Do I really need to use an assert with a suitable XPath expression or is there a more natural way to express this in XSD? Thanks.
PS: assume start is a required attribute and the child name attributes are marked unique in the appropriate scope.