Use of Merge

Whenever a relative XPath expression returns more than one result, you have the option of how to combine the results into a single field. The usual behaviour is to concatenate, so there are merge options for using Space, Comma, Semicolon, Newline and Tab as separators between the merged string components. None will concatenate the strings directly with no separator. No-Merge will just use the first result returned and discard the rest.

There is one final option, Group. If you choose Group then all subsequent XPaths are relative to the Group and will generate multiple records sharing all common fields. For example, given this input:

<?xml version="1.0"?>

<ROOT>
  <A id="A1">
    <B id="B1"/>
    <C id="C1"/>
    <C id="C2"/>
  </A>
  <A id="A2">
    <B id="B2"/>
    <C id="C3"/>
    <C id="C4"/>
    <C id="C5"/>
  </A>
  <A id="A3">
    <B id="B3"/>
    <C id="C6"/>
    <C id="C7"/>
  </A>
</ROOT>

. Use of a Merge Space will concatenate all the C ids together, as shown in Figure 7.4, “Merge Space”

Figure 7.4. Merge Space

Merge Space

However, use of Merge Group will add extra records to ensure each C id remains distinct. This is shown in Figure 7.5, “Merge Group”.

Figure 7.5. Merge Group

Merge Group

There are now two A1 records, because there are two C nodes grouped within A1. Note that the value of the Group row is a zero-based index of the number of the record within the parent.