[xsd-users] Sequence + Choice (or Alternative)

Marvin M. xsd-users at groenndemon.de
Wed Apr 14 19:12:36 EDT 2010


I would like to have a schema like this:

<grammar>
    <rule lhs="A">
        <non-terminal>Foo</non-terminal>
        <terminal>Bar</terminal>
        <string>Buzz</string>
        <terminal>Bar</terminal>
        <non-terminal>Foo</non-terminal>
    </rule>
</grammar>

<grammar> ist the root node, and an infinite number of rules are
allowed. It looks like this works quite well.

However, I am unsure how to implement the rule's child nodes:
There has to be at least one child node (valid elements are
<non-terminal>, <terminal> and <string>), but there is no restriction on
how many there could be.
The order of the child nodes has to be preserved.

I'm not that experienced with XML schemas yet, and I currently have a
sequence of choices that would allow one of the three element types.
But as the element types currently don't have a common base type, I
think I can't use "--generate-polymorphic", can I?

Anyway, I'd like to have something like an Item() method for my Rule
class, so that I would be able to iterate through all children and check
what element type they are.

Thanks,
Marvin



More information about the xsd-users mailing list