[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: enforce at least one element and at most N from a set of N
If you can have the same element multiple times, then you can do: <xs:complexType name='..'> <xs:choice maxOccurs='4'> <xs:element name='element1'../> ... </xs:choice> <xs:complexType> If each element can only appear once, then it is more problematic. You can write a schema that spells out all the possible combinations, e.g. <xs:complexType name='..'> <xs:choice> <xs:sequence> <xs:element name='element1'../> <xs:element name='element2' minOccurs='0'.../> <xs:element name='element3' minOccurs='0'../> <xs:element name='element4' minOccurs='0'../> </xs:sequence> <xs:sequence> <xs:element name='element2'.../> <xs:element name='element3' minOccurs='0'../> <xs:element name='element4' minOccurs='0'../> </xs:sequence> <xs:sequence> <xs:element name='element3'../> <xs:element name='element4' minOccurs='0'../> </xs:sequence> <xs:sequence> <xs:element name='element4' minOccurs='0'../> </xs:sequence> </xs:choice> <xs:complexType> But that's not particularly pretty and doesn't scale very well. In that case it's often best to define a looser schema, and then impose the constraint at the application level. An example schema for that might be: <xs:complexType name='..'> <xs:sequence> <xs:element name='element1' minOccurs='0'../> <xs:element name='element2' minOccurs='0'.../> <xs:element name='element3' minOccurs='0'../> <xs:element name='element4' minOccurs='0'../> </xs:sequence> <xs:complexType> HTH, Pete Cordell Codalogic Visit http://www.codalogic.com/lmx/ for XML Schema to C++ data binding ----- Original Message ----- From: "dave" <ceek63@y...> To: <xml-dev@l...> Sent: Monday, November 05, 2007 4:02 AM Subject: enforce at least one element and at most N from a set of N elements- XSD how? > > How would I design an XSD to enforce- > at least one element and at most 4 elements must be > present from a set of 4 elements. > > sequence/choice/all with minoccurs/maxoccurs doesn't > seem to help here. > > Thanks > -D > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > _______________________________________________________________________ > > XML-DEV is a publicly archived, unmoderated list hosted by OASIS > to support XML implementation and development. To minimize > spam in the archives, you must subscribe before posting. > > [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/ > Or unsubscribe: xml-dev-unsubscribe@l... > subscribe: xml-dev-subscribe@l... > List archive: http://lists.xml.org/archives/xml-dev/ > List Guidelines: http://www.oasis-open.org/maillists/guidelines.php > >
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|