Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Schema Question? >Thread Next - Re: Schema Question? Re: Schema Question?To: NULL Date: 11/30/2007 3:57:00 AM On 30 Nov, 00:38, Scott <Sc...@discussions.microsoft.com> wrote: > The "all" indicator allows you to specify a number of elements in random > order but it only allows each element to appear a maximum of once. > > I would like to have an unordered list of elements that must appear at least > once but may appear numerous time. Is it possible to describe this in XML > Schema? > > Example: > > <item> > <a>1</a> > <b>2</b> > <a>3</a> > <a>4</a> > <b>5</b> > </item> There isn't a simple way, like some alternative to xs:all or similar. However, if you can come up with a regular expression type syntax of what you want (taking care to remove any unique particle attribution conflicts) you can in principle do this sort of thing. e.g. I think an expression for what you want might look like: (a+b+ | b+a+)(a|b)* which in XSD would translate to something like: <complexType> <sequence> <choice> <sequence> <element name='a' maxOccurs='unbounded'/> <element name='b' maxOccurs='unbounded'/> </sequence> <sequence> <element name='b' maxOccurs='unbounded'/> <element name='a' maxOccurs='unbounded'/> </sequence> </choice> <choice minOccurs='0' maxOccurs='unbounded'> <element name='a'/> <element name='b'/> </choice> </sequence> </complexType> The approach doesn't scale particularly well though, is easy to get wrong and pretty ugly. As such it might be best to impose this sort of constraint at the application level rather than the schema. e.g. just define the schema as: <complexType> <choice minOccurs='0' maxOccurs='unbounded'> <element name='a'/> <element name='b'/> </choice> </complexType> and check that at least one of each appears in the application. HTH, Pete Cordell Codalogic Visit http://www.codalogic.com/lmx/ for XSD C++ data binding | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
