orderless ComplexType
April 18, 2008 4:42 PM   Subscribe

How do I make a complex type in Schema that's not "All", "Choice", nor "Sequence"?

I want to say that this thing can have a few possible types of children, but it doesn't have to be All of the types, nor a Choice of just one type, nor do the types have to be in a particular Sequence.
posted by badstone to Computers & Internet (8 answers total)
 
The xml spec is all greek to me, but from some weak googling, can you not have child types with minoccurs=0 and use "All"?
posted by juv3nal at 4:58 PM on April 18, 2008


Response by poster: unfortunately, maxoccurs for elements within "All" must be 1. See the "Note" after "All Indicator" is described here.
posted by badstone at 5:02 PM on April 18, 2008


Am I looking at the wrong thing? It says max must be 1 but min can be 0 or 1.
posted by juv3nal at 5:05 PM on April 18, 2008


Response by poster: my question is not phrased right then. my intent is that maxoccurs be unbounded.
posted by badstone at 5:07 PM on April 18, 2008


ah. my bad.
posted by juv3nal at 6:30 PM on April 18, 2008


Best answer: This sounds like it might help. As far as I can understand it, apparently you can make the choice/parent thing itself unbounded to let you pick "one of the following" an arbitrary number of times in arbitrary order.
posted by juv3nal at 8:46 PM on April 18, 2008


Best answer: juv3nal is correct. It sounds like what you want is an

<xs:choice maxOccurs="unbounded">
<xs:element ref="firstThing">
<xs:element ref="anotherThing">
</xs:choice>

If you're not forced into using W3C XML Schema for interop or tool reasons, then consider using Relax NG instead - it's more readable, and more expressive.
posted by siskin at 3:24 AM on April 19, 2008


Response by poster: that works. sucks that you have to resort to a hacky approach like that for what feels like a pretty standard thing to want to do. thanks!
posted by badstone at 9:23 AM on April 22, 2008


« Older Mmm, garlic-flavored mojito...   |   Austrian villages Newer »
This thread is closed to new comments.