If a tag sets xml-combine to append or prepend, tags that are embedded in the combined tags also are matched and combined recursively. Before the primary tags are combined, they are searched for matching embedded tags. Given embedded tags tag1.subtag1 and tag2.subtag2 in file1.xml and file2.xml, respectively, the two tags match if all attributes in tag2.subtag1 have matching attributes in tag1.subtag1. The attributes in tag2.subtag2 can be a subset of the attributes in tag1.subtag1.

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

For example, each of the following XML files contains a <people> tag, where the tag in file2.xml sets its xml-combine attribute to append:

File1.xml

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

File2.xml

<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>

Before appending, all tags embedded in tag1 are searched for matches. The search yields the following match:

<person name="joe" title="CTO">
<person name="joe">

It does not define all the same attributes found in tag1, but those that it does define match.

Because these tags are a match, the tag embedded in tag1 is modified in place to combine 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 is used.


Copyright © 1997, 2015 Oracle and/or its affiliates. All rights reserved. Legal Notices