Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - XSD "one or more" construct [Thread Next] Re: XSD "one or more" constructTo: NULL Date: 10/2/2005 4:06:00 PM Wors wrote: > When defining an XSD is there a way of specifying that one or more > elements in a structure must exist? > > E.g. Structure A Element B Element C End Structure > > If I make them both optional (minoccurs 0) then it means Structure A > may contain nothing which isn't right. What it must contain is B, C > or both B and C . OK found out how to do this using the choice construct and setting maxoccurs to the number of choices allowed (min 1 max 2) <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Example"> <xs:complexType> <xs:sequence> <xs:element name="A" maxOccurs="unbounded"> <xs:complexType> <xs:choice maxOccurs="2"> <xs:element name="B"/> <xs:element name="C"/> </xs:choice> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
