I trying to make a schema for the following xml.
<root>
<allow_any_name id="string">
<required_tag_1>string</required_tag_1>
<required_tag_2>string</required_tag_2>
<required_tag_3>string</required_tag_3>
</allow_any_name>
<name1 id="string">
<required_tag_1>string</required_tag_1>
<required_tag_2>string</required_tag_2>
<required_tag_3>string</required_tag_3>
</name1>
<name2 id="string">
<required_tag_1>string</required_tag_1>
<required_tag_2>string</required_tag_2>
<required_tag_3>string</required_tag_3>
</name2>
</root>
The main problem is that I can't find a way to specify the child elements with any specifying the tag name as well. In the above xml the allow_any_name
tag could be any name.
I have tried <xs:any processContents="lax"></xs:any>
which allow any tag name but does not allow me to specify the children.
I also tried using <xs:any processContents="strict" namespace="##local"></xs:any>
which enforces the child elements but means I have to know all the tag names used (which I don't)
Thanks
It's not possible with XSD 1.0.
In XSD 1.1 it can be done using assertions.
I think this is not possible with XML Schema. I think you must change your structure from
<allow_any_name id="string">
<required_tag_1>string</required_tag_1>
<required_tag_2>string</required_tag_2>
<required_tag_3>string</required_tag_3>
</allow_any_name>
to something like this:
<fixed_tag_name id="string" name="allow_any_name">
<required_tag_1>string</required_tag_1>
<required_tag_2>string</required_tag_2>
<required_tag_3>string</required_tag_3>
</fixed_tag_name>
hth
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.