The append and prepend operations specify that any embedded tags must be matched and combined recursively. This means that before the embedded tags are appended, both lists of embedded tags are traversed to see if they match. A tag embedded in tag1 matches a tag embedded in tag2 if all of the attributes defined in the tag embedded in tag2 are defined with the same values in the tag embedded in tag1. The attributes from tag2 may be a subset of those in tag1; as long as they all match values, the tags still match.

If any tag from tag1 matches a tag from tag2, then the tag from tag1 is replaced by its combination with its matching tag, as defined by its xml-combine attribute. That tag is replaced “in place” — it is not appended or prepended.

For example, consider these two <people> tags:

File 1

File 2

<people>
  <person name="joe" title="CTO">
    <interests>
      <interest interest="rollerblading"/>
      <interest interest="bass"/>
    </interests>
  </person>
</people>

<people xml-combine="append">
  <person name="jeet" title="CEO">
    <interests>
      <interest interest="parenting"/>
    </interests>
  </person>
  <person name="joe"
       xml-combine="append">
    <interests xml-combine="prepend">
      <interest interest="parenting"/>
    </interests>
  </person>
</people>

In this example, the top-level tag that is being combined is the <people> tag. The two tags are defined to be combined by appending. Without any embedded tag matching (if the xml-combine attribute were defined as “append-without-matching”), the result would be:

<people>
  <person name="joe" title="CTO">
    <interests>
      <interest interest="rollerblading"/>
      <interest interest="bass"/>
    </interests>
  </person>
  <person name="jeet" title="CEO">
    <interests>
      <interest interest="parenting"/>
    </interests>
  </person>
  <person name="joe">
    <interests>
      <interest interest="parenting"/>
    </interests>
  </person>
</people>

But with tag matching, the result is different. Before appending, all of the tags embedded in tag1 are scanned. That would just be the <person name="joe" title="CTO"> tag. The tags embedded in tag2 are then scanned to find a match. As it turns out, the <person name="joe"> tag is a match. It doesn’t define all the same attributes found in tag1, but those it does define are a match.

Because these tags are a match, the tag embedded in tag1 is modified in place to be the combination of the tag from tag1 and the tag from tag2. The tag is then removed from tag2 so that it is not actually appended.

The embedded tags are then combined by recursively going through the entire combination process. In this example they are combined by using “append”, but the <interests> tag in each matches, so the <interests> tags are combined by using “prepend”, and the final result is:

<people>
  <person name="joe" title="CTO">
    <interests>
      <interest interest="parenting"/>
      <interest interest="rollerblading"/>
      <interest interest="bass"/>
    </interests>
  </person>
  <person name="jeet" title="CEO">
    <interests>
      <interest interest="parenting"/>
    </interests>
  </person>
</people>

If there are multiple matches for a tag, it is undefined which of the matching tags will be used.

 
loading table of contents...