Typically, the DeltaXML Core product is used to compare XML content, but have you ever considered using the Core product to compare non-XML documents? In this blog post, I experiment with using Core to compare (non-XML) XQuery code.
The objective here is to use a DXP Pipeline Configuration file to define a pipeline for the Core comparator. Two simple XSLT filters are to be used, one for input, the other for output. The input filter converts XQuery to XML with one element for each token, it exploits an imported tokenizer function for XQuery – from the open source XMLSpectrum project (for which I’m currently the sole contributor).
A high-level view of the XQuery pipeline I developed is shown below:
A view of the configured pipeline
Running the XQuery comparison
For this experiment I’m using the Java version of Core and invoking the comparison from an Ant build file. Within this, the run target invokes the DeltaXML command.jar with 5 command-line arguments:
compare
The Core method to invoke
xquery
The id attribute of the Pipeline Configuration file
input-file1.xml
Input XML file 1 – holds the URI of the 1st XQuery file to compare
input-file2.xml
Input XML file 2 – holds the URI of the 2nd XQuery file to compare
result.html
The destination file