Sections that expand and shrink to accommodate the data being merged are added by making subforms and nesting them into a hierarchy similar to the structure of the data. You can nest subforms to any depth. By nesting them, you can make the form design match the XML data file that will be merged with it. For example, if the XML data file includes two levels, you can create the subform hierarchy by matching the subforms names with the tag names in the XML data file so that LiveCycle Designer ES can map the data without transforming the data file.
A form that has a flowable layout, such as the Purchase Order sample, typically includes various subforms nested together, with one or more objects in each subform. For example, you can see how the different objects in the Purchase Order sample are wrapped in the subforms named header, detailHeader, detail, and total. Notice how you can align text and text field objects into rows and columns and wrap them in a subform. Using subforms to wrap groups of objects such as the various text field objects in the detail subform not only lets you maintain the layout of the objects, but also lets you control how often the subform is repeated.
You can configure each subform so that when the form is rendered, only the subforms that contain the objects that are necessary for representing the data content are placed. For example, you may want to produce different purchase orders for each customer where, in one purchase order form, the detail subform is placed twelve times to indicate the items purchased and, in another purchase order form, the same subform is placed fifty times, spanning multiple pages.
The sample Purchase Order form whose layout adjusts to accommodate data illustrates how you can use subforms to achieve this configuration. Open the form in LiveCycle Designer ES and look at the Hierarchy palette to examine the structure of the subform, and look at the Object palette to see how the subforms are configured. Pay particular attention to the purchaseOrder, detailHeader, and detail subforms and how they are configured. Keep in mind that the parent subform, which is purchaseOrder, controls the flow of content in the form and expands to fit the available data. The detailHeader subform is configured with a minimum count of 1, which means that when the form is rendered, this subform will appear only once. However, the detail subform is configured to repeat with each data item and therefore, when the form is rendered, will appear as many times as there are occurrences of the data.
You can also use a subform to draw a border around a group of subforms. For example, you can create one or more dynamic subforms, nest those subforms within a wrapper subform, and then specify a border for the wrapper subform. When the form is rendered, a border will be drawn around all of the internal subforms.
See also 

Using subforms in a form that has a flowable layout