public class Comparison
extends java.lang.Object
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.
Modifier and Type | Method and 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,
java.net.URL dxp)
A com.deltaxml.cores9api XSLT extension function that allows XSLT nodes or subtrees to be compared using a configurable
pipelined comparison.
|
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, java.net.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.
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 comparisonnet.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 comparatorpublic 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 #compareS9(XPathContext, NodeInfo, NodeInfo, URL)
for examples of use, requirements and discussion of error
handling.
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 XSLTnet.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#compareS9(XPathContext, NodeInfo, NodeInfo, URL)