map xml element to xsd complexType based on attribute
- by Joshua Johnson
Assume there exists an XML instance document that looks like this:
<root>
<object type="foo">
<!-- ... -->
</object>
<object type="bar">
<!-- ... -->
</object>
</root>
My goal is to have a small (static) schema that verifies proper <element type="xxx" /> syntax for objects, and another schema (more prone to change) that verifies the contents of each object element against a complexType that matches the type attribute:
<complexType name="foo"><!--should match object with type="foo"--></complexType>
<complexType name="bar"><!--should match object with type="bar"--></complexType>
What is the best way to accomplish this (or something similar)?