Class DitaTopicCompare
Compares two Darwin Information Typing Architecture (DITA) topics and produces a result topic marked to show changes.
The input topics are first 'generalized' back to generic topic documents, compared and then 'specialized' back to their original document types. Although the comparison of two different specialized types is not recommended, in such circumstances the result topic is left in its generalized form, unless the force-specialization parameter is set to 'true'.
Changes are marked using 'rev' and 'status' attributes as discussed in the DITA Markup Section of the User Guide.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a progress listener.voidaddLicenseFile(File licenseFile) Adds the license file for use with Flexera licensing.voidaddLicenseServer(String hostname) Adds a license server for use with concurrent licensing.voidaddLicenseServer(String hostname, int port) Adds a license server and port for use with concurrent licensing.voidCompares two File inputs to produce a File result.voidcompare(InputStream is1, String systemId1, InputStream is2, String systemId2, OutputStream result) Compares two input streams to produce an output stream result.voidCompares two input reader (character streams) to produce an output writer result.Compares two XML string inputs to produce an XML string result.voidcompare(InputSource input1, InputSource input2, StreamResult result) Compares two InputSource inputs to produce a StreamResult.Get theAdvancedParametersin use by this DITA comparator.booleanGets whether the production of debug files is on or not.Get the current prefix used for debug result files.Get theDitaConfigin use by this DITA comparator.Gets the explicitly set EntityResolver in use by the comparison.getEntityResolver(boolean builtInResolver) Gets the EntityResolver in use by the comparison.Get theFormattingElementsConfigin use by this DITA comparator.Get theImageConfigurationin use by this DITA comparator.Get theMathMLConfigin use by this DITA comparator.Get theMovesConfigin use by this DITA comparator.Get theOutputParametersin use by this DITA comparator.Get theSVGConfigin use by this DITA comparator.Get theTableConfigin use by this DITA comparator.Get theTextComparisonConfigin use by this DITA comparator.Get theTopicConfigin use by this DITA comparator.Gets the explicitly set URIResolver in use by the comparison.getURIResolver(boolean builtInResolver) Gets the URIResolver in use by the comparison.voidRemove a progress listener.voidsetAdvancedParameters(AdvancedParameters advancedParameters) Set theAdvancedParametersin use by this DITA comparator.voidsetDebugFiles(boolean enableDebug) Determines whether intermediate pipeline result files are generated.voidsetDebugFilesPrefix(String prefix) Provide a prefix for debug result files.voidsetDitaConfig(DitaConfig ditaConfig) Set theDitaConfigin use by this DITA comparator.voidsetEntityResolver(EntityResolver resolver, boolean fallbackToDefaultCatalogResolver) Sets the EntityResolver to use during the comparison.voidsetFormattingElementsConfig(FormattingElementsConfig formattingElementsConfig) Set theFormattingElementsConfigin use by the DITA comparator.voidsetImageConfiguration(ImageConfiguration imageConfiguration) Set theImageConfigurationin use by the DITA comparator.voidsetMathmlConfig(MathMLConfig mathmlConfig) Set theMathMLConfigin use by the DITA comparator.voidsetMovesConfig(MovesConfig movesConfig) Set theMovesConfigin use by the DITA comparator.voidsetOutputParameters(OutputParameters outputParameters) Set theOutputParametersin use by this DITA comparator.voidsetSvgConfig(SVGConfig svgConfig) Set theSVGConfigin use by the DITA comparator.voidsetTableConfig(TableConfig tableConfig) Set theTableConfigin use by the DITA comparator.voidsetTextComparisonConfig(TextComparisonConfig textComparisonConfig) Set theTextComparisonConfigin use by the DITA comparator.voidsetTopicConfig(TopicConfig topicConfig) Set theTopicConfigin use by the DITA comparator.voidsetURIResolver(URIResolver resolver, boolean fallbackToDefaultCatalogResolver) Sets the URIResolver to use during the comparison.
-
Constructor Details
-
DitaTopicCompare
Constructs a new DitaTopicCompare instance.
- Throws:
ParserException- when there is a problem creating/configuring a parser
-
-
Method Details
-
addDitaTopicCompareProgressListener
Add a progress listener. This adds a progress listener to the list of registered progress listeners. The same listener may be added more than once.- Parameters:
listener- the progress listener to add.
-
removeDitaTopicCompareProgressListener
Remove a progress listener. This removes the first occurrence of the progress listener from the registered progress listener list.- Parameters:
listener- the progress listener to remove.
-
compare
public void compare(File input1, File input2, File result) throws com.deltaxml.licensing.LicenseException, ParserException, FileNotFoundException, SerializationException, InputLoadException, FilterException, DifferentRootElementException, InvalidInputException, ComparisonCancelledException Compares two File inputs to produce a File result.
- Parameters:
input1- the first input to compare as a File objectinput2- the second input to compare as a File objectresult- the File in which to write the comparison result- Throws:
com.deltaxml.licensing.LicenseException- when the license cannot be read or is not validParserException- when there is a problem creating/configuring an XML parserFileNotFoundException- when an input File or the location of the result File cannot be foundSerializationException- when there is a problem writing the result FileInputLoadException- when there is a problem loading an input FileFilterException- when an error occurs running a filter in the pipelineDifferentRootElementException- if the two input Files have different rootsInvalidInputException- if an input file is not in the correct formatComparisonCancelledException- if comparison is cancelled via a cancellation policyInvalidParameterException- if a previous parameter setting on the comparator cannot be used at comparison time
-
compare
public void compare(Reader r1, String systemId1, Reader r2, String systemId2, Writer result) throws com.deltaxml.licensing.LicenseException, ParserException, SerializationException, InputLoadException, FilterException, DifferentRootElementException, InvalidInputException, ComparisonCancelledException Compares two input reader (character streams) to produce an output writer result.
- Parameters:
r1- the first input to comparesystemId1- the location of the first input stream (for relative lookup)r2- the second input to comparesystemId2- the location of the second input stream (for relative lookup)result- the writer in which to write the comparison result- Throws:
com.deltaxml.licensing.LicenseException- when the license cannot be read or is not validParserException- when there is a problem creating/configuring an XML parserSerializationException- when there is a problem writing the result FileInputLoadException- when there is a problem loading an input FileFilterException- when an error occurs running a filter in the pipelineDifferentRootElementException- if the two input Files have different rootsInvalidInputException- if an input file is not in the correct formatComparisonCancelledException- if comparison is cancelled via a cancellation policyInvalidParameterException- if a previous parameter setting on the comparator cannot be used at comparison time
-
compare
public void compare(InputStream is1, String systemId1, InputStream is2, String systemId2, OutputStream result) throws com.deltaxml.licensing.LicenseException, ParserException, SerializationException, InputLoadException, FilterException, DifferentRootElementException, InvalidInputException, ComparisonCancelledException Compares two input streams to produce an output stream result.
- Parameters:
is1- the first input to comparesystemId1- the location of the first input stream (for relative lookup)is2- the second input to comparesystemId2- the location of the second input stream (for relative lookup)result- the output stream in which to write the comparison result- Throws:
com.deltaxml.licensing.LicenseException- when the license cannot be read or is not validParserException- when there is a problem creating/configuring an XML parserSerializationException- when there is a problem writing the result FileInputLoadException- when there is a problem loading an input FileFilterException- when an error occurs running a filter in the pipelineDifferentRootElementException- if the two input Files have different rootsInvalidInputException- if an input file is not in the correct formatComparisonCancelledException- if comparison is cancelled via a cancellation policyInvalidParameterException- if a previous parameter setting on the comparator cannot be used at comparison time
-
compare
public String compare(String input1, String systemId1, String input2, String systemId2) throws com.deltaxml.licensing.LicenseException, ParserException, SerializationException, InputLoadException, FilterException, DifferentRootElementException, InvalidInputException, ComparisonCancelledException Compares two XML string inputs to produce an XML string result.
- Parameters:
input1- the first input to compare as a string containing an XML documentsystemId1- the location of the first input (for relative lookup)input2- the second input to compare as a string containing an XML documentsystemId2- the location of the second input (for relative lookup)- Returns:
- the comparison result as a string containing an XML document
- Throws:
com.deltaxml.licensing.LicenseException- when the license cannot be read or is not validParserException- when there is a problem creating/configuring an XML parserSerializationException- when there is a problem writing the result FileInputLoadException- when there is a problem loading an input FileFilterException- when an error occurs running a filter in the pipelineDifferentRootElementException- if the two input Files have different rootsInvalidInputException- if an input file is not in the correct formatComparisonCancelledException- if comparison is cancelled via a cancellation policyInvalidParameterException- if a previous parameter setting on the comparator cannot be used at comparison time
-
compare
public void compare(InputSource input1, InputSource input2, StreamResult result) throws com.deltaxml.licensing.LicenseException, ParserException, SerializationException, InputLoadException, FilterException, DifferentRootElementException, InvalidInputException, ComparisonCancelledException Compares two InputSource inputs to produce a StreamResult.
This is the most general of the compare methods, in the sense that all the other compare methods can (and are) written in terms of it. However, care must be taken to ensure that each InputSource is provided with an appropriate systemId (say via the InputSource's setSystemId method). This system identifier is used as the base-path for locating external resources (such as those provided by xi:includes and external entity references).
Note that the presence of a system id is not checked for as there are at least two plausible use cases where it is not required. First, simple documents that are self contained (i.e. have no external resource references) do not need to set a system Id, though it can still be useful for error reporting. Second, when catalogs are being used to provide access to external resources, then relative document based lookup mechanisms may not be required (as well).
- Parameters:
input1- the first input to compare as a Source objectinput2- the second input to compare as a Source objectresult- the Result to which to write the comparison result- Throws:
com.deltaxml.licensing.LicenseException- when the license cannot be read or is not validParserException- when there is a problem creating/configuring an XML parserSerializationException- when there is a problem writing the result FileInputLoadException- when there is a problem loading an input FileFilterException- when an error occurs running a filter in the pipelineDifferentRootElementException- if the two input Files have different rootsInvalidInputException- if an input file is not in the correct formatComparisonCancelledException- if comparison is cancelled via a cancellation policyInvalidParameterException- if a previous parameter setting on the comparator cannot be used at comparison time
-
setDebugFilesPrefix
Provide a prefix for debug result files.- Parameters:
prefix- The prefix that will be used for debug file names in subsequent compare operations.- See Also:
-
ParameterBase.setDebugFiles(boolean)
-
getDebugFilesPrefix
Get the current prefix used for debug result files.- Returns:
- the current prefix used for debug result files.
- See Also:
-
ParameterBase.setDebugFiles(boolean)
-
getSvgConfig
-
setSvgConfig
Set theSVGConfigin use by the DITA comparator. TheSVGConfigcontains parameters that control how SVG comparison is performed and the output is displayed.- Parameters:
svgConfig- theSVGConfigto use- Throws:
IllegalArgumentException- if passedSVGConfigis null- See Also:
-
getMovesConfig
Get theMovesConfigin use by this DITA comparator. TheMovesConfigcontains parameters that control how and if element moves are shown and how they are represented.- Returns:
- the active
MovesConfigin use by this DITA comparator - See Also:
-
setMovesConfig
Set theMovesConfigin use by the DITA comparator. TheMovesConfigcontains parameters that control how and if element moves are shown and how they are represented.- Parameters:
movesConfig- theMovesConfigto use- Throws:
IllegalArgumentException- if passedMovesConfigis null- See Also:
-
getImageConfiguration
Get theImageConfigurationin use by this DITA comparator. TheImageConfigurationcontains parameters that control how and if referenced image content is compared.- Returns:
- the active
ImageConfigurationin use by this DITA comparator - See Also:
-
setImageConfiguration
Set theImageConfigurationin use by the DITA comparator. TheImageConfigurationcontains parameters that control how and if referenced image content is compared.- Parameters:
imageConfiguration- theImageConfigurationto use- Throws:
IllegalArgumentException- if passedImageConfigurationis null- See Also:
-
getMathmlConfig
Get theMathMLConfigin use by this DITA comparator. TheMathMLConfigcontains parameters that control how and if MathML content is specially handled.- Returns:
- the active
MathMLConfigin use by this DITA comparator - See Also:
-
setMathmlConfig
Set theMathMLConfigin use by the DITA comparator. TheMathMLConfigcontains parameters that control how and if MathML content is specially handled.- Parameters:
mathmlConfig- theMathMLConfigto use- Throws:
IllegalArgumentException- if passedMathMLConfigis null- See Also:
-
getFormattingElementsConfig
Get theFormattingElementsConfigin use by this DITA comparator. TheFormattingElementsConfigcontains parameters that control how formatting elements are defined and compared.- Returns:
- the active
FormattingElementsConfigin use by this DITA comparator - See Also:
-
setFormattingElementsConfig
Set theFormattingElementsConfigin use by the DITA comparator. TheFormattingElementsConfigcontains parameters that control how formatting elements are defined and compared.- Parameters:
formattingElementsConfig- theFormattingElementsConfigto use- Throws:
IllegalArgumentException- if passedFormattingElementsConfigis null- See Also:
-
getTableConfig
Get theTableConfigin use by this DITA comparator. TheTableConfigcontains parameters that control how tables are handled and compared.- Returns:
- the active
TableConfigin use by this DITA comparator - See Also:
-
setTableConfig
Set theTableConfigin use by the DITA comparator. TheTableConfigcontains parameters that control how tables are handled and compared.- Parameters:
tableConfig- theTableConfigto use- Throws:
IllegalArgumentException- if passedTableConfigis null- See Also:
-
getTopicConfig
Get theTopicConfigin use by this DITA comparator. TheTopicConfigcontains topic specific parameters that control how the DITA input documents are compared.- Returns:
- the active
TopicConfigin use by this DITA comparator - See Also:
-
setTopicConfig
Set theTopicConfigin use by the DITA comparator. TheTopicConfigcontains topic specific parameters that control how the DITA input documents are compared.- Parameters:
topicConfig- theTopicConfigto use- Throws:
IllegalArgumentException- if passedTopicConfigis null- See Also:
-
getTextComparisonConfig
Get theTextComparisonConfigin use by this DITA comparator. TheTextComparisonConfigcontains parameters that control how text is compared during the comparison.- Returns:
- the active
TextComparisonConfigin use by this DITA comparator - See Also:
-
setTextComparisonConfig
Set theTextComparisonConfigin use by the DITA comparator. TheTextComparisonConfigcontains parameters that control how text is compared during the comparison.- Parameters:
textComparisonConfig- theTextComparisonConfigto use- Throws:
IllegalArgumentException- if passedTextComparisonConfigis null- See Also:
-
getDitaConfig
Get theDitaConfigin use by this DITA comparator. TheDitaConfigcontains general parameters that control how the DITA input documents are compared.- Returns:
- the active
DitaConfigin use by this DITA comparator - See Also:
-
setDitaConfig
Set theDitaConfigin use by this DITA comparator. TheDitaConfigcontains general parameters that control how the DITA input documents are compared.- Parameters:
ditaConfig- theDitaConfigto use- Throws:
IllegalArgumentException- if passedDitaConfigis null- See Also:
-
getOutputParameters
Get theOutputParametersin use by this DITA comparator. TheOutputParameterscontains parameters that control how the result of the comparison is presented.- Returns:
- the active
OutputParametersin use by this DITA comparator - See Also:
-
setOutputParameters
Set theOutputParametersin use by this DITA comparator. TheOutputParameterscontains parameters that control how the result of the comparison is presented.- Parameters:
outputParameters- theOutputParametersto use- Throws:
IllegalArgumentException- if passedOutputParametersis null- See Also:
-
getAdvancedParameters
Get theAdvancedParametersin use by this DITA comparator. TheAdvancedParametersprovide a finer level of control over the comparison, the output, and error reporting.- Returns:
- the active
AdvancedParametersin use by this DITA comparator - See Also:
-
setAdvancedParameters
Set theAdvancedParametersin use by this DITA comparator. TheAdvancedParametersprovide a finer level of control over the comparison, the output, and error reporting.- Parameters:
advancedParameters- theAdvancedParametersto use- Throws:
IllegalArgumentException- if passedAdvancedParametersis null- See Also:
-
setDebugFiles
public void setDebugFiles(boolean enableDebug) 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.
For topic and mapfile comparisons the directory these files are written to can be controlled with setDebugFilesPrefix(String).
- Parameters:
enableDebug- when true intermediate result files are produced and stored in a directory.
-
getDebugFiles
public boolean getDebugFiles()Gets whether the production of debug files is on or not.
- Returns:
- whether the production of debug files is on or not.
-
getEntityResolver
Gets the explicitly set EntityResolver in use by the comparison.
- Returns:
- the explicitly set EntityResolver in use by the comparison.
-
getEntityResolver
Gets the EntityResolver in use by the comparison.
- Parameters:
builtInResolver- Whether to get the built in resolver (with any explicit enhancement), or just the explicitly set resolver.- Returns:
- the explicitly set EntityResolver in use by the comparison.
-
setEntityResolver
Sets the EntityResolver to use during the comparison.
By default, the Apache Commons Resolver is used as an EntityResolver. If you wish to use a different one, set it up using this method. Note you can turn off the default catalog support by providing a
nullresolver and setting thefallbackToDefaultCatalogResolvertofalse.- Parameters:
resolver- The resolver to use. Using null removes an existing resolver.fallbackToDefaultCatalogResolver- Sets whether to use the inbuilt catalog resolver if the provided resolver fails to resolve the entity.
-
getURIResolver
Gets the explicitly set URIResolver in use by the comparison.
- Returns:
- the explicitly set URIResolver in use by the comparison.
-
getURIResolver
Gets the URIResolver in use by the comparison.
- Parameters:
builtInResolver- Whether to get the built in resolver (with any explicit enhancement), or just the explicitly set resolver.- Returns:
- the explicitly set URIResolver in use by the comparison.
-
setURIResolver
Sets the URIResolver to use during the comparison.
By default, the Apache Commons Resolver is used as an URIResolver. If you wish to use a different one, set it up using this method. Note you can turn off the default catalog support by providing a
nullresolver and setting thefallbackToDefaultCatalogResolvertofalse.- Parameters:
resolver- The resolver to use. Using null removes an existing resolver.fallbackToDefaultCatalogResolver- Sets whether to use the inbuilt catalog resolver if the provided resolver fails to resolve the URI.
-
addLicenseFile
public void addLicenseFile(File licenseFile) throws SecurityException, IOException, com.deltaxml.licensing.LicenseException Adds the license file for use with Flexera licensing. This can be either simple server/named-user license file or a concurrent license file containing the USE_SERVER directive- Parameters:
licenseFile- the FlexLM format license file- Throws:
com.deltaxml.licensing.LicenseException- When there is a problem due to licensing considerations.IOException- When there is a problem related to the license file.SecurityException- When there is a problem related to the license file.
-
addLicenseServer
Adds a license server for use with concurrent licensing.- Parameters:
hostname- of the license server host or its IP address- Throws:
com.deltaxml.licensing.LicenseException- When there is a problem due to licensing considerations.
-
addLicenseServer
public void addLicenseServer(String hostname, int port) throws IllegalArgumentException, com.deltaxml.licensing.LicenseException Adds a license server and port for use with concurrent licensing.- Parameters:
hostname- of the license server host or its IP address.port- the port number on the license server for the 'lmgrd' license server.- Throws:
IllegalArgumentException- if the port number is outside the allowed range.com.deltaxml.licensing.LicenseException- When there is a problem due to licensing considerations.
-