public final class DocumentComparator extends java.lang.Object implements CommonComparator
Provides a pre-configured comparison tool more suited for document comparison.
The DocumentComparator
includes pre- and post-comparison filters for improving results for many items commonly featured
in XML documents. These items include:
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.
In order 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 DocumentComparator.setExtensionPoint(ExtensionPoint, FilterChain)
method.
Modifier and Type | Class and Description |
---|---|
static class |
DocumentComparator.ExtensionPoint
Represents the point at which user
FilterStep s can be inserted. |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONFIG_DEBUG_FILES
This is a boolean configuration property that when true will send most or all intermediate results to files.
|
static java.lang.String |
DO_NEW_TABLE_PROCESSING
This is a boolean configuration property, when set to true will use the new table processing algorithms
when comparing CALS or HTML tables within files.
|
Constructor and Description |
---|
DocumentComparator()
Creates a new DocumentComparator.
|
DocumentComparator(net.sf.saxon.s9api.Processor suppliedProcessor)
Creates a new DocumentComparator.
|
Modifier and Type | Method and Description |
---|---|
void |
addLicenseFile(java.io.File licenseFile)
Sets the license file for use with Flexera licensing.
|
void |
addLicenseServer(java.lang.String hostname)
Sets a license server for use with concurrent licensing.
|
void |
addLicenseServer(java.lang.String hostname,
int port)
Sets a license server and port for use with concurrent licensing.
|
void |
addProgressListener(DocumentProgressListener dpl)
Add a progress listener to the list of registered progress listeners.
|
void |
addUsageListener(com.deltaxml.cores9api.common.usage.ComUsageListener ul) |
void |
cancel()
Cancel a running comparison from a different thread.
|
void |
clearProgressListeners()
Remove all currently registered progress listeners.
|
void |
compare(java.io.File f1,
java.io.File f2,
java.io.File result)
Compares File objects and uses a File to represent the result.
|
void |
compare(org.xml.sax.InputSource a,
org.xml.sax.InputSource b,
javax.xml.transform.stream.StreamResult result)
Compares the XML obtained from InputSource Objects and writes the pipeline result to a StreamResult.
|
void |
compare(java.io.InputStream a,
java.lang.String systemIdA,
java.io.InputStream b,
java.lang.String systemIdB,
java.io.OutputStream result)
Compares the XML obtained from InputStream objects and uses an OutputStream to represent the pipeline result.
|
void |
compare(java.io.Reader a,
java.lang.String systemIdA,
java.io.Reader b,
java.lang.String systemIdB,
java.io.Writer result)
Compares the XML obtained from Reader objects and uses a Writer to represent the pipeline result.
|
void |
compare(java.lang.String a,
java.lang.String systemIdA,
java.lang.String b,
java.lang.String systemIdB,
java.lang.StringBuilder result)
Compares the XML obtained from Strings and uses a StringBuilder to represent the pipeline result.
|
void |
compare(java.net.URL a,
java.net.URL b,
java.io.File result)
Compares the XML obtained from URLs and writes the pipeline result to a File.
|
void |
compare(java.net.URL a,
java.net.URL b,
java.io.OutputStream result)
Compares the XML obtained from URLs and writes the pipeline result to an OutputStream.
|
net.sf.saxon.s9api.XdmNode |
compare(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.
|
void |
comparePartial(org.xml.sax.InputSource a,
org.xml.sax.InputSource b,
javax.xml.transform.stream.StreamResult result)
Run partial comparison up to Part 2 of output chain - used for DITA Map Topicset comparisons.
|
CalsTableConfiguration |
getCalsTableConfiguration()
Returns the current configuration options for CALS table comparison.
|
org.xml.sax.EntityResolver |
getEntityResolver()
Returns the current entity resolver setting.
|
HtmlTableConfiguration |
getHtmlTableConfiguration()
Returns the current configuration options for HTML table comparison.
|
LexicalPreservationConfig |
getLexicalPreservationConfig()
Returns the current lexical preservation configuration settings.
|
MathMLConfig |
getMathMLConfig()
Returns the current MathML configuration options.
|
MoveDetectionConfig |
getMoveDetectionConfig()
Gets the current Move Detection configuration settings.
|
int |
getNumberOfProgressStages()
Get the total number of enabled Progress Reporting Stages.
|
FilterChain |
getOutputFilterChainPart2()
Return Part 2 of output chain - used for DITA Map Topicset comparisons.
|
OutputFormatConfiguration |
getOutputFormatConfiguration()
Returns the current configuration options for the format of the result document.
|
java.lang.String |
getOutputProperty(net.sf.saxon.s9api.Serializer.Property property)
Allows the current settings of the serializer properties to be determined.
|
boolean |
getParserFeature(java.lang.String featureName)
Allows the current settings of parser features to be determined.
|
java.lang.Object |
getParserProperty(java.lang.String propertyName)
Allows the current settings of parser properties to be determined.
|
java.lang.String |
getReportDirectory()
Returns the String currently set as the output directory for comparison report.
|
ResultReadabilityOptions |
getResultReadabilityOptions()
Returns the current configuration options for result readability.
|
SubtreeProcessingMode |
getSubtreeProcessingMode()
Gets the current Subtree Processing Mode setting.
|
SVGConfiguration |
getSVGConfig()
Returns the current SVG comparison options.
|
java.lang.Object |
getTransformerConfigurationOption(java.lang.String name)
Reports current attribute settings of the XSLT transformers in the pipeline.
|
javax.xml.transform.URIResolver |
getURIResolver()
Returns the current URI resolver setting.
|
boolean |
isGenerateComparisonReport()
Returns the whether comparison report is generated or not.
|
FilterStepHelper |
newFilterStepHelper()
Creates a
FilterStepHelper using the Processor and URIResolver currently in use by this Core S9 API
Comparator. |
void |
removeProgressListener(DocumentProgressListener dpl)
Remove a progress listener from the list of registered progress listeners.
|
void |
removeUsageListener(com.deltaxml.cores9api.common.usage.ComUsageListener ul) |
void |
resetLexicalPreservationConfigToDefault()
Resets the
LexicalPreservationConfig setting back to the default mode. |
void |
setCalsTableConfiguration(CalsTableConfiguration config)
Sets the configuration options for CALS table comparison.
|
void |
setCancellationPolicy(CancellationPolicy policy,
java.util.Optional<java.lang.Long> timeoutMs)
Set a policy to timeout the comparison.
|
void |
setComUsageReporter(boolean isReportingFromExternal,
com.deltaxml.cores9api.common.usage.ComUsageReporter reporter,
java.util.Map<java.lang.String,com.deltaxml.cores9api.common.usage.ComJobFile> inputJobFiles,
java.util.Map<java.lang.String,java.lang.String> configuration) |
void |
setDebugFiles(boolean debug)
Determines whether intermediate pipeline result files are generated.
|
void |
setDebugFilesPrefix(java.lang.String prefix)
Provides a prefix for debug result files.
|
void |
setEntityResolver(org.xml.sax.EntityResolver resolver)
Set an entity resolver for use when reading the inputs to the pipelined comparator.
|
void |
setEntityResolver(org.xml.sax.EntityResolver resolver,
boolean useFallbackEntityResolver)
Set an entity resolver for use when reading the inputs to the pipelined comparator.
|
void |
setEvaluationVariables(boolean isEval,
double obfuscatePercentage)
Used to pass on the evaluation information to the underlying comparator used in the other products like DocBook.
|
void |
setExtensionPoint(DocumentComparator.ExtensionPoint extensionPoint,
FilterChain chain)
Sets the
FilterChain to run at the specified DocumentComparator.ExtensionPoint . |
void |
setGenerateComparisonReport(boolean generateComparisonReport)
This method used to generate comparison report.
|
void |
setHtmlTableConfiguration(HtmlTableConfiguration config)
Sets the configuration options for HTML table comparison.
|
void |
setLexicalPreservationConfig(LexicalPreservationConfig config)
Sets the
LexicalPreservationConfig to use during comparison. |
void |
setMathMLConfig(MathMLConfig config)
Sets the configuration options for the MathML processing.
|
void |
setMoveDetectionConfig(MoveDetectionConfig moveDetectionConfig)
Sets the configuration options for Move Detection.
|
void |
setOutputFormatConfiguration(OutputFormatConfiguration config)
Sets the configuration options for the format of the result document.
|
void |
setOutputProperty(net.sf.saxon.s9api.Serializer.Property property,
java.lang.String value)
Configures output formatting and control.
|
void |
setParserFeature(java.lang.String featureName,
boolean value)
Sets a feature on the parser used for reading XML inputs into a Core S9 Comparator.
|
void |
setParserProperty(java.lang.String propertyName,
java.lang.Object value)
Configures parser properties for the pipeline input parsers.
|
void |
setRedistributionLicenseContent(long[] encodedLicense)
Sets a redistribution license for use with subsequent compare operations.
|
void |
setRedistributionLicenseContent(long[] encodedLicense,
com.deltaxml.licensing.LicenseContent parent,
java.util.Set<java.lang.String> overrideKeys)
Sets a redistribution license for use with subsequent compare operations.
|
void |
setReportDirectory(java.lang.String reportDirectory)
Sets the String to use for the output directory when generating comparison report.
|
void |
setResultReadabilityOptions(ResultReadabilityOptions options)
Sets the configuration options for making a document result more readable.
|
void |
setSubtreeProcessingMode(SubtreeProcessingMode subtreeProcessingMode)
Sets the configuration options for Subtree Processing.
|
void |
setSVGConfig(SVGConfiguration config)
Sets the configuration options for the SVG comparison.
|
void |
setTransformerConfigurationOption(java.lang.String name,
java.lang.Object value)
Set a configuration option on the XSLT transformers used in a Core S9 API comparator.
|
void |
setURIResolver(javax.xml.transform.URIResolver resolver)
Sets a resolver for use by all XSLT based filters in a Core S9 API comparator.
|
void |
setURIResolver(javax.xml.transform.URIResolver resolver,
boolean useFallbackURIResolver)
Sets a resolver for use by all XSLT based filters in a Core S9 API comparator.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLicenseFile, addLicenseServer, addLicenseServer, compare, compare, compare, compare, compare, compare, compare, compare, getEntityResolver, getLexicalPreservationConfig, getOutputProperty, getParserFeature, getParserProperty, getTransformerConfigurationOption, getURIResolver, newFilterStepHelper, setEntityResolver, setEntityResolver, setParserFeature, setParserProperty, setTransformerConfigurationOption, setURIResolver, setURIResolver
public static final java.lang.String CONFIG_DEBUG_FILES
public static final java.lang.String DO_NEW_TABLE_PROCESSING
public DocumentComparator() throws ParserInstantiationException, FilterConfigurationException, ComparatorInstantiationException, FilterClassInstantiationException
Creates a new DocumentComparator. This will use an internal Saxon Processor
for running XSLT transformations.
ParserInstantiationException
- if there is a problem instantiating an XML parserFilterConfigurationException
- if any of the Filters used internally by the pipeline cannot be configured correctlyComparatorInstantiationException
- if there is a problem instantiating the underlying comparator used in the pipelineFilterClassInstantiationException
- if any of the Java filters used by the pipeline cannot be instantiatedpublic DocumentComparator(net.sf.saxon.s9api.Processor suppliedProcessor) throws ParserInstantiationException, ComparatorInstantiationException, java.lang.IllegalArgumentException, FilterConfigurationException, FilterClassInstantiationException
Creates a new DocumentComparator. This will use the supplied Saxon Processor
for running XSLT transformations.
suppliedProcessor
- a Saxon Processor
to be used for the NamePool and filter compilationParserInstantiationException
- if there is a problem instantiating an XML parserComparatorInstantiationException
- if there is a problem instantiating the underlying comparator used in the pipelinejava.lang.IllegalArgumentException
- if the supplied Processor
is from a version of Saxon that is not supported by the
DocumentComparator
FilterConfigurationException
- 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 instantiatedpublic void setLexicalPreservationConfig(LexicalPreservationConfig config)
Sets the LexicalPreservationConfig
to use during comparison.
Note that setting the config
value to null
has the same affect as resetting it back to its default
value, DocumentComparator.resetLexicalPreservationConfigToDefault()
.
setLexicalPreservationConfig
in interface CommonComparator
config
- the LexicalPreservationConfig
object to use during comparisonfor details of what the settings are used for
public void resetLexicalPreservationConfigToDefault()
Resets the LexicalPreservationConfig
setting back to the default mode.
public void setCalsTableConfiguration(CalsTableConfiguration config)
Sets the configuration options for CALS table comparison.
config
- a CalsTableConfiguration
object that contains the settings to use for CALS table comparisonpublic void setHtmlTableConfiguration(HtmlTableConfiguration config)
Sets the configuration options for HTML table comparison.
config
- a HtmlTableConfiguration
object that contains the settings to use for HTML table comparisonpublic CalsTableConfiguration getCalsTableConfiguration()
Returns the current configuration options for CALS table comparison.
CalsTableConfiguration
object that contains the settings in use for CALS table comparisonpublic HtmlTableConfiguration getHtmlTableConfiguration()
Returns the current configuration options for HTML table comparison.
HtmlTableConfiguration
object that contains the settings in use for HTML table comparisonpublic void setResultReadabilityOptions(ResultReadabilityOptions options)
Sets the configuration options for making a document result more readable.
options
- a ResultReadabilityOptions
instance that contains the settings to usepublic ResultReadabilityOptions getResultReadabilityOptions()
Returns the current configuration options for result readability.
ResultReadabilityOptions
objects that contains the current settingspublic void setOutputFormatConfiguration(OutputFormatConfiguration config)
Sets the configuration options for the format of the result document.
config
- an OutputFormatConfiguration
instance that contains the settings to usefor more details
public OutputFormatConfiguration getOutputFormatConfiguration()
Returns the current configuration options for the format of the result document.
OutputFormatConfiguration
object that contains the current settingspublic void setMathMLConfig(MathMLConfig config)
Sets the configuration options for the MathML processing.
config
- an MathMLConfig
instance that contains the settings to usefor more details
public MathMLConfig getMathMLConfig()
Returns the current MathML configuration options.
MathMLConfig
instance that contains the current settingspublic void setSVGConfig(SVGConfiguration config)
Sets the configuration options for the SVG comparison.
config
- an SVGConfiguration
instance that contains the settings to usefor more details
public SVGConfiguration getSVGConfig()
Returns the current SVG comparison options.
SVGConfiguration
instance that contains the current settingspublic MoveDetectionConfig getMoveDetectionConfig()
Gets the current Move Detection configuration settings.
MoveDetectionConfig
instance that contains move detection settings.public void setMoveDetectionConfig(MoveDetectionConfig moveDetectionConfig)
Sets the configuration options for Move Detection.
moveDetectionConfig
- a MoveDetectionConfig
that contains the settings to usepublic SubtreeProcessingMode getSubtreeProcessingMode()
Gets the current Subtree Processing Mode setting.
SubtreeProcessingMode
instance that contains subtree processing settings.public void setSubtreeProcessingMode(SubtreeProcessingMode subtreeProcessingMode)
Sets the configuration options for Subtree Processing.
subtreeProcessingMode
- a SubtreeProcessingMode
that contains the settings to usepublic void setCancellationPolicy(CancellationPolicy policy, java.util.Optional<java.lang.Long> timeoutMs)
timeoutMs
- An Optional timeout for use when policy is CancellationPolicy.Timed
. The default is 5 minutespolicy
- The policy which dictates how the timeout will work. The default is CancellationPolicy.Noop
CancellationPolicy
public void cancel()
public void setExtensionPoint(DocumentComparator.ExtensionPoint extensionPoint, FilterChain chain)
Sets the FilterChain
to run at the specified DocumentComparator.ExtensionPoint
.
N.B. the supplied FilterChain
will have its name set to the name of the supplied
DocumentComparator.ExtensionPoint
parameter (i.e. the result of calling DocumentComparator.ExtensionPoint.toString()
).
extensionPoint
- the DocumentComparator.ExtensionPoint
at which to insert the FilterChain
;chain
- the FilterChain
containing the FilterStep
s to insert at the specified extension pointpublic void comparePartial(org.xml.sax.InputSource a, org.xml.sax.InputSource b, javax.xml.transform.stream.StreamResult result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
a
- the first comparison inputb
- the second comparison inputresult
- the location where the pipeline result will be writtenComparisonException
- 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 locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic 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.
setDebugFiles
in interface CommonComparator
debug
- when true intermediate result files are producedDocumentComparator.setDebugFilesPrefix(String)
public java.lang.String getReportDirectory()
Returns the String currently set as the output directory for comparison report.
public void setReportDirectory(java.lang.String reportDirectory)
Sets the String to use for the output directory when generating comparison report.
reportDirectory
- a String representing the output directory to use when generating comparison reportpublic boolean isGenerateComparisonReport()
Returns the whether comparison report is generated or not.
public void setGenerateComparisonReport(boolean generateComparisonReport)
This method used to generate comparison report.
generateComparisonReport
- boolean for comparison report generationpublic void setDebugFilesPrefix(java.lang.String prefix)
setDebugFilesPrefix
in interface CommonComparator
prefix
- The prefix that will be used for debug file names in subsequent compare operationsDocumentComparator.setDebugFiles(boolean)
public void setOutputProperty(net.sf.saxon.s9api.Serializer.Property property, java.lang.String value) throws java.lang.IllegalArgumentException
Configures output formatting and control.
Any properties set here are then passed to the Serializer
used 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.Property
enumeration as follows:
DocumentComparator dc= new DocumentComparartor(); ... dc.setOutputProperty(Serializer.Property.INDENT, "yes");
setOutputProperty
in interface CommonComparator
property
- the property to setvalue
- the new value for the propertyjava.lang.IllegalArgumentException
- if a parameter value is illegal in some waySerializer.setOutputProperty(net.sf.saxon.s9api.Serializer.Property, java.lang.String)
,
Serializer.Property
,
XSLT 2.0 and XQuery 1.0
Serialization, section 5.1.5public void setRedistributionLicenseContent(long[] encodedLicense) throws LicenseException
CommonComparator
DeltaXML Redistribtion or 'OEM' customers should use this method in conjunction with supplied code which is typically compiled and integrated into their own products. The supplied code provides examples of usage. This method is not intended to be used by other types of license/customer.
A LicenseException should always contain a nested exception or cause containing further details of the underlying issue. This will typically be either LicenseContentException or LicenseSecurityException
Note that some of the exceptions thrown here can also be thrown by a compare method.
setRedistributionLicenseContent
in interface CommonComparator
encodedLicense
- a redistribution licenseLicenseException
- if there are any problems with the supplied license or its usepublic void setRedistributionLicenseContent(long[] encodedLicense, com.deltaxml.licensing.LicenseContent parent, java.util.Set<java.lang.String> overrideKeys) throws LicenseException
A LicenseException should always contain a nested exception or cause containing further details of the underlying issue. This will typically be either LicenseContentException or LicenseSecurityException
Note that some of the exceptions thrown here can also be thrown by a compare method.
encodedLicense
- a redistribution licenseparent
- The LicenseContent of the parent licenseoverrideKeys
- Set of VENDOR_STRING keys that will be overridden using the data from the LicenseContentLicenseException
- if there are any problems with the supplied license or its usepublic void clearProgressListeners()
public void addProgressListener(DocumentProgressListener dpl)
dpl
- the progress listener to register.public void removeProgressListener(DocumentProgressListener dpl)
dpl
- the progress listener to remove.public int getNumberOfProgressStages()
CommonComparator
PipelineProgressListener
.getNumberOfProgressStages
in interface CommonComparator
public void setEvaluationVariables(boolean isEval, double obfuscatePercentage)
isEval
- when true restricted results are produced.obfuscatePercentage
- A percentage that will be used to restrict evaluation.public FilterChain getOutputFilterChainPart2()
public FilterStepHelper newFilterStepHelper()
CommonComparator
Creates a FilterStepHelper
using the Processor
and URIResolver
currently in use by this Core S9 API
Comparator.
Due to the way that Saxon's Processor works, all internal XdmNodes and compiled XSLT must be created by the same
Processor
. Therefore FilterChain
s and FilterStep
s that are to be associated with this Core S9 API
Comparator, should be instantiated by this Comparator's FilterStepHelper
, which is what this method provides.
newFilterStepHelper
in interface CommonComparator
FilterStepHelper
with which to create FilterChain
s and FilterStep
s for this
Core S9 API Comparator.public LexicalPreservationConfig getLexicalPreservationConfig()
CommonComparator
Returns the current lexical preservation configuration settings.
getLexicalPreservationConfig
in interface CommonComparator
public org.xml.sax.EntityResolver getEntityResolver()
CommonComparator
getEntityResolver
in interface CommonComparator
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
CommonComparator
setEntityResolver(resolver, true)
.setEntityResolver
in interface CommonComparator
resolver
- the user specified entity resolver.public void setEntityResolver(org.xml.sax.EntityResolver resolver, boolean useFallbackEntityResolver)
CommonComparator
setEntityResolver
in interface CommonComparator
resolver
- the user specified entity resolver.useFallbackEntityResolver
- whether to use the internal catalog support (supplied by the fallback entity resolver).public javax.xml.transform.URIResolver getURIResolver()
CommonComparator
getURIResolver
in interface CommonComparator
public void setURIResolver(javax.xml.transform.URIResolver resolver)
CommonComparator
<xsl:import>
,
<xml:include>
and document()
constructs. This is equivalent to calling
setURIResolver(resolver, true)
.setURIResolver
in interface CommonComparator
resolver
- An implementation of the URIResolver interface, or nullpublic void setURIResolver(javax.xml.transform.URIResolver resolver, boolean useFallbackURIResolver)
CommonComparator
<xsl:import>
, <xsl:include>
and document()
constructs.setURIResolver
in interface CommonComparator
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.XsltTransformer.setURIResolver(javax.xml.transform.URIResolver)
public boolean getParserFeature(java.lang.String featureName) throws FeatureNotRecognizedException, java.lang.IllegalArgumentException
CommonComparator
getParserFeature
in interface CommonComparator
featureName
- the name of the feature whose value is being queriedFeatureNotRecognizedException
- if the featureName is not recognizedjava.lang.IllegalArgumentException
- if the argument is nullCommonComparator.setParserFeature(String, boolean)
public void setParserFeature(java.lang.String featureName, boolean value) throws FeatureSettingNotSupportedException, FeatureNotRecognizedException, java.lang.IllegalArgumentException
CommonComparator
Sets 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
PipelinedComparatorS9 will override these settings. Alternative settings using the CommonComparator.setTransformerConfigurationOption(java.lang.String, java.lang.Object)
method must be used instead:
Parser Feature | Corresponding setTransformerConfigurationOption |
---|---|
http://xml.org/sax/features/validation | Feature.DTD_VALIDATION |
http://apache.org/xml/features/xinclude-aware | Feature.XINCLUDE |
http://apache.org/xml/features/xinclude | Feature.XINCLUDE |
The following list includes some of the features which we consider useful in conjunction with a pipelined comparator architecture:
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
FeatureSettingNotSupportedException
being thrown.
Feature | fixed/permissible value |
---|---|
http://xml.org/sax/features/namespaces | true |
http://xml.org/sax/features/namespace- prefixes | false |
setParserFeature
in interface CommonComparator
featureName
- the name of the feature to be setvalue
- the new value for the featureFeatureSettingNotSupportedException
- if the feature cannot be set to the specific valueFeatureNotRecognizedException
- if the featureName is not recognizedjava.lang.IllegalArgumentException
- if the featureName argument is nullXMLReader.setFeature(String, boolean)
,
Processor.setConfigurationProperty(Feature, Object)
,
Feature
public java.lang.Object getParserProperty(java.lang.String propertyName) throws PropertyNotRecognizedException, java.lang.IllegalArgumentException
CommonComparator
getParserProperty
in interface CommonComparator
propertyName
- the name of the property whose value is being queriedPropertyNotRecognizedException
- if the property name is not recognizedjava.lang.IllegalArgumentException
- if the argument is nullCommonComparator.setParserProperty(String, Object)
public void setParserProperty(java.lang.String propertyName, java.lang.Object value) throws PropertyNotRecognizedException, PropertySettingNotSupportedException, java.lang.IllegalArgumentException
CommonComparator
Configures 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:
setParserProperty
in interface CommonComparator
propertyName
- the name of the property to set on the parservalue
- the new value for the propertyPropertyNotRecognizedException
- if the property name is not recognizedPropertySettingNotSupportedException
- if the property cannot be set to the specific valuejava.lang.IllegalArgumentException
- if an argument is nullCommonComparator.getParserProperty(String)
,
XMLReader.setProperty(java.lang.String, java.lang.Object)
public java.lang.String getOutputProperty(net.sf.saxon.s9api.Serializer.Property property)
CommonComparator
getOutputProperty
in interface CommonComparator
property
- the output property whose value is being queriedSerializer.Property
public java.lang.Object getTransformerConfigurationOption(java.lang.String name) throws java.lang.IllegalArgumentException
CommonComparator
getTransformerConfigurationOption
in interface CommonComparator
name
- of the option to reportjava.lang.IllegalArgumentException
- if the attribute name is not recognized by the underlying TransformerFactoryCommonComparator.setTransformerConfigurationOption(String, Object)
public void setTransformerConfigurationOption(java.lang.String name, java.lang.Object value) throws java.lang.IllegalArgumentException
CommonComparator
Set 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.
setTransformerConfigurationOption
in interface CommonComparator
name
- The name of the option to setvalue
- The value to be set (an Object)java.lang.IllegalArgumentException
- if the attribute name is not recognized by the underlying TransformerCommonComparator.getTransformerConfigurationOption(String)
,
CommonComparator.setParserFeature(String, boolean)
public void compare(java.io.File f1, java.io.File f2, java.io.File result) throws ComparisonException, FilterProcessingException, java.io.FileNotFoundException, java.io.IOException, PipelineLoadingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares File objects and uses a File to represent the result.
compare
in interface CommonComparator
f1
- the first comparison inputf2
- the second inputresult
- the location where the pipeline result will be writtenComparisonException
- if there is a problem during the comparison processingFilterProcessingException
- if there was a problem running any of the filtersjava.io.FileNotFoundException
- if the input or output files cannot be foundjava.io.IOException
- 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 locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(java.io.Reader a, java.lang.String systemIdA, java.io.Reader b, java.lang.String systemIdB, java.io.Writer result) throws ComparisonException, FilterProcessingException, PipelineLoadingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares 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.
compare
in interface CommonComparator
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 writtenComparisonException
- 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 locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(java.io.InputStream a, java.lang.String systemIdA, java.io.InputStream b, java.lang.String systemIdB, java.io.OutputStream result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares 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.
compare
in interface CommonComparator
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 writtenComparisonException
- 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 locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(java.lang.String a, java.lang.String systemIdA, java.lang.String b, java.lang.String systemIdB, java.lang.StringBuilder result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares 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.
compare
in interface CommonComparator
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 writtenComparisonException
- 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 locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(java.net.URL a, java.net.URL b, java.io.File result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, java.io.FileNotFoundException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares the XML obtained from URLs and writes the pipeline result to a File.
compare
in interface CommonComparator
a
- The URL from which the first input is loadedb
- The URL for the second inputresult
- where the pipeline result will be writtenComparisonException
- 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 locationjava.io.FileNotFoundException
- if the output file location cannot be foundLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(java.net.URL a, java.net.URL b, java.io.OutputStream result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares the XML obtained from URLs and writes the pipeline result to an OutputStream.
compare
in interface CommonComparator
a
- The URL from which the first input is loadedb
- The URL for the second inputresult
- where the pipeline result will be writtenComparisonException
- 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 locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(org.xml.sax.InputSource a, org.xml.sax.InputSource b, javax.xml.transform.stream.StreamResult result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares 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.
compare
in interface CommonComparator
a
- The InputSource from which the first input is loadedb
- The InputSource for the second inputresult
- where the pipeline result will be writtenComparisonException
- 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 locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic net.sf.saxon.s9api.XdmNode compare(net.sf.saxon.s9api.XdmNode a, net.sf.saxon.s9api.XdmNode b) throws FilterProcessingException, ComparisonException, LicenseException, java.lang.IllegalArgumentException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares 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.
compare
in interface CommonComparator
a
- The first XdmNode input tree to be comparedb
- The second XdmNode inputFilterProcessingException
- if there is a problem executing the pipeline filtersComparisonException
- if there is a problem during the comparison processingLicenseException
- if there is a licensing issuejava.lang.IllegalArgumentException
- if the XdmNodes were produced by an unknown Saxon ProcessorPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void addLicenseFile(java.io.File licenseFile) throws java.lang.SecurityException, java.io.IOException, LicenseException
CommonComparator
addLicenseFile
in interface CommonComparator
licenseFile
- the FlexLM format license filejava.lang.SecurityException
- if the file cannot be accessedjava.io.IOException
- if there are problems reading the fileLicenseException
- if there is a problem using the license filepublic void addLicenseServer(java.lang.String hostname) throws LicenseException
CommonComparator
addLicenseServer
in interface CommonComparator
hostname
- the license server host or its ip addressLicenseException
- if there is a problem using the license serverpublic void addLicenseServer(java.lang.String hostname, int port) throws java.lang.IllegalArgumentException, LicenseException
CommonComparator
addLicenseServer
in interface CommonComparator
hostname
- the license server host or its ip addressport
- the port number on the license server for the lmgrdjava.lang.IllegalArgumentException
- if the port number is out of rangeLicenseException
- if there is a problem using the license serverpublic void addUsageListener(com.deltaxml.cores9api.common.usage.ComUsageListener ul)
public void removeUsageListener(com.deltaxml.cores9api.common.usage.ComUsageListener ul)
public void setComUsageReporter(boolean isReportingFromExternal, com.deltaxml.cores9api.common.usage.ComUsageReporter reporter, java.util.Map<java.lang.String,com.deltaxml.cores9api.common.usage.ComJobFile> inputJobFiles, java.util.Map<java.lang.String,java.lang.String> configuration)