- From: Klöck, Erwin <Erwin.Kloeck@bayernlb.de>
- Date: Fri, 13 Feb 2009 16:41:13 +0100
- To: <xmlschema-dev@w3.org>
- Message-ID: <6E8B9135BA0FC84EBF6ED86B94B0E74107323B22@BLEXMUCMAIL1.bayernlb.sfinance-mail.ne>
> Hi, > > is this the best way to ensure that one element out of a set is used? > I have the following xml: > > --- test.xml begin --- > <?xml version="1.0" encoding="ISO-8859-1"?> > <top xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:noNamespaceSchemaLocation="test.xsd"> > > <conditions> > > <primitive_condition_0 /> > <primitive_condition_1 /> > <primitive_condition_2 /> > > <complex_condition /> > </conditions> > </top> > --- test.xml end --- > > I want to make sure that at least one of the primitive_condition elements ist used, but I don't care which one. > I have come up with the following solution (which works) but are now wondering if this is the best way to do this. > My qestion is: Is there a more straight forward way to do this than to have a group of choices? > > --- test.xsd begin --- > <?xml version="1.0" encoding="UTF-8"?> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> > <xs:element name="top" > > <xs:complexType> > <xs:sequence> > <xs:element name="conditions" type="conditions" /> > </xs:sequence> > </xs:complexType> > </xs:element> > > <xs:complexType name="conditions" > > <xs:sequence> > <xs:group ref="primitive_conditon" minOccurs="0" maxOccurs="unbounded" /> > <xs:element name="complex_condition" type="complex_condition" minOccurs="0" maxOccurs="unbounded" /> > </xs:sequence> > </xs:complexType> > > <xs:group name="primitive_conditon" > > <xs:choice> > <xs:element name="primitive_condition_0" /> > <xs:element name="primitive_condition_1" /> > <xs:element name="primitive_condition_2" /> > </xs:choice> > </xs:group> > > <xs:complexType name="complex_condition" /> > </xs:schema> > --- test.xsd end --- > > Thanks for taking an interest. > > Erwin >
Received on Friday, 13 February 2009 17:11:25 UTC