Class PipelinedComparator
- All Implemented Interfaces:
com.deltaxml.core.internals.CommonComparator
Provides a Pipeline abstraction for the Comparator.
Each of the two comparator input streams is passed through a number of input filters and the comparator output is fed through a chain of output filters. Filters can be used for input processing or cleaning (removing unnecessary whitespace or elements not significant for comparison), keying, or output report generation. They could be implemented using XSLT or Java. The current implementation also supports filter parameterization using String parameters.
Note: This class instantiates the underlying SAX parsers using the JAXP factory mechanisms. A configuration property is also available which can be used to bypass the factory and instantiate Apache Xerces-J directly. Reconfiguring the factories so as to change the underlying factory implementation classes during the existence of a PipelinedComparator is not supported and may result in unpredictable results.
Note: A single instance of this class should not be used by multiple threads. Different instances may be used by different threads.
For more information about thread safety please read the Multithreading Guide on our documentation website
- Since:
- 6.0
- Author:
- Nigel Whitaker, Tristan Mitchell, Christopher Cormack, Anthony Smith
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new PipelinedComparatorS9.PipelinedComparator(net.sf.saxon.s9api.Processor suppliedProcessor) A constructor allowing the use of a supplied s9api Processor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLicenseFile(File licenseFile) Sets the license file for use with Flexera licensing.voidaddLicenseServer(String hostname) Sets a license server for use with concurrent licensing.voidaddLicenseServer(String hostname, int port) Sets a license server and port for use with concurrent licensing.voidAdd a progress listener to the list of registered progress listeners.voidRemove all currently registered progress listeners.voidCompares File objects and uses a File to represent the result.voidcompare(InputStream a, String systemIdA, InputStream b, String systemIdB, OutputStream result) Compares the XML obtained from InputStream objects and uses an OutputStream to represent the pipeline result.voidCompares the XML obtained from Reader objects and uses a Writer to represent the pipeline result.voidCompares the XML obtained from Strings and uses a StringBuilder to represent the pipeline result.voidCompares the XML obtained from URLs and writes the pipeline result to a File.voidcompare(URL a, URL b, OutputStream result) Compares the XML obtained from URLs and writes the pipeline result to an OutputStream.net.sf.saxon.s9api.XdmNodecompare(net.sf.saxon.s9api.XdmNode a, net.sf.saxon.s9api.XdmNode b) Compares two Saxon XdmNode trees and generates an XdmNode tree result from the pipeline.voidcompare(InputSource a, InputSource b, StreamResult result) Compares the XML obtained from InputSource Objects and writes the pipeline result to a StreamResult.booleanGets whether the production of debug files is on or not.This returns where the debug files will be found.Returns the current entity resolver setting.Returns the current lexical preservation configuration settings.intGet the total number of enabled Progress Reporting Stages.booleanReports the current value of the optimization setting.getOutputProperty(net.sf.saxon.s9api.Serializer.Property property) Allows the current settings of the serializer properties to be determined.booleangetParserFeature(String featureName) Allows the current settings of parser features to be determined.getParserProperty(String propertyName) Allows the current settings of parser properties to be determined.Gets the currentThreadingConfiginstance in use byPipelinedComparator.Reports current attribute settings of the XSLT transformers in the pipeline.Returns the current URI resolver setting.booleanStates whether the lexical preservation output chain is being bypassed or not.booleanCompares two File inputs and returns whether they're equal.booleanisEqual(InputStream a, String systemIdA, InputStream b, String systemIdB) Compares two InputStream inputs and returns whether they're equal.booleanCompares two Reader inputs and returns whether they're equal.booleanCompares two String inputs and returns whether they're equal.booleanCompares two URL inputs and returns whether they're equal.booleanisEqual(net.sf.saxon.s9api.XdmNode a, net.sf.saxon.s9api.XdmNode b) Compares two XdmNode inputs and returns whether they're equal.booleanisEqual(InputSource is1, InputSource is2) Compares two InputSource inputs and returns whether they're equal.Generates aFilterChainto process lexical preservation items.voidRemove a progress listener from the list of registered progress listeners.voidsetBypassLexicalPreservationOutputChain(boolean value) Sets whether or not to bypass the automatically added lexical preservation output chain during the comparison.voidsetCancellationPolicy(CancellationPolicy policy, Optional<Long> timeoutMs) Set a policy to timeout the comparison.voidsetDebugFiles(boolean debug) Determines whether intermediate pipeline result files are generated.voidsetDebugFilesPrefix(String debugPrefix) Provides a prefix for debug result files.voidsetEntityResolver(EntityResolver resolver) Set an entity resolver for use when reading the inputs to the pipelined comparator.voidsetEntityResolver(EntityResolver resolver, boolean useFallbackEntityResolver) Set an entity resolver for use when reading the inputs to the pipelined comparator.voidsetInput1Filters(FilterChain filters) Allows filters to be specified using aFilterChain.voidsetInput2Filters(FilterChain filters) Allows filters to be specified using aFilterChain.voidsetInputFilters(FilterChain filters) Allows input filters to be specified using aFilterChain.voidSets theLexicalPreservationConfigto use during comparison.voidsetOptimizeXMLFiltersAroundComparator(boolean optimize) Apply streaming optimization to filters around the comparator.voidsetOutputFilters(FilterChain filters) Allows output filters to be specified using aFilterChain.voidsetOutputProperty(net.sf.saxon.s9api.Serializer.Property property, String value) Configures output formatting and control.voidsetParserFeature(String featureName, boolean value) Sets a feature on the parser used for reading XML inputs into a Core S9 Comparator.voidsetParserProperty(String propertyName, Object value) Configures parser properties for the pipeline input parsers.voidsetThreadingConfig(ThreadingConfig threadingConfig) Sets the currentThreadingConfiginstance in use byPipelinedComparator.voidsetTransformerConfigurationOption(String name, Object value) Set a configuration option on the XSLT transformers used in the pipeline.voidsetURIResolver(URIResolver resolver) Sets a resolver for use by all XSLT based filters in a Core S9 API comparator.voidsetURIResolver(URIResolver resolver, boolean useFallbackURIResolver) Sets a resolver for use by all XSLT based filters in a Core S9 API comparator.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.deltaxml.core.internals.CommonComparator
addLicenseFile, addLicenseServer, addLicenseServer, compare, compare, compare, compare, compare, compare, compare, compare, getOutputProperty, getParserFeature, getParserProperty, setParserFeature, setParserProperty
-
Field Details
-
CONFIG_DEBUG_FILES
This is a boolean configuration property that when true will send most or all intermediate results to files. The files are named according to their positions in the respective input and output filter lists. The A and B strings are used to differentiate the input filter chains. If you are using multiple pipelines in a single applications then using a prefix is a good idea.- See Also:
-
CONFIG_OPTIMIZE_XMLFILTERS_AROUND_COMPARATOR
This configuration property provides the default or initial value for this optimization setting. Use of the setOptimizeXMLFiltersAroundComparator method will override the configuration setting. Configuration properties can be used in configuration files to set global (entire JVM or application scope) settings, whereas the API methods ("See Also" below) provide finer granularity and control.
-
-
Constructor Details
-
PipelinedComparator
Creates a new PipelinedComparatorS9. This will use an internal Saxon Processor for running XSLT transformations and therefore this constructor should not be used in conjunction with methods which perform XdmNode IO. If planning to use these methods see the constructor that takes a Processor argument.
- Throws:
ParserInstantiationException- if there is a problem instantiating the XML parser- See Also:
-
PipelinedComparator
public PipelinedComparator(net.sf.saxon.s9api.Processor suppliedProcessor) throws ParserInstantiationException, IllegalArgumentException A constructor allowing the use of a supplied s9api Processor. If you wish to use the compare method with XdmNodes then this constructor should be used to ensure Saxon Configuration/NamePool compatibility between the inputs and the compilation of pipeline filters used to process the inputs. The supplied processor should be from Saxon version 9.9 or 10.0 and ideally from a Professional or Enterprise ('PE' or 'EE') version of Saxon. A 'HE' version of Saxon can be supplied but some DeltaXML supplied filters use Saxon PE features and this may result in compilation or runtime errors. We are investigating ways of supporting, in a future release, Saxon HE XdmNode IO while using Saxon PE internally in PipelineComparatorS9.- Parameters:
suppliedProcessor- A Saxon processor to be used for the NamePool and filter compilation.- Throws:
ParserInstantiationException- if there is a problem instantiating the XML parserIllegalArgumentException- if the supplied Processor is not based on Saxon version 9.9 or 10.0.
-
-
Method Details
-
newFilterStepHelper
Creates a
FilterStepHelperusing theProcessorandURIResolvercurrently in use by this comparator.Due to the way that Saxon's Processor works, all internal XdmNodes and compiled XSLT must be created by the same
Processor. ThereforeFilterChains andFilterSteps that are to be associated with this Comparator should be instantiated by this Comparator'sFilterStepHelper, which is what this method provides.Note that the set input and output filter methods (e.g.
setOutputFilters(FilterChain)) make use of aFilterStepHelperbehind the scenes.- Specified by:
newFilterStepHelperin interfacecom.deltaxml.core.internals.CommonComparator- Returns:
- an instance of a
FilterStepHelperwith which to createFilterChains andFilterSteps for this Core S9 API Comparator. - Since:
- 7.0
-
setEntityResolver
Set an entity resolver for use when reading the inputs to the pipelined comparator.- Parameters:
resolver- the user specified entity resolver.useFallbackEntityResolver- whether to use the internal catalog support (supplied by the fallback entity resolver).
-
setEntityResolver
Set an entity resolver for use when reading the inputs to the pipelined comparator. This is equivalent to callingsetEntityResolver(resolver, true).- Parameters:
resolver- the user specified entity resolver.
-
getEntityResolver
Returns the current entity resolver setting.- Returns:
- The current entity resolver in use, or null if one hasn't been set or if it was previously nulled.
-
setURIResolver
Sets a resolver for use by all XSLT based filters in a Core S9 API comparator. A URIResolver used in this way is useful when resolving files referenced by<xsl:import>,<xsl:include>anddocument()constructs.- Parameters:
resolver- An implementation of the URIResolver interface, or nulluseFallbackURIResolver- Whether to use the fallback URI Resolver, if the user supplied URI Resolver fails to resolve.- See Also:
-
AbstractXsltTransformer.setURIResolver(javax.xml.transform.URIResolver)
-
setURIResolver
Sets a resolver for use by all XSLT based filters in a Core S9 API comparator. This resolver is then used during compilation and transformation to determine the location of URIs associated with the<xsl:import>,<xml:include>anddocument()constructs. This is equivalent to callingsetURIResolver(resolver, true).- Parameters:
resolver- An implementation of the URIResolver interface, or null
-
getURIResolver
Returns the current URI resolver setting.- Returns:
- The current resolver in use, or null if one hasn't been set or if it was previously nulled.
-
setTransformerConfigurationOption
public void setTransformerConfigurationOption(String name, Object value) throws IllegalArgumentException Set a configuration option on the XSLT transformers used in the pipeline. Some of the configuration options affect the compilation of XSLT filters and as the compilation process can be triggered by setInputFilters and setOutputFilters methods this method should be used prior to these methods if appropriate.
Please note: Some of the options available with Saxon assume that the Transformer is 'in control' of the parser or XMLReader used for input processing. In a PipelinedComparatorS9 this is not the case; if an attribute seems to have no effect look for alternative techniques such as using equivalent features and the
CommonComparator.setParserFeature(java.lang.String, boolean)method.- Specified by:
setTransformerConfigurationOptionin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
name- The name of the option to setvalue- The value to be set (an Object)- Throws:
IllegalArgumentException- if the attribute name is not recognized by the underlying Transformer- See Also:
-
- Saxon Feature
getTransformerConfigurationOption(String)CommonComparator.setParserFeature(String, boolean)
-
getTransformerConfigurationOption
Reports current attribute settings of the XSLT transformers in the pipeline.- Specified by:
getTransformerConfigurationOptionin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
name- of the option to report- Returns:
- an Object representing the current setting
- Throws:
IllegalArgumentException- if the attribute name is not recognized by the underlying TransformerFactory- See Also:
-
setOutputProperty
public void setOutputProperty(net.sf.saxon.s9api.Serializer.Property property, String value) throws IllegalArgumentException Configures output formatting and control.
Any properties set here are then passed to the
Serializerused to write the output in most of the compare methods. The compare method which returns an XdmNode result bypasses XML serialization and any properties will have no effect with this method.NOTE The Saxon s9api Serializer will throw an XPathException which in turn will be presented as an exception during compare or isEqual when "omit-xml-declaration" has the value "yes" and standalone has either of the values "yes" or "no". Saxon does however support setting the "standalone" property to "omit" as described in the XSLT2 serialization specification.
Earlier releases supported only a limited subset of the common properties. The drawback of the new approach is that PropertyNotRecognized exceptions cannot be reported immediately when the property is set.
Output properties should be set using the
Serializer.Propertyenumeration as follows:PipelinedComparatorS9 pc= new PipelinedComparatorS9(); ... pc.setOutputProperty(Serializer.Property.INDENT, "yes");
- Specified by:
setOutputPropertyin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
property- the property to setvalue- the new value for the property- Throws:
IllegalArgumentException- if a parameter value is illegal in some way- See Also:
-
Serializer.setOutputProperty(net.sf.saxon.s9api.Serializer.Property, java.lang.String)Serializer.Property- XSLT 2.0 and XQuery 1.0 Serialization, section 5.1.5
-
getLexicalPreservationConfig
Returns the current lexical preservation configuration settings.
- Returns:
- a configuration object containing the settings in use for lexical preservation (or null if it has not been configured).
- Since:
- 7.0
-
setLexicalPreservationConfig
Sets the
LexicalPreservationConfigto use during comparison.- Parameters:
lpc- theLexicalPreservationConfigobject to use during comparison- Since:
- 7.0
Note that setting the
configvalue tonulldisables the lexical preservation. - See Also:
-
setBypassLexicalPreservationOutputChain
public void setBypassLexicalPreservationOutputChain(boolean value) Sets whether or not to bypass the automatically added lexical preservation output chain during the comparison.
Typically, this will be set to true and if a
LexicalPreservationConfigobject is set on thisPipelinedComparator, the output chain will be added automatically. However, if you wish to add these filters to a different location, you can create them usingnewLexicalPreservationOutputFilterChain(LexicalPreservationConfig)and manually add them to the outputFilterChain. If you do this, you should turn off the automatic addition by passing a value offalseto this method.- Parameters:
value- whether or not to bypass the automatic lexical preservation output chain- Since:
- 7.0
-
isBypassLexicalPreservationOutputChain
public boolean isBypassLexicalPreservationOutputChain()States whether the lexical preservation output chain is being bypassed or not.
- Returns:
- a boolean stating whether the output chain is bypassed or not
- Since:
- 7.0
- See Also:
-
setCancellationPolicy
Set a policy to timeout the comparison.- Parameters:
policy- The policy which dictates how the timeout will work. The default isCancellationPolicy.NooptimeoutMs- An Optional timeout for use when policy isCancellationPolicy.Timed. The default is 5 minutes- See Also:
-
setInput1Filters
Allows filters to be specified using aFilterChain.Filters added using this method will be applied to input 1 only.
- Parameters:
filters- theFilterChainobject to be set as the input filters on input 1 for this PipelinedComparator- Since:
- 7.0
-
setInput2Filters
Allows filters to be specified using aFilterChain.Filters added using this method will be applied to input 2 only.
- Parameters:
filters- theFilterChainobject to be set as the input filters on input 2 for this PipelinedComparator
-
setInputFilters
Allows input filters to be specified using aFilterChain.Filters added using this method will be applied to both inputs.
If the
FilterChaincontains anyXMLFilterImplSteps then consideration of serial reusability and multithreaded operation is necessary. Please see the javadoc for theXMLFilterImplStepclass.- Parameters:
filters- theFilterChainobject to be set as the input filters on this PipelinedComparator- Since:
- 7.0
- See Also:
-
XMLFilterImplStep
-
setThreadingConfig
Sets the current
ThreadingConfiginstance in use byPipelinedComparator.- Parameters:
threadingConfig- theThreadingConfigto set on thisPipelinedComparator.
-
getThreadingConfig
Gets the current
ThreadingConfiginstance in use byPipelinedComparator.- Returns:
- the current
ThreadingConfiginstance in use byPipelinedComparator.
-
setOutputFilters
Allows output filters to be specified using aFilterChain.Filters added using this method will be applied to the output only.
- Parameters:
filters- theFilterChainobject to be set as the output filters for this PipelinedComparator- Since:
- 7.0
-
setDebugFiles
public void setDebugFiles(boolean debug) Determines whether intermediate pipeline result files are generated. When developing a pipelined application it is sometimes useful to see the intermediate results. This debug option when set will generate a file containing the XML corresponding the intermediate result of most of the pipeline stages. These files are generated in the current working directory and are named according to the filter chain (a, b, result) and their position within the chain. An optional prefix can be supplied and is useful in applications involving multiple comparison pipelines or multiple invocations of a pipeline so that the intermediate results are not overwritten on sucessive comparison runs and can be differentiated.- Specified by:
setDebugFilesin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
debug- when true intermediate result files are produced- See Also:
-
getDebugFiles
public boolean getDebugFiles()Gets whether the production of debug files is on or not.
- Specified by:
getDebugFilesin interfacecom.deltaxml.core.internals.CommonComparator- Returns:
- whether the production of debug files is on or not.
- See Also:
-
setDebugFilesPrefix
Provides a prefix for debug result files.- Specified by:
setDebugFilesPrefixin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
debugPrefix- Must be a non null String which can be used as a valid name for a directory in which debug files will be put.- See Also:
-
getDebugFilesPrefix
This returns where the debug files will be found.- Specified by:
getDebugFilesPrefixin interfacecom.deltaxml.core.internals.CommonComparator- Returns:
- The name of the directory where debug files are placed
- See Also:
-
setOptimizeXMLFiltersAroundComparator
public void setOptimizeXMLFiltersAroundComparator(boolean optimize) Apply streaming optimization to filters around the comparator. When Java-based filters are used adjacent to the comparator it is possible to stream (by passing SAX 'events') information between them and the comparator. This reduces run-time and also can have a significant effect on the amount of heap memory required, particularly when word-by-word filters are used.- Parameters:
optimize- if true optimization is done
-
getOptimizeXMLFiltersAroundComparator
public boolean getOptimizeXMLFiltersAroundComparator()Reports the current value of the optimization setting.- Returns:
- true if optimization is turned on
-
newLexicalPreservationOutputFilterChain
public FilterChain newLexicalPreservationOutputFilterChain(LexicalPreservationConfig config) throws ParserInstantiationException Generates a
FilterChainto process lexical preservation items.The parameter settings of the
FilterSteps in theFilterChainwill be based upon the suppliedLexicalPreservationConfig.N.B. Serialization aspects of lexical preservation output (e.g. DOCTYPE, CDATA etc.) will not be configured in the resultant FilterChain. These options will still need to be set on whatever object is being used for Serialization (whether that be as part of the comparison or as a separate serialization step)
- Parameters:
config- the configuration object upon which to base the lexical preservation output parameters- Returns:
- a pre-configured FilterChain to add to the output
FilterChainof aPipelinedComparator - Throws:
ParserInstantiationException- Since:
- 7.0
-
isEqual
public boolean isEqual(net.sf.saxon.s9api.XdmNode a, net.sf.saxon.s9api.XdmNode b) throws FilterProcessingException, ComparisonException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Compares two XdmNode inputs and returns whether they're equal. An XdmNode can have an associated baseURI (see the Saxon DocumentBuilder and the getBaseURI methods) and thus String systemId arguments are not required as they are in other compare and isEqual methods.- Parameters:
a- the first XdmNode tree to compareb- the second XdmNode tree to compare against the first- Returns:
- whether the two inputs are equal after they have been processed with the input filters
- Throws:
com.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationFilterProcessingException- if there was a problem running any of the filtersComparisonException- if there is a problem during the comparison stage of the pipelineComparisonCancelledException- If the comparison was cancelled
-
isEqual
public boolean isEqual(File f1, File f2) throws ComparisonException, FilterProcessingException, FileNotFoundException, IOException, PipelineLoadingException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Compares two File inputs and returns whether they're equal.- Parameters:
f1- the first File object to comparef2- the second File object to compare against the first- Returns:
- whether the two input files are equal after they have been processed with the input filters
- Throws:
IOException- if there is a problem constructing or closing FileInputStreams using the argumentsFileNotFoundException- if the input File argument cannot be foundPipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filterscom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonException- if there is a problem during the comparison stage of the pipelineComparisonCancelledException- if the comparison is cancelled
-
isEqual
public boolean isEqual(Reader a, String systemIdA, Reader b, String systemIdB) throws ComparisonException, FilterProcessingException, PipelineLoadingException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Compares two Reader inputs and returns whether they're equal.Warning: Using this isEqual method with input data that refers to relative URIs is not recommended. We would recommend using
isEqual(InputSource, InputSource)and constructing InputSources with a Reader and a systemId to ensure that relative URIs are referenced correctly.- Parameters:
a- The reader from which the first input is readb- The reader for the second inputsystemIdA- the SystemId used for resolving URIs and reporting errors associated with the A inputsystemIdB- the SystemId used for resolving URIs and reporting errors associated with the B input- Returns:
- whether the two inputs are equal after they have been processed with the input filters
- Throws:
ComparisonException- if there is a problem during the comparison stage of the pipelinePipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filterscom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if the comparison is cancelled
-
isEqual
public boolean isEqual(InputSource is1, InputSource is2) throws ComparisonException, FilterProcessingException, PipelineLoadingException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Compares two InputSource inputs and returns whether they're equal.- Parameters:
is1- the first InputSource object to compareis2- the second InputSource object to compare against the first- Returns:
- whether the two inputs are equal after they have been processed with the input filters
- Throws:
ComparisonException- if there is a problem during the comparison stage of the pipelinePipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filterscom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if the comparison is cancelled
-
isEqual
public boolean isEqual(InputStream a, String systemIdA, InputStream b, String systemIdB) throws ComparisonException, PipelineLoadingException, FilterProcessingException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Compares two InputStream inputs and returns whether they're equal.- Parameters:
a- The InputStream from which the first input is readb- The InputStream for the second inputsystemIdA- the SystemId used for resolving URIs and reporting errors associated with the A inputsystemIdB- the SystemId used for resolving URIs and reporting errors associated with the B input- Returns:
- whether the two input streams are equal after they have been processed with the input filters
- Throws:
ComparisonException- if there is a problem during the comparison stage of the pipelinePipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filterscom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if the comparison is cancelled
-
isEqual
public boolean isEqual(String a, String systemIdA, String b, String systemIdB) throws ComparisonException, PipelineLoadingException, FilterProcessingException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Compares two String inputs and returns whether they're equal.- Parameters:
a- The String from which the first input is readb- The String for the second inputsystemIdA- the SystemId used for resolving URIs and reporting errors associated with the A inputsystemIdB- the SystemId used for resolving URIs and reporting errors associated with the B input- Returns:
- whether the XML contained in the two strings is equal after they have been processed with the input filters
- Throws:
ComparisonException- if there is a problem during the comparison stage of the pipelinePipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filterscom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if the comparison is cancelled
-
isEqual
public boolean isEqual(URL u1, URL u2) throws ComparisonException, PipelineLoadingException, FilterProcessingException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Compares two URL inputs and returns whether they're equal.- Parameters:
u1- the first URL to compareu2- the second URL to compare against the first- Returns:
- whether the two inputs are equal after they have been processed with the input filters
- Throws:
ComparisonException- if there is a problem during the comparison stage of the pipelinePipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filterscom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if the comparison is cancelled
-
addProgressListener
Add a progress listener to the list of registered progress listeners. It is possible to add the same listener multiple times.- Parameters:
ppl- the progress listener to register.
-
removeProgressListener
Remove a progress listener from the list of registered progress listeners. This will remove the first occurrence of a progress listener.- Parameters:
ppl- the progress listener to remove.
-
getNumberOfProgressStages
Description copied from interface:com.deltaxml.core.internals.CommonComparatorGet the total number of enabled Progress Reporting Stages. The number returned by this function is dependent on the number of input and output filters that are enabled, so should be called once all these filters have been loaded and configured. It corresponds to the number of Finish messages that will be reported by thePipelineProgressListener.- Specified by:
getNumberOfProgressStagesin interfacecom.deltaxml.core.internals.CommonComparator- Returns:
- the number of enabled stages that the comparison pipeline contains.
- Throws:
ParserInstantiationException
-
clearProgressListeners
public void clearProgressListeners()Remove all currently registered progress listeners. -
getParserFeature
public boolean getParserFeature(String featureName) throws FeatureNotRecognizedException, IllegalArgumentException Description copied from interface:com.deltaxml.core.internals.CommonComparatorAllows the current settings of parser features to be determined.- Specified by:
getParserFeaturein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
featureName- the name of the feature whose value is being queried- Returns:
- the current value of the feature
- Throws:
FeatureNotRecognizedException- if the featureName is not recognizedIllegalArgumentException- if the argument is null- See Also:
-
CommonComparator.setParserFeature(String, boolean)
-
setParserFeature
public void setParserFeature(String featureName, boolean value) throws FeatureSettingNotSupportedException, FeatureNotRecognizedException, IllegalArgumentException Description copied from interface:com.deltaxml.core.internals.CommonComparatorSets a feature on the parser used for reading XML inputs into a Core S9 Comparator.
Feature setting modify the parsing behaviour of a pipeline. In particular features relating to input validation, schema and DTD handling can be controlled. The features which can be controlled are features of the underlying SAX parser used in the pipeline (but with some exceptions described below). If the SAX parser being used is Apache Xerces, the features which can be set are both the generic SAX features and Apache specific ones.
These features are only appropriate and will only be applied when the compare methods in this class are responsible for parsing and loading input XML data. When the compare or isEqual methods use XdmNode arguments the data has already been parsed and the code being used for creating the XdmNode objects should be configured appropriately.
The following table lists settings which should not be used, as the Saxon s9api code used internally in the PipelinedComparator will override these settings. Alternative settings using the
CommonComparator.setTransformerConfigurationOption(java.lang.String, java.lang.Object)method must be used instead:Settings that must not be used. Parser Feature Corresponding setTransformerConfigurationOption http://xml.org/sax/features/validation Feature.DTD_VALIDATIONhttp://apache.org/xml/features/xinclude-aware Feature.XINCLUDEhttp://apache.org/xml/features/xinclude Feature.XINCLUDEThe following list includes some of the features which we consider useful in conjunction with a pipelined comparator architecture:
- http://apache.org/xml/features/validation/ dynamic
- http://apache.org/xml/features/validation/ schema
- http://apache.org/xml/features/ nonvalidating/load-dtd-grammar
- http://apache.org/xml/features/ nonvalidating/load-external-dtd
The following table lists features that can only be set to specific values. These fixed settings are necessary for the comparator to operate properly. This in turn is because Saxon requires particular feature settings to be used and supported by setFeature. Any attempt to set values other than those shown below will result in a
FeatureSettingNotSupportedExceptionbeing thrown.Settings that are restricted. Feature fixed/permissible value http://xml.org/sax/features/namespaces true http://xml.org/sax/features/namespace- prefixes false - Specified by:
setParserFeaturein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
featureName- the name of the feature to be setvalue- the new value for the feature- Throws:
FeatureSettingNotSupportedException- if the feature cannot be set to the specific valueFeatureNotRecognizedException- if the featureName is not recognizedIllegalArgumentException- if the featureName argument is null- See Also:
-
XMLReader.setFeature(String, boolean)Processor.setConfigurationProperty(Feature, Object)Feature
-
getParserProperty
public Object getParserProperty(String propertyName) throws PropertyNotRecognizedException, IllegalArgumentException Description copied from interface:com.deltaxml.core.internals.CommonComparatorAllows the current settings of parser properties to be determined.- Specified by:
getParserPropertyin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
propertyName- the name of the property whose value is being queried- Returns:
- an Object representing the current value of the property
- Throws:
PropertyNotRecognizedException- if the property name is not recognizedIllegalArgumentException- if the argument is null- See Also:
-
CommonComparator.setParserProperty(String, Object)
-
setParserProperty
public void setParserProperty(String propertyName, Object value) throws PropertyNotRecognizedException, PropertySettingNotSupportedException, IllegalArgumentException Description copied from interface:com.deltaxml.core.internals.CommonComparatorConfigures parser properties for the pipeline input parsers.
Allows properties of the underlying parser to be configured. If using Apache Xerces-J the following properties may prove useful in comparator pipelines:
- Specified by:
setParserPropertyin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
propertyName- the name of the property to set on the parservalue- the new value for the property- Throws:
PropertyNotRecognizedException- if the property name is not recognizedPropertySettingNotSupportedException- if the property cannot be set to the specific valueIllegalArgumentException- if an argument is null- See Also:
-
CommonComparator.getParserProperty(String)XMLReader.setProperty(java.lang.String, java.lang.Object)
-
getOutputProperty
Description copied from interface:com.deltaxml.core.internals.CommonComparatorAllows the current settings of the serializer properties to be determined.- Specified by:
getOutputPropertyin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
property- the output property whose value is being queried- Returns:
- the value of the property
- See Also:
-
Serializer.Property
-
compare
public void compare(File f1, File f2, File result) throws ComparisonException, FilterProcessingException, IOException, PipelineLoadingException, PipelineSerializationException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Description copied from interface:com.deltaxml.core.internals.CommonComparatorCompares File objects and uses a File to represent the result.
- Specified by:
comparein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
f1- the first comparison inputf2- the second inputresult- the location where the pipeline result will be written- Throws:
ComparisonException- if there is a problem during the comparison processingFilterProcessingException- if there was a problem running any of the filtersFileNotFoundException- if the input or output files cannot be foundIOException- if there is a problem opening/closing streams associated with the File argumentsPipelineLoadingException- if the inputs cannot be loaded or parsedPipelineSerializationException- if the result cannot be saved or serialized to the result locationcom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if a comparison is cancelled according to theCancellationPolicyin force
-
compare
public void compare(Reader a, String systemIdA, Reader b, String systemIdB, Writer result) throws ComparisonException, FilterProcessingException, PipelineLoadingException, PipelineSerializationException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Description copied from interface:com.deltaxml.core.internals.CommonComparatorCompares the XML obtained from Reader objects and uses a Writer to represent the pipeline result.
systemId parameters are provided so that relative URIs can be resolved in the inputs, they are also useful when reporting errors as the systemId may be useful when locating the error position. Using identifiers such as "string1" or "database2" may be useful when the inputs do not contain URIs to resolve as they can aid error diagnosis.
- Specified by:
comparein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
a- The reader from which the first input is readsystemIdA- the SystemId used for resolving URIs and reporting errors associated with the A inputb- The reader for the second inputsystemIdB- the SystemId used for resolving URIs and reporting errors associated with the B inputresult- where the pipeline result will be written- Throws:
ComparisonException- if there is a problem during the comparison processingFilterProcessingException- if there was a problem running any of the filtersPipelineLoadingException- if the inputs cannot be loaded or parsedPipelineSerializationException- if the output cannot be saved or serialized to the result locationcom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if a comparison is cancelled according to theCancellationPolicyin force
-
compare
public void compare(InputStream a, String systemIdA, InputStream b, String systemIdB, OutputStream result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Description copied from interface:com.deltaxml.core.internals.CommonComparatorCompares the XML obtained from InputStream objects and uses an OutputStream to represent the pipeline result.
systemId parameters are provided so that relative URIs can be resolved in the inputs, they are also useful when reporting errors as the systemId may be useful when locating the error position. Using identifiers such as "string1" or "database2" may be useful when the inputs do not contain URIs to resolve as they can aid error diagnosis.
- Specified by:
comparein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
a- The InputStream from which the first input is readsystemIdA- the SystemId used for resolving URIs and reporting errors associated with the A inputb- The InputStream for the second inputsystemIdB- the SystemId used for resolving URIs and reporting errors associated with the B inputresult- where the pipeline result will be written- Throws:
ComparisonException- if there is a problem during the comparison processingPipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filtersPipelineSerializationException- if the output cannot be saved or serialized to the result locationcom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if a comparison is cancelled according to theCancellationPolicyin force
-
compare
public void compare(String a, String systemIdA, String b, String systemIdB, StringBuilder result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Description copied from interface:com.deltaxml.core.internals.CommonComparatorCompares the XML obtained from Strings and uses a StringBuilder to represent the pipeline result.
systemId parameters are provided so that relative URIs can be resolved in the inputs, they are also useful when reporting errors as the systemId may be useful when locating the error position. Using identifiers such as "string1" or "database2" may be useful when the inputs do not contain URIs to resolve as they can aid error diagnosis.
- Specified by:
comparein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
a- The String from which the first input is readsystemIdA- the SystemId used for resolving URIs and reporting errors associated with the A inputb- The String for the second inputsystemIdB- the SystemId used for resolving URIs and reporting errors associated with the B inputresult- where the pipeline result will be written- Throws:
ComparisonException- if there is a problem during the comparison processingPipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filtersPipelineSerializationException- if the output cannot be saved or serialized to the result locationcom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if a comparison is cancelled according to theCancellationPolicyin force
-
compare
public void compare(URL a, URL b, File result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, FileNotFoundException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Description copied from interface:com.deltaxml.core.internals.CommonComparatorCompares the XML obtained from URLs and writes the pipeline result to a File.
- Specified by:
comparein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
a- The URL from which the first input is loadedb- The URL for the second inputresult- where the pipeline result will be written- Throws:
ComparisonException- if there is a problem during the comparison processingPipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filtersPipelineSerializationException- if the output cannot be saved or serialized to the result locationFileNotFoundException- if the output file location cannot be foundcom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if a comparison is cancelled according to theCancellationPolicyin force
-
compare
public void compare(URL a, URL b, OutputStream result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Description copied from interface:com.deltaxml.core.internals.CommonComparatorCompares the XML obtained from URLs and writes the pipeline result to an OutputStream.
- Specified by:
comparein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
a- The URL from which the first input is loadedb- The URL for the second inputresult- where the pipeline result will be written- Throws:
ComparisonException- if there is a problem during the comparison processingPipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filtersPipelineSerializationException- if the input cannot be saved or serialized to the result locationcom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operationComparisonCancelledException- if a comparison is cancelled according to theCancellationPolicyin force
-
compare
public void compare(InputSource a, InputSource b, StreamResult result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, ComparisonCancelledException, com.deltaxml.licensing.LicenseException Description copied from interface:com.deltaxml.core.internals.CommonComparatorCompares the XML obtained from InputSource Objects and writes the pipeline result to a StreamResult.
It is recommended that systemIds be associated with the InputSource parameters so that relative URIs and external entities can be resolved.
- Specified by:
comparein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
a- The InputSource from which the first input is loadedb- The InputSource for the second inputresult- where the pipeline result will be written- Throws:
ComparisonException- if their is a problem during the comparison stage of the pipelinePipelineLoadingException- if the inputs cannot be loaded or parsedFilterProcessingException- if there was a problem running any of the filtersPipelineSerializationException- if the output cannot be saved or serialized to the result locationComparisonCancelledException- if a comparison is cancelled according to theCancellationPolicyin forcecom.deltaxml.licensing.LicenseException- if there is a licensing issue that prevents operation
-
compare
public net.sf.saxon.s9api.XdmNode compare(net.sf.saxon.s9api.XdmNode a, net.sf.saxon.s9api.XdmNode b) throws FilterProcessingException, ComparisonException, com.deltaxml.licensing.LicenseException, IllegalArgumentException, ComparisonCancelledException Description copied from interface:com.deltaxml.core.internals.CommonComparatorCompares two Saxon XdmNode trees and generates an XdmNode tree result from the pipeline.
XdmNode trees are associated with specific s9api Processors. This method should be used in conjunction with one of the class constructors which takes a Processor argument.
- Specified by:
comparein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
a- The first XdmNode input tree to be comparedb- The second XdmNode input- Returns:
- an XdmNode tree containing the comparison result
- Throws:
FilterProcessingException- if there is a problem executing the pipeline filtersComparisonException- if there is a problem during the comparison processingcom.deltaxml.licensing.LicenseException- if there is a licensing issueIllegalArgumentException- if the XdmNodes were produced by an unknown Saxon ProcessorComparisonCancelledException- if a comparison is cancelled according to theCancellationPolicyin force
-
addLicenseFile
public void addLicenseFile(File licenseFile) throws SecurityException, IOException, com.deltaxml.licensing.LicenseException Description copied from interface:com.deltaxml.core.internals.CommonComparatorSets the license file for use with Flexera licensing. This can be either simple fixed host/user licensing, or a concurrent licensing containing the USE_SERVER directive- Specified by:
addLicenseFilein interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
licenseFile- the FlexLM format license file- Throws:
SecurityException- if the file cannot be accessedIOException- if there are problems reading the filecom.deltaxml.licensing.LicenseException- if there is a problem using the license file
-
addLicenseServer
Description copied from interface:com.deltaxml.core.internals.CommonComparatorSets a license server for use with concurrent licensing.- Specified by:
addLicenseServerin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
hostname- the license server host or its ip address- Throws:
com.deltaxml.licensing.LicenseException- if there is a problem using the license server
-
addLicenseServer
public void addLicenseServer(String hostname, int port) throws IllegalArgumentException, com.deltaxml.licensing.LicenseException Description copied from interface:com.deltaxml.core.internals.CommonComparatorSets a license server and port for use with concurrent licensing.- Specified by:
addLicenseServerin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
hostname- the license server host or its ip addressport- the port number on the license server for the lmgrd- Throws:
IllegalArgumentException- if the port number is out of rangecom.deltaxml.licensing.LicenseException- if there is a problem using the license server
-