Class Comparison
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 TypeMethodDescriptionstatic net.sf.saxon.om.NodeInfocompare(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.NodeInfocompare(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.
-
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.jarfrom 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 XSLTdxp- 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 exceptionnet.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 exceptionnet.sf.saxon.s9api.SaxonApiException- if there are issues converting data to/from SAX events used by the comparator- Since:
- 6.0
- See Also:
-