I am trying to document somebody else's hand-coded XML and I hope that XSD will help me do that. However, I am hampered by ignorance: I have no guarantee yet that XSD will work for the whole thing. (Feel free to tell me that something is bad coding style if it is, but I am just the documenter, not the developer.)
Anyway, the situation is that I have:
<items>
<item name="foo">
<coolThing>wah!</coolThing>
</item>
<item name="bar">
<needfulThing>address</needfulThing>
</item>
</items>
(Actual terms of course made up.) The <coolThing>
element can only occur in an <item name="foo">
container, and the <needfulThing>
element can only occur in an <item name="bar">
container.
How do I specify this in the XSD? The tutorial I'm looking at conveniently leaves this out.
Is it as simple as defining the assorted elements as children of the attribute declaration:
<xs:attribute name="foo" type="xs:string">
<xs:element name="coolThing" type="xs:string"/>
</xs:attribute>
(Stuff has been left out for clarity.) Of course, that wouldn't easily allow me to specify that <coolThing>
can occur in both <item name="foo">
and an <item name="baz">
elements, if that situation occurs.
Or am I missing something? (Quite likely.)