Published By: Bill Chesnut

I have always wondered what Group Max Occurs did, recently doing a code review I ran into a case where they were using Group Max Occurs, so it was now time for me to determine exactly what it does.

I have always used Max Occurs on a node that I wanted to repeat, as below:

The sample XML produced by this schema is below with 3 Details nodes:

So know we now what Max Occurs does, what does Group Max Occurs?

I have changed the schema to use Group Max Occurs.

The first thing I noticed was that the maxOccurs was moved from the element definition for Details to the sequence definition under the Details node.

I tried to validate the same XML document as above and I got the following error.

So I decided to generate a document with the Group Max Occurs, this is the resulting document.

You will notice that the Details node does not repeat but the nodes inside of the Details nodes do.

I now understand the difference between Group Max Occurs and Max Occurs, Group Max Occurs repeats the nodes inside of the element that has Group Max Occurs set, the Max Occurs repeats the element and it contents.

Also, remember that if you do not validate the resulting document from a mapping operation it will not catch the difference, because BizTalk does not do full XML validation unless you have a pipeline component with the XMLValidator included.

More …