Class Comparison

java.lang.Object
com.deltaxml.ext.xslt.saxon.Comparison

public class Comparison extends Object
A class consisting of XSLT extension functions for comparison operations. Future enhancements may provide more sophisticated ways of providing the DXP pipeline to be used, for example via an XSLT temporary tree. Support for other XSLT processors may be included according to demand, probably in different packages.

The methods in this class are designed for use with the com.deltaxml.cores9api package, please read the javadoc below to select the correct method.

Since:
5.3.3
Author:
Nigel Whitaker
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.sf.saxon.om.NodeInfo
    compare(net.sf.saxon.expr.XPathContext context, net.sf.saxon.om.NodeInfo a, net.sf.saxon.om.NodeInfo b)
    A com.deltaxml.cores9api XSLT extension function that allows a XSLT nodes or subtrees to be compared with a standard comparison.
    static net.sf.saxon.om.NodeInfo
    compare(net.sf.saxon.expr.XPathContext context, net.sf.saxon.om.NodeInfo a, net.sf.saxon.om.NodeInfo b, URL dxp)
    A com.deltaxml.cores9api XSLT extension function that allows XSLT nodes or subtrees to be compared using a configurable pipelined comparison.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • compare

      public static net.sf.saxon.om.NodeInfo compare(net.sf.saxon.expr.XPathContext context, net.sf.saxon.om.NodeInfo a, net.sf.saxon.om.NodeInfo b, URL dxp) throws net.sf.saxon.trans.XPathException, net.sf.saxon.s9api.SaxonApiException

      A com.deltaxml.cores9api XSLT extension function that allows XSLT nodes or subtrees to be compared using a configurable pipelined comparison. Unlike the deep-equals XPath2 function this method produces a DeltaXML deltaV2 output tree which tries to align the inputs and describe their differences.

      This method is Saxon Specific and also makes use of the Saxon 'S9API' classes and requires Saxon version 9.3

      In order to use this extension the Java classpath should contain saxon9pe.jar from the XML Compare release.

      Error handling: Most of the errors/restrictions which apply to the standard comparators in com.deltaxml.api and com.deltaxml.core apply here. For example, the root elements in each input should be of the same type, and orderless subtrees must not contain PCData. One error to be avoided is that delta files cannot be compared, this is particularly important when the extension is used to compare fragments of a delta result in an output filter, which typically contain delta or deltaV2 attributes.

      To use this extension a namespace prefix should be declared according to the rules described in the saxon extension function documentation, for example:

      <xsl:copy-of select="dxml:compare(., previous-sibling::*[1], 'file:///localhost/dir/subpipe.dxp')"     xmlns:dxml="java:com.deltaxml.ext.xslt.saxon.Comparison"/>

      The invocation mechanism described above requires the use of either a PE or EE edition of Saxon. We recommend using the jar file included in the XML Compare release.

      The DXP parameter specifies the comparison pipeline to be used. This allows input and output filters to be added as needed. If the DXP is located inside a JAR file then we suggest that the following XSLT pattern be used specify its location: resolve-uri('../dxp/subpipe.dxp', static-base-uri()) The static-base-uri() function typically provides the location of the invoking stylesheet and resolve-uri can be used to locate a DXP file relative to it.

      Parameters:
      a - The first comparator input - an XSLT node()
      b - The second comparator input - an XSLT node()
      context - an implicit argument for the extension, hidden when invoked from XSLT
      dxp - the location of a DXP pipeline configuration for the comparison
      Returns:
      a document node containing the delta result tree
      Throws:
      net.sf.saxon.trans.XPathException - to indicate problems, look for a nested cause which may be a comparator exception
      net.sf.saxon.s9api.SaxonApiException - if there are issues converting data to/from SAX events used by the comparator
      Since:
      6.0
    • compare

      public static net.sf.saxon.om.NodeInfo compare(net.sf.saxon.expr.XPathContext context, net.sf.saxon.om.NodeInfo a, net.sf.saxon.om.NodeInfo b) throws net.sf.saxon.trans.XPathException, net.sf.saxon.s9api.SaxonApiException

      A com.deltaxml.cores9api XSLT extension function that allows a XSLT nodes or subtrees to be compared with a standard comparison. Unlike the deep-equals XPath2 function this method produces a DeltaXML deltaV2 output tree which tries to align the inputs and describe their differences.

      See compare(XPathContext, NodeInfo, NodeInfo, URL) for examples of use, requirements and discussion of error handling.

      Parameters:
      a - The first comparator input - an XSLT node()
      b - The second comparator input - an XSLT node()
      context - an implicit argument for the extension, hidden when invoked from XSLT
      Returns:
      a document node containing the delta result tree
      Throws:
      net.sf.saxon.trans.XPathException - to indicate problems, look for a nested cause which may be a comparator exception
      net.sf.saxon.s9api.SaxonApiException - if there are issues converting data to/from SAX events used by the comparator
      Since:
      6.0
      See Also: