开发者

Change Sequence to Choice

开发者 https://www.devze.com 2023-02-09 18:28 出处:网络
In my Schema File I defined a Group with a Sequence of possible Elements. <group name=\"argumentGroup\">

In my Schema File I defined a Group with a Sequence of possible Elements.

<group name="argumentGroup">
    <sequence>
        <element name="foo" type="double" />
        <element name="bar" type="string" />
        <element name="baz" type="integer" />
    </sequence> 
</group>

I then reference this Group like this:

<element name="arguments">
    <complexType>
        <group ref="my:argumentGroup"/>
    </complexType>
</element>

Is it possible to r开发者_高级运维eference the Group at some other point but restrict it so it's a Choice instead of a Sequence. The position where I want to reuse it would only allow one of the Elements within.

<element name="argument" minOccurs="0" maxOccurs="1">
    <complexType>
        <group name="my:argumentGroup">
            <! -- Somehow change argumentGroup sequence to choice here -->
        </group>
    <complexType>
</element>


No, you will need to define a different group.


No. You cannot do this with groups. To get this type of reusability, use a complex type instead of a group to define the sequence of elements (foo, bar, baz).

Assign this complex type to an element in your schema using restriction. However, you would need the base complex type to use the choice element.

It seems that, using restriction, you can update the choice element to be a sequence in the restriction. However, if the base complex type is defined using a sequence, then updating the restricted element to a choice will cause the schema to fail validation.

0

精彩评论

暂无评论...
验证码 换一张
取 消