The matching rules described earlier in this section match two tags on the basis of their attribute values. Sometimes, tags cannot be matched in this way. For example, J2EE deployment descriptors do not typically use attributes. Thus, the matching rules cause too many tag matches because there are no attribute values to distinguish the tags.

In this case, it might be necessary to manufacture an attribute. The J2EE deployment descriptors provide the id attribute, which is designed to be used when tags need to be matched at a lexical level.

The id tag can be used to hold the value of an embedded value that is known to be unique, as in this example:

<session>
  <ejb-name>Account</ejb-name>
  ...
</session>

<session>
  <ejb-name>Payroll</ejb-name>
  ...
</session>

Here, all <session> tags are distinguished by the value of their <ejb-name> child tag, but that is no help to the XML combination rules. In this case, an id attribute is added to facilitate tag matching:

<session id="Account">
  <ejb-name>Account</ejb-name>
  ...
</session>

<session id="Payroll">
  <ejb-name>Payroll</ejb-name>
  ...
</session>