Reputation: 10969
I am trying to write some XML schema code to specify that a particular element 'abc' may have a child element with name 'xyz', and that element may have any attributes, and any child elements.
At the moment I have this:
<xs:element name="abc">
<xs:complexType>
<xs:sequence>
<xs:element name="xyz">
<xs:complexType>
<xs:sequence>
<xs:any/>
</xs:sequence>
<xs:anyAttribute/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
But when I validate my XML against the schema, I get validation failures complaining about the child elements of the xyz element.
Upvotes: 2
Views: 233
Reputation: 1470
Your xs:any doesn't have any information attached to it, so it is looking for schema defined elements. If you want to be slack in your interpretation of the sub-elements, try this:
<xs:element name="abc">
<xs:complexType>
<xs:sequence>
<xs:element name="xyz">
<xs:complexType>
<xs:sequence>
<xs:any processContents="lax" />
</xs:sequence>
<xs:anyAttribute/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
This should get you past validation. If you have any expectation on the well-formedness of xyz's content, you can include a namespace using the namespace attribute for xs:any, and pull in another schema for that information.
Good luck, and I hope this helps!
Upvotes: 1