Class DocumentComparator
- All Implemented Interfaces:
com.deltaxml.core.internals.CommonComparator
Provides a pre-configured comparison tool more suited for document comparison.
TheDocumentComparator includes pre- and post-comparison filters for improving results for many items commonly featured
in XML documents. These items include:
- CALS tables
- XHTML tables
- Inline formatting markup
- Doctypes and entities
- Comments and processing instructions
'Format-aware' comparison
One of the main features of the DocumentComparator is that it can be configured to remove formatting elements for the
purposes of word alignment during comparison. This leads to significant improvements in the comparison results of text content
when the formatting of text changes.
Due to structural changes that occur in the XML when inline formatting elements are added, removed or changed, it can be all
too easy to find deletion and addition of identical text in a comparison result. The DocumentComparator takes the
approach that 'content is king' and that if textual content hasn't been changed then there should be no text changes
highlighted in the result.
To achieve this result, inline formatting elements must be highlighted in the input files before comparison. Formating elements
must be marked with a deltaxml:format="true" attribute. The simplest way of achieving this is to write an XSLT filter that adds
the attributes to the relevant elements, then add it to the DocumentComparator.ExtensionPoint.PRE_FLATTENING extension point before
comparison using the setExtensionPoint(ExtensionPoint, FilterChain) method.
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:
- 7.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents the point at which userFilterSteps can be inserted. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThis is a boolean configuration property that when true will send most or all intermediate results to files. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DocumentComparator.DocumentComparator(net.sf.saxon.s9api.Processor suppliedProcessor) Creates a new DocumentComparator. -
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.voidaddProgressListener(com.deltaxml.core.FeatureProgressListener dpl) Add a progress listener to the list of registered progress listeners.voidcancel()Cancel a running comparison from a different thread.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.voidcomparePartial(InputSource a, InputSource b, StreamResult result) Run partial comparison up to Part 2 of output chain - used for DITA Map Topicset comparisons.Gets the current Attribute Splitting Configuration setting.Returns the current configuration options for CALS table comparison.booleanGets whether the production of debug files is on or not.Get the current prefix used for debug result files.Returns the current entity resolver setting.Returns the current configuration options for HTML table comparison.Gets the current Ignore Changes Configuration setting.Gets the current Binary Image comparison configuration.Returns the current lexical preservation configuration settings.Returns the current MathML configuration options.Gets the current Move Detection configuration settings.Gets theNamespaceConfigurationsettings in use.intGet the total number of enabled Progress Reporting Stages.Returns the current configuration options for the format of the result document.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.Returns the String currently set as the output directory for comparison report.Returns the current configuration options for result readability.Gets the current Subtree Processing Mode setting.Returns the current SVG comparison options.Gets the currentThreadingConfiginstance in use byDocumentComparator.Reports current attribute settings of the XSLT transformers in the pipeline.Returns the current URI resolver setting.booleanReturns whether the comparison report is generated or not.voidremoveProgressListener(com.deltaxml.core.FeatureProgressListener dpl) Remove a progress listener from the list of registered progress listeners.voidvoidsetAttributeSplittingConfig(AttributeSplittingConfig attributeSplittingConfig) Sets the configuration options for Attribute Splitting.voidSets the configuration options for CALS table 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) Provide a prefix for debug result files.voidsetEntityResolver(EntityResolver resolver) Set an entity resolver for use when reading the inputs to the document comparator.voidsetEntityResolver(EntityResolver resolver, boolean useFallbackEntityResolver) Set an entity resolver for use when reading the inputs to the document comparator.voidsetExtensionPoint(DocumentComparator.ExtensionPoint extensionPoint, FilterChain chain) Sets theFilterChainto run at the specifiedDocumentComparator.ExtensionPoint.voidsetGenerateComparisonReport(boolean generateComparisonReport) Turns on or off the generation of an HTML comparison report on completion of a comparison.voidSets the configuration options for HTML table comparison.voidsetIgnoreChangesConfig(IgnoreChangesConfig ignoreChangesConfig) Sets the configuration options for Ignore Changes Processing.voidsetImageConfiguration(ImageConfiguration imageConfig) Sets the configuration options for the Binary Image comparison.voidSets theLexicalPreservationConfigto use during comparison.voidsetMathMLConfig(MathMLConfig config) Sets the configuration options for the MathML processing.voidsetMoveDetectionConfig(MoveDetectionConfig moveDetectionConfig) Sets the configuration options for Move Detection.voidsetNamespaceConfiguration(NamespaceConfiguration namespaceConfiguration) Sets theNamespaceConfigurationsettings to be used.voidSets the configuration options for the format of the result document.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.voidsetReportDirectory(String reportDirectory) Set the output directory where a comparison report will be generated.voidSet the configuration options for making a comparison result more readable.voidsetSubtreeProcessingMode(SubtreeProcessingMode subtreeProcessingMode) Sets the configuration options for Subtree Processing.voidsetSVGConfig(SVGConfiguration config) Sets the configuration options for the SVG comparison.voidsetThreadingConfig(ThreadingConfig threadingConfig) Set the currentThreadingConfiginstance in use by the comparator.voidsetTransformerConfigurationOption(String name, Object value) Set a configuration option on the XSLT transformers used in a Core S9 API comparator.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, getDebugFiles, getDebugFilesPrefix, getNumberOfProgressStages, getOutputProperty, getParserFeature, getParserProperty, getTransformerConfigurationOption, newFilterStepHelper, setDebugFiles, setDebugFilesPrefix, setParserFeature, setParserProperty, setTransformerConfigurationOption
-
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:
-
CommonComparator.setDebugFiles(boolean)- Constant Field Values
-
-
Constructor Details
-
DocumentComparator
public DocumentComparator() throws ParserInstantiationException, FilterConfigurationException, FilterClassInstantiationExceptionCreates a new DocumentComparator. This will use an internal Saxon
Processorfor running XSLT transformations.- Throws:
ParserInstantiationException- if there is a problem instantiating an XML parserFilterConfigurationException- if any of the Filters used internally by the pipeline cannot be configured correctlyFilterClassInstantiationException- if any of the Java filters used by the pipeline cannot be instantiated
-
DocumentComparator
public DocumentComparator(net.sf.saxon.s9api.Processor suppliedProcessor) throws ParserInstantiationException, IllegalArgumentException, FilterConfigurationException, FilterClassInstantiationException Creates a new DocumentComparator. This will use the supplied Saxon
Processorfor running XSLT transformations.- Parameters:
suppliedProcessor- a SaxonProcessorto be used for the NamePool and filter compilation- Throws:
ParserInstantiationException- if there is a problem instantiating an XML parserIllegalArgumentException- if the suppliedProcessoris from a version of Saxon that is not supported by theDocumentComparatorFilterConfigurationException- if any of the Filters used internally by the pipeline cannot be configured correctlyFilterClassInstantiationException- if any of the Java filters used by the pipeline cannot be instantiated
-
-
Method Details
-
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.
Output properties should be set using the
Serializer.Propertyenumeration as follows:DocumentComparator dc= new DocumentComparator(); ... dc.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
-
setEntityResolver
Set an entity resolver for use when reading the inputs to the document 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 document 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.
-
setCalsTableConfiguration
Sets the configuration options for CALS table comparison.
- Parameters:
config- aCalsTableConfigurationobject that contains the settings to use for CALS table comparison
-
setHtmlTableConfiguration
Sets the configuration options for HTML table comparison.
- Parameters:
config- aHtmlTableConfigurationobject that contains the settings to use for HTML table comparison
-
getCalsTableConfiguration
Returns the current configuration options for CALS table comparison.
- Returns:
- a
CalsTableConfigurationobject that contains the settings in use for CALS table comparison
-
getHtmlTableConfiguration
Returns the current configuration options for HTML table comparison.
- Returns:
- a
HtmlTableConfigurationobject that contains the settings in use for HTML table comparison
-
setMathMLConfig
Sets the configuration options for the MathML processing.
- Parameters:
config- anMathMLConfiginstance that contains the settings to use- See Also:
-
getMathMLConfig
Returns the current MathML configuration options.
- Returns:
- an
MathMLConfiginstance that contains the current settings
-
setSVGConfig
Sets the configuration options for the SVG comparison.
- Parameters:
config- anSVGConfigurationinstance that contains the settings to use- Throws:
IllegalArgumentException- if passed XpathToReferencedSVG is invalid.- See Also:
-
getSVGConfig
Returns the current SVG comparison options.
- Returns:
- an
SVGConfigurationinstance that contains the current settings
-
getThreadingConfig
Gets the current
ThreadingConfiginstance in use byDocumentComparator.- Returns:
- the current
ThreadingConfiginstance in use byDocumentComparator.
-
setImageConfiguration
Sets the configuration options for the Binary Image comparison.
- Parameters:
imageConfig- anImageConfigurationinstance that contains the settings to use- Throws:
IllegalArgumentException- if passed imageXPaths are invalid.- See Also:
-
getImageConfiguration
Gets the current Binary Image comparison configuration.
- Returns:
- an
ImageConfigurationinstance that contains the current Binary Image comparison settings - See Also:
-
setExtensionPoint
Sets the
FilterChainto run at the specifiedDocumentComparator.ExtensionPoint.N.B. the supplied
FilterChainwill have its name set to the name of the suppliedDocumentComparator.ExtensionPointparameter (i.e. the result of callingDocumentComparator.ExtensionPoint.toString()).- Parameters:
extensionPoint- theDocumentComparator.ExtensionPointat which to insert theFilterChain;chain- theFilterChaincontaining theFilterSteps to insert at the specified extension point
-
getOutputFormatConfiguration
Returns the current configuration options for the format of the result document.
- Returns:
- an
OutputFormatConfigurationobject that contains the current settings
-
setOutputFormatConfiguration
Sets the configuration options for the format of the result document.
- Parameters:
config- anOutputFormatConfigurationinstance that contains the settings to use- See Also:
-
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:
config- theLexicalPreservationConfigobject to use during comparison- Since:
- 7.0
Note that setting the
configvalue tonullhas the same affect as resetting it back to its default value,resetLexicalPreservationConfigToDefault(). - See Also:
-
resetLexicalPreservationConfigToDefault
public void resetLexicalPreservationConfigToDefault() -
comparePartial
public void comparePartial(InputSource a, InputSource b, StreamResult result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, com.deltaxml.licensing.LicenseException, ComparisonCancelledException Run partial comparison up to Part 2 of output chain - used for DITA Map Topicset comparisons. (excluded from public javadoc and zkm unexclude)- Parameters:
a- the first comparison inputb- the second comparison inputresult- the location where the pipeline result will be written- 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 filtersPipelineSerializationException- 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
-
getReportDirectory
Returns the String currently set as the output directory for comparison report.
- Returns:
- a String representing the output directory to use when generating comparison report
-
isGenerateComparisonReport
public boolean isGenerateComparisonReport()Returns whether the comparison report is generated or not.
- Returns:
- boolean for comparison report generation
-
setGenerateComparisonReport
public void setGenerateComparisonReport(boolean generateComparisonReport) Turns on or off the generation of an HTML comparison report on completion of a comparison.
- Parameters:
generateComparisonReport- boolean for comparison report generation. True turns on report generation, false turns off generation.
-
setReportDirectory
Set the output directory where a comparison report will be generated.
- Parameters:
reportDirectory- a String representing the output directory to use when generating comparison report
-
setThreadingConfig
Set the current
ThreadingConfiginstance in use by the comparator.- Parameters:
threadingConfig- theThreadingConfigto set on this comparator.
-
getNamespaceConfiguration
Gets the
NamespaceConfigurationsettings in use.- Returns:
- the current
NamespaceConfigurationinstance that contains namespace settings. - See Also:
-
setNamespaceConfiguration
Sets the
NamespaceConfigurationsettings to be used.- Parameters:
namespaceConfiguration- aNamespaceConfigurationthat contains the settings to use- See Also:
-
getSubtreeProcessingMode
Gets the current Subtree Processing Mode setting.
- Returns:
- the current
SubtreeProcessingModeinstance that contains subtree processing settings.
-
setSubtreeProcessingMode
Sets the configuration options for Subtree Processing.
- Parameters:
subtreeProcessingMode- aSubtreeProcessingModethat contains the settings to use- Throws:
IllegalArgumentException- if passed subtree XPaths are invalid.
-
getIgnoreChangesConfig
Gets the current Ignore Changes Configuration setting.
- Returns:
- the current
IgnoreChangesConfiginstance that contains ignore changes settings.
-
setIgnoreChangesConfig
Sets the configuration options for Ignore Changes Processing.
- Parameters:
ignoreChangesConfig- aIgnoreChangesConfigthat contains the settings to use- Throws:
IllegalArgumentException- if passed ignoreChanges XPaths are invalid.
-
getAttributeSplittingConfig
Gets the current Attribute Splitting Configuration setting.
- Returns:
- the current
AttributeSplittingConfiginstance that contains the attribute splitting settings.
-
setAttributeSplittingConfig
Sets the configuration options for Attribute Splitting.
- Parameters:
attributeSplittingConfig- anAttributeSplittingConfigthat contains the settings to use- Throws:
IllegalArgumentException- if passed attributeLocation XPaths are invalid.
-
getMoveDetectionConfig
Gets the current Move Detection configuration settings.
- Returns:
- the current
MoveDetectionConfiginstance that contains move detection settings.
-
setMoveDetectionConfig
Sets the configuration options for Move Detection.
- Parameters:
moveDetectionConfig- aMoveDetectionConfigthat contains the settings to use- Throws:
IllegalArgumentException- if passed attributeXpath is invalid.
-
getResultReadabilityOptions
Returns the current configuration options for result readability.
- Returns:
- a
ResultReadabilityOptionsobjects that contains the current settings
-
setResultReadabilityOptions
Set the configuration options for making a comparison result more readable.
- Parameters:
options- aResultReadabilityOptionsinstance that contains the settings to use
-
getNumberOfProgressStages
public int getNumberOfProgressStages()Get 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.
-
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.
- Specified by:
setDebugFilesin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
debug- when true intermediate result files are produced- See Also:
-
CommonComparator.setDebugFilesPrefix(String)
-
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:
-
CommonComparator.setDebugFilesPrefix(String)
-
setDebugFilesPrefix
Provide a prefix for debug result files.- Specified by:
setDebugFilesPrefixin interfacecom.deltaxml.core.internals.CommonComparator- Parameters:
debugPrefix- The prefix that will be used for debug file names in subsequent compare operations- See Also:
-
CommonComparator.setDebugFiles(boolean)
-
getDebugFilesPrefix
Get the current prefix used for debug result files.- Specified by:
getDebugFilesPrefixin interfacecom.deltaxml.core.internals.CommonComparator- Returns:
- the current prefix used for debug result files.
- See Also:
-
CommonComparator.setDebugFiles(boolean)
-
clearProgressListeners
public void clearProgressListeners()Remove all currently registered progress listeners. -
addProgressListener
public void addProgressListener(com.deltaxml.core.FeatureProgressListener dpl) Add a progress listener to the list of registered progress listeners. It is possible to add the same listener multiple times.- Parameters:
dpl- the progress listener to register.
-
removeProgressListener
public void removeProgressListener(com.deltaxml.core.FeatureProgressListener dpl) Remove a progress listener from the list of registered progress listeners. This will remove the first occurrence of a progress listener.- Parameters:
dpl- the progress listener to remove.
-
setCancellationPolicy
Set a policy to timeout the comparison.- Parameters:
timeoutMs- An Optional timeout for use when policy isCancellationPolicy.Timed. The default is 5 minutespolicy- The policy which dictates how the timeout will work. The default isCancellationPolicy.Noop- See Also:
-
cancel
public void cancel()Cancel a running comparison from a different thread. -
newFilterStepHelper
Description copied from interface:com.deltaxml.core.internals.CommonComparatorCreates 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.- Specified by:
newFilterStepHelperin interfacecom.deltaxml.core.internals.CommonComparator- Returns:
- an instance of a
FilterStepHelperwith which to createFilterChains andFilterSteps for this Core S9 API Comparator.
-
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
-
getTransformerConfigurationOption
Description copied from interface:com.deltaxml.core.internals.CommonComparatorReports 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:
-
- Saxon Feature
- Xalan-J attributes
CommonComparator.setTransformerConfigurationOption(String, Object)
-
setTransformerConfigurationOption
public void setTransformerConfigurationOption(String name, Object value) throws IllegalArgumentException Description copied from interface:com.deltaxml.core.internals.CommonComparatorSet a configuration option on the XSLT transformers used in a Core S9 API comparator. Some of the configuration options affect the compilation of XSLT filters and as the compilation process can be triggered by various step helper methods. This method should be used prior to these methods if appropriate. Please also note that it is possible to create XSLT based steps using a Saxon Processor argument, this method will not apply to Steps created in this way as this method configures the Saxon Processor that is created by or passed as an argument to a Core S9 API comparator constructor.
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. This is not the case for Core S9 API comparators; 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
CommonComparator.getTransformerConfigurationOption(String)CommonComparator.setParserFeature(String, boolean)
-
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
-