The rules described earlier specify how two tags are supposed to be combined. However, an additional rule is required to specify how two XML files must be combined.

The rule for combining two XML files is to act as if each file were completely enclosed in a tag, that tag matched for both files, and the tags are being combined with mode append. For example, consider two XML files:

File1.xml

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

File2.xml

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

The <people> tag has been removed for the purpose of this example. In this case, the XML files should act as if they were defined like this:

File1.xml

<pretend-enclosing-tag>
  <person name="joe" title="CTO">
    <interests>
      <interest interest="rollerblading"/>
      <interest interest="bass"/>
    </interests>
  </person>
</pretend-enclosing-tag>

File2.xml

<pretend-enclosing-tag 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>
</pretend-enclosing-tag>

The enclosing tags are combined as normal, and the enclosing tag is omitted from the generated file.


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