XSD with elements in any order and unbounded multiplicity -
i have requirement produce xsd. under root element there can 0, 1 or multiple occurrences of of 7 different elements, , these elements can occur in order.
i can't use sequence, since elements not in predefined order. valid schema, imposes severe restriction:
<xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="data"> <xs:complextype> <xs:sequence> i can't use all, since doesn't allow maxoccurs unbounded, invalid schema:
<xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="data"> <xs:complextype> <xs:all> <xs:element name="address" minoccurs="0" maxoccurs="unbounded"> i have feeling i've come against limitation of xsd, thought i'd ask new xml schemas.
use choice block maxoccurs="1" on each element. ensure there @ least 1 of either a, b, or c no more 1 each.
<xs:choice minoccurs="1" maxoccurs="unbounded"> <xs:element name="a" maxoccurs="1"/> <xs:element name="b" maxoccurs="1"/> <xs:element name="c" maxoccurs="1"/> </xs:choice> all of following valid under schema:
<root> <a/> </root> <root> <a/> <b/> </root> <root> <b/> <a/> </root> <root> <c/> <a/> </root> <root> <a/> <c/> <b/> </root>
Comments
Post a Comment