4.19.  Comparing XMP Data

You can compare the XMP data in two PDF documents using XPath. Comparing XFA and XMP data are basically the same. And because the previous chapter 3.30: “XFA Data” describes the tests in detail, this section is very short.

If you are in doubt about the structure and values of the XMP data you can extract them with the program ExtractXMPData. See chapter 9.12: “Extract XMP Data to XML”.

Overview

PDFUnit provides the following tag:

<!-- Tag to compare XMP data: -->

<haveSameXMPData />

Example

<testcase name="haveSameXMPData_ResulttypeNode">
  <assertThat testDocument="test/test.pdf"
              masterDocument="master/master.pdf"
  >
    <haveSameXMPData>
      <matchingXPath expr="//pdf:Producer" 
                     withResultType="NODE" 
      />
    </haveSameXMPData>
  </assertThat>
</testcase>

The XPath result types are the same as for XFA tests.

The XPath expression may also contain XPath functions.

If the XMP data is compared in two documents, but neither contains XMP data, PDFUnit throws an exception.