Editar

Compartilhar via


Choice Group Nodes

In BizTalk Editor, you can insert a Choice Group node to contain other nodes (or entire subtrees of nodes), only one of which can appear in an instance message. A given instance message, if valid, will have only one of the choices present. The contained nodes must be nodes that correspond to XML elements, but cannot be nodes that correspond to XML attributes.

Note

In BizTalk Editor, the Choice Group node is represented with the string <Choice> in the schema tree view. If you set a reference to a Choice Group node, such as x, it is represented as <Group:x> in the schema tree view.

XSD representation

When a Choice Group node is inserted into a Record node, it is inserted at the end of any other child nodes within the sequence, choice, or all element in the Record node. The following example shows, in bold type, how a new Choice Group node is represented in the XML Schema definition (XSD) language as a choice element inserted at the end of the sequence element in a Record node (with nodes named to clarify their identity).

<xs:element name="ContainingRecord">  
    <xs:complexType>  
        <xs:sequence>  
            <xs:element name="ExistingFieldElement" type="xs:string" />  
        </xs:sequence>  
    </xs:complexType>  
</xs:element>  

By default, the choice element is given a minOccurs attribute value of zero (0), indicating that none of the choices need occur. You can change this value in the Visual Studio Properties window when the Choice Group node is selected in the schema tree view.

The following example shows the same choice element with the XSD element elements corresponding to two subordinate Record nodes.

<xs:element name="ContainingRecord">  
    <xs:complexType>  
        <xs:sequence>  
            <xs:element name="ExistingFieldElement" type="xs:string" />  
            <xs:choice minOccurs="1" maxOccurs="1">  
                <xs:element name="usAddress">  
                    <xs:complexType>  
                        <xs:sequence>  
                        </xs:sequence>  
                    </xs:complexType>  
                </xs:element>  
                <xs:element name="foreignAddress">  
                    <xs:complexType>  
                        <xs:sequence>  
                        </xs:sequence>  
                    </xs:complexType>  
                </xs:element>  
            </xs:choice>  
        </xs:sequence>  
    </xs:complexType>  
</xs:element>  

In this example, two sibling Record nodes are used to describe the fact that an instance message will either have a record with United States address information in it, or a record with worldwide address information in it. Further, the minOccurs and maxOccurs properties of the Choice Group node have both been set to one (1) in the Visual Studio Properties window, resulting in the minOccurs and maxOccurs attributes of the choice element being set to one (1) in the XSD representation.

See Also