Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Schema Question?

From: usenet@--------------.---
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent