I have an XML schema in which I know that an element has to have a particular child, but I do not know the depth at which that child will exist at. Take the following example XML:
<node id="top">
<node id="inner">
<event/>
</node>
</node>
<node id="top">
<event/>
</node>
The only requirements I have is that an <event>
element must be a descendant of the <node id="top">
element, but I do not know at what depth it will occur. In other words, there could be any number of <node id="inner">
elements in between the top <node id="top">
and an <event>
element. In the example above, each of those are valid within the schema. My attempted solution was:
<xs:element name="node">
<xs:complexType>
<xs:sequence>
<xs:element name="node" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="event"/>
</xs:sequence>
<xs:attribute name="id" fixed="inner"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:attribute name="id" fixed="top"/>
</xs:element>
But, as expected, this does not take into account many "depths" of <node>
elements that can occur after the <node id="top">
element.