XSD defining repeating elements

S

Seago

I'm not sure if I can explain my issue well enough, but here goes:

I want to define an .XSD such that it allows for an ( A | B )*
configuration where A and B are different elements. I would like to
allow for an infinite list of either type A or type B elements. I
could accomplish this in a DTD file, but I would like to migrate to XSD
and I'm having difficulty with this aspect of it. I thought an
<xs:sequence><xs:choice>... nest might do the trick, but it's not
working and I'm not even sure if this is legal syntax.

Thanks for any help you can give me.
 
J

Joseph Kesselman

It sounds like what you're looking for is

<xsd:choice minOccurs="0" maxOccurs="unbounded> ... </xsd:choice>
 
C

C. M. Sperberg-McQueen

Seago said:
I'm not sure if I can explain my issue well enough, but here goes:

I want to define an .XSD such that it allows for an ( A | B )*
configuration where A and B are different elements. I would like to
allow for an infinite list of either type A or type B elements. I
could accomplish this in a DTD file, but I would like to migrate to XSD
and I'm having difficulty with this aspect of it. I thought an
<xs:sequence><xs:choice>... nest might do the trick, but it's not
working and I'm not even sure if this is legal syntax.

Thanks for any help you can give me.

Er, what's wrong with

<xsd:choice maxOccurs="unbounded">
<xsd:element ref="A"/>
<xsd:element ref="B"/>
</xsd:choice>

(which is a very simple literal translation of your example)?

(In general, if you are having trouble getting something to
work and are asking others for help, it's a good idea to
show more fully what you have tried, and to describe more fully
what error messages it elicited. See [1] for a useful essay
on the art of asking good questions.)

--C. M. Sperberg-McQueen
World Wide Web Consortium

[1] http://www.catb.org/~esr/faqs/smart-questions.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top