Group Max Occurs vs Max Occurs in BizTalk Schema

The following are some important definitions to understand:

Group Max Occurs: This property defines the maximum number of times a group of fields can occur, regardless of the Group Order Type property value.

Max Occurs: This property defines the maximum number of times an element or record node can occur.

Group Order Type: This property determines the order in which child nodes are repeated. If the value is “Sequence”, all child nodes are repeated in the same order as defined in the xsd file. If the value is “All”, all child nodes are repeated without a specific sequence, but all child nodes must be available. If the value is “Choice”, not all child nodes are mandatory in the repeating node.

It’s important to note that the default value of Group Max Occurs, Max Occurs, Group Min Occurs, and Min Occurs is “1”. Additionally, Group Min Occurs and Min Occurs cannot be less than Group Max Occurs and Max Occurs, respectively.

For a better understanding, please refer to the following example. It’s quite simple and can help clear up any doubts.

1. Please refer to the image below and replicate the schema in your Visual Studio.

2. Generate an instance of the same schema in Solution Explorer by right-clicking and selecting “Generate Instance”. Then, copy the yellow records two more times. Refer to the image below for guidance.
3. To make the child record “AHDetails” have an unlimited number of occurrences, you need to go to its properties and set the Max Occurs field as “unbounded” or “*“. Once you’ve done that, you can browse the same XML file in the Input Instance Filename property from the corresponding XSD file.
4. To validate the instance, select the same XSD file and click on “Validate Instance”. The result should look like the image shown below.
5. To keep the same input instance filename and change the “AHDetails” property from Max Occurs to Group Max Occurs as “unbounded” or “*”. Now right-click on the XSD file property and select “Validate Instance”. If you receive an error message, it may be because you changed the Group Max Occurs property to “unbounded” and the Default Group Order Type is “Sequence”. This means that all child elements must repeat in the same order in the same record name “AHDetails”, but your XML file contains multiple “AHDetails” tags.
6. Please keep in mind that you should not modify the “AHDetails” property, which means that the maximum number of occurrences for the group is “unbounded”. Additionally, please browse another XML file in the Input Instance Filename. You can refer to the attached picture, where you will see a yellow Record node called “AHDetails”. This node appears only once, but it has multiple child elements that can be repeated multiple times.
7. Again go to the solution explorer list and right-click on the same xsd file property then click Validate Instance and see the below following successfully validated result.
8. There are multiple “AHDetails” record nodes and Name elements in the following XML file.
9. To validate an instance of the XML file, follow these steps: 1. Click on the “AHDetails” node. 2. Go to the node’s properties and set the “Max Occurs” value as “unbounded”. 3. Set the same “unbounded” value for the “Name” element as shown in the picture below. 4. Finally, click on “Validate Instance” from the XSD file property and check the result to confirm a successful validation.
10. Create one more xml file as shown below picture
11. In the given image, there is only one “AHDetails” record note, but multiple “Name” elements. To validate the instance successfully, please set the value of “AHDetails” Group Max Occurs as “unbounded” and the same “Name” element property.

Please apply the same approach for both Group Min Occurs and Min Occurs.

Please click the link to download the BizTalk application along with the test XML files.

Post a comment

Leave a Comment

Scroll to Top