XmlDiff Operation xd:add

Microsoft XML Diff

Microsoft XML Diff 1.0 and XML Patch 1.0

XmlDiff Operation xd:add

An xd:add element occurs when a new node or XML fragment is found in the changed document that was not found in the source document.

Addition of a single node

The following is an example of what an xd:add element looks like when new nodes are found:

<xd:add type="1" name="Customer">
    <xd:add type="2" name="id">1001</xd:add>

When a single node has been added, the xd:add element has the attribute type that indicates what type of node was added, using the W3C DOM Node Types enumeration. The xd:add element can then have a name attribute, which is the local name for the new element, attribute, DTD, or entity reference. The element can also contain an ns attribute, indicating the namespace, and a prefix attribute indicating the prefix for the new element or attribute name. It can also have the opid attribute which contains the ID number of the add operation. If the new node type is a DTD, the xd:add element may contain attributes systemId and publicId specifying the system and public identifiers for the DTD.

The value of the added node, that is, the value of an attribute or xml declaration, is specified as the content of the xd:add element.

The preceding example shows that a new Customer element was added. The two lines below show an addition of a type 2 node, which is a new attribute, with an attribute name of id, and an attribute value of 1001.

Currently, the xd:add element for showing the addition of a single node is used only when a new element, attribute, xml declaration, DTD, or entity reference has been added. For other node types, the xd:add element used when adding fragments is shown. For more information, see Adding Fragments and Multiple Nodes.

The following table describes the attributes that the xd:add element might have:

Attribute name Data type Description
type unsigned int Type of the new node according to the values of the DOM node type enumeration (1=element, 2=attribute, and so on).
name NCName Local name for the new element or attribute, or a name for the new processing instruction, DTD, or entity reference.
ns Namespace URI Namespace for the new element or attribute.
prefix NCName Prefix for the new element or attribute.
systemId string System identifier for the new DTD node.
publicId string Public identifier for the new DTD.
opid unsigned int Operation ID.

The following table describes the content that the xd:add element might have:

Content type Description
text value The value for the new attribute, or the value for the new xml declaration.
CDATA section Internal subset of the new DTD enclosed in a CDATA section.
(xd:add)* Child nodes of the new node. This xd:add child nodes are only available for an add of type=1 (element).

See Also

XML Diff Functionality | XML Diff Language (Diffgram) | Path Descriptors | XmlDiff Operation xd:node | XmlDiff Operation xd:remove | XmlDiffOperation xd:change | Extended Operations | Example of a Diffgram |XmlDiff Class

© 2002 Microsoft Corporation. All rights reserved.