Section - 3 : Handling Overflow


The XML search infrastructure has position support.

/descendant::Forms/child::form[position()=2]/child::field1

The 2 in this case indicates you want the second form child. Since you would not want to write the search to work with every explicit number, you must indicate where the overflow variable fits into the equation, as shown here:

/descendant::Forms/child::form[position()=****]/child::field1

The system first scans the search to see if a replacement is needed for the overflow value. In this case, it would insert the 2 (taken from the overflow variable value) and then do the actual XML search.

You can also handle overflow within overflow by specifying an overflow variable name in the search. For instance, suppose you have multiple cars and each car can have multiple drivers.

<car>

<driver>Tom<driver/>

<driver>Tim<driver/>

<car/>

<car>

<driver>Sally<driver/>

<car/>

If you had two overflow variables, one working for car and one for driver, you could create a search like this:

/descendant::car[**carvar**]/child::driver[**drivevar**]

Where the system gets two overflow variables and insert them into the search text.