XML Comparisons

Specifying Comparisons

To invoke a comparison, you POST parameters to the specified pipeline, in either JSON or XML form.

Synchronous Comparison

Here is a simple synchronous example (asynchronous comparison is detailed on the Asynchronous Comparison page) using the included doc-delta pipeline, however doc-delta in the POST request can be be replaced with any of the default pipelines or a custom pipeline:

POST request
POST /api/compare/pipelines/doc-delta
Content-Type: application/json

Request (XML)

<compare>
  <inputA type="file">
    <path>samples/compare/xml/file1.xml</path>
  </inputA>
  <inputB type="file">
    <path>samples/compare/xml/file2.xml</path>
  </inputB>
  <configurationParameters>
    <configurationParameter type="boolean">
      <name>Preserve Whitespace</name>
      <value>false</value>
    </configurationParameter>
    <configurationParameter type="string">
      <name>Output Type</name>
      <value>full-context</value>
    </configurationParameter>
  </configurationParameters>
</comparison>

Request (JSON)

{
  "inputA": {
    "type": "file",
    "path": "samples/compare/xml/file1.xml"
  },
  "inputB": {
    "type": "file",
    "path": "samples/compare/xml/file2.xml"
  },
  "configurationParameters": [
    {
      "name": "Word By Word",
      "value": true,
      "type": "boolean"
    },
    {
      "name": "Indent",
      "value": "yes",
      "type": "string"
    }
  ]
}

The request allows the pipeline parameters to be changed from their default values.

The response below indicates the comparison result — in this case an XML Delta describing the changes between the inputs specified in the request. The ellipses would give the actual content.

Response

HTTP/1.1 201 Created
<root xmlns:deltaxml="http://deltaxml.com/ns/well-formed-delta-v1" deltaxml:deltaV2="A!=B">
  <child deltaxml:deltaV2="A=B">...</child>
  <child deltaxml:deltaV2="A!=B">...</child>
</root>

The example above shows how comparison inputs could be specified using a File Path. The inputA and inputB elements in the request can contain different types of children according to the types of data being processed. This is described in more detail in the REST I/O Types Reference .

Comparison Model

When specifying a comparison, these are the various available objects:

Object

Description

inputA (required)

Input A to the comparison. See REST I/O Types Reference for the various I/O types available.

inputB (required)

Input B to the comparison. See REST I/O Types Reference for the various I/O types available.

catalog

An OASIS XML Catalog. See REST I/O Types Reference for the various I/O types available.

configurationParameters (type="string")

A name and string value, corresponding with a parameter in the DXP / DCP configuration.

configurationParameters (type="boolean")

A name and boolean value, corresponding with a parameter in the DXP / DCP configuration.

asyncoutput

Specification of where the comparison result will be written. See REST I/O Types Reference for the various I/O types available.

asynccallback

URL that will be polled after the comparison is complete. See Callbacks in Async for more information.

Form Input

In addition to requests in structured XML or JSON format, multipart/form-data can also be used.

Request

POST /api/compare/pipelines/doc-delta HTTP/1.1
Content-Type: multipart/form-data; boundary=boundary-id
Content-Length: number_of_bytes_in_entire_request_body

--boundary-id
Content-Disposition: file; filename="file1.xml"
Content-Size: 98344
Content-Type: application/xml

... XML  ...
--boundary-id
Content-Disposition: file; filename="file2.xml"
Content-Size: 92224
Content-Type: application/xml

... XML  ...
--boundary-id
Content-Disposition: form-data; name="Word By Word"
true
--boundary-id
Content-Disposition: form-data; name="Indent"
yes
--boundary-id
Content-Disposition: form-data; name="async"
true
--boundary-id

The following table describes the parts that can make up the form-data:

Parameter

Description and example usage

A (required)

Input A. Can be specified as a file path, HTTP URI, or raw XML.

B (required)

Input B. Can be specified as a file path, HTTP URI, or raw XML.

output

An optional file path to write the output to. E.g. "/Users/exampleUser/Documents/test.xml"

async

Whether async comparison is used. Default value if not specified: false

callback

Callback URL called after comparison is complete. Note: only used with asynchronous comparisons. See Callbacks in Async for more information.

catalog

An OASIS XML Catalog. Can be specified as a file path, HTTP URI, or raw XML.

Configuration Parameters are specified by using the name of the pipeline parameter as the name of the form data element. For example, the example above sets two parameters — "Word By Word" and "Indent". Note each parameter is specified separately.