Class DXPConfiguration
Loads a PipelinedComparator from a DXP configuration.
DXP (DeltaXML Pipelines) is a declarative file format for describing comparator pipelines and could also be considered a form of customization language for comparator based tools. It supports DXP file format versions 1.0-2.4 as discussed in DXP User Guide.
This class provides methods for obtaining information from DXP files and also for loading a PipelinedComparatorS9 instance from DXP. The constructor of this class is generally responsible for ensuring validity of the input DXP.
- Since:
- 6.0
- Author:
- Nigel Whitaker, Tristan Mitchell
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a DXPConfigurationS9 object from a DXP file.DXPConfiguration(net.sf.saxon.s9api.XdmNode dxpSource) Creates a DXPConfigurationS9 object from a supplied XdmNode tree.DXPConfiguration(InputSource dxpSource) Creates a DXPConfigurationS9 object from an InputSource.DXPConfiguration(InputSource dxpSource, EntityResolver er, boolean validate) Creates a DXPConfigurationS9 object from a DXP InputSource. -
Method Summary
Modifier and TypeMethodDescriptionfinal PipelinedComparatorgenerate()Generates a PipelinedComparatorS9 from the DXP configuration loaded into this instance of a DXPConfigurationS9.final PipelinedComparatorGenerates a PipelinedComparatorS9 from this instance of a DXPConfigurationS9.final PipelinedComparatorgenerate(Map<String, Boolean> booleanOverrides, Map<String, String> stringOverrides, net.sf.saxon.s9api.Processor proc) Generates a PipelinedComparatorS9 from this instance of a DXPConfigurationS9.Returns the boolean parameters declared in a configuration file.Returns the boolean parameters declared in a configuration file.Returns the contents of the description attribute of a DXP/DCP File.Returns the contents of the DXPoutputFileExtension/@extensionattribute.Returns the contents of the parameter elements as a formatted table.getFormattedParametersDescription(int width, int indent) Returns the contents of the parameter elements as a formatted table.static StringgetFormattedPipelineSummaryTable(Collection<DXPConfiguration> dxpConfigs, int width, int indent) A table summarising the provided pipelines as a multi-line string.Returns the contents of the fullDescription element.getId()Returns the id attribute from a DXP/DCP file.Returns the description of each of the parameters in a configuration file.Returns the parameters declared in a configuration file.Returns the string parameters declared in a configuration file.Returns the String parameters declared in a configuration file.Returns the systemId of the loaded DXP/DCP file.Returns the user specified URIResolver.booleanStates whether this represents a core (XML Compare) pipeline or not.voidsetURIResolver(URIResolver resolver) Specifies the URIResolver to be used with the generated comparator and also during compilation of XSLT scripts.voidsetURIResolver(URIResolver resolver, boolean useFallbackURIResolver) Specifies the URIResolver to be used with the generated comparator and also during compilation of XSLT scripts.toString()Provides a string representation of the configuration based on the systemId of the DXP/DCP file.
-
Constructor Details
-
DXPConfiguration
public DXPConfiguration(File f) throws ParserInstantiationException, FileNotFoundException, net.sf.saxon.s9api.SaxonApiException, InvalidPipelineException Creates a DXPConfigurationS9 object from a DXP file. Once loaded this Object can be queried for information from the DXP configuration and a PipelinedComparatorS9 object can be generated.- Parameters:
f- A File containing a DXP configuration- Throws:
ParserInstantiationException- if there are problems creating the parserFileNotFoundException- if the DXP file cannot be locatednet.sf.saxon.s9api.SaxonApiException- if there are parsing errors or other s9api related problemsInvalidPipelineException- if the DXP contains errors (beyond standard validation errors)- See Also:
-
DXPConfiguration
public DXPConfiguration(InputSource dxpSource, EntityResolver er, boolean validate) throws ParserInstantiationException, net.sf.saxon.s9api.SaxonApiException, InvalidPipelineException Creates a DXPConfigurationS9 object from a DXP InputSource. Once loaded this Object can be queried for information from the DXP configuration and a PipelinedComparatorS9 object can be generated. This method allows the user to control entity resolving and validation associated with the InputSource. Normally validation is strongly recommended and in order to validate a systemId should be associated with the InputSource so that a DTD can be located using relative URLs. Note: Please only consider this method after considering the other DXPConfiguration constructors, as invalid DXP files may produce unpredictable results.- Parameters:
dxpSource- An InputSource describing a DXP configurationer- An EntityResolver for dealing with DTD and other external URL referencesvalidate- controls parser validation (requires uses of a DTD)- Throws:
ParserInstantiationException- if there are problems creating the parsernet.sf.saxon.s9api.SaxonApiException- if there are parsing errors or other s9api related problemsInvalidPipelineException- if the DXP contains errors (beyond standard validation errors)- See Also:
-
DXPConfiguration
public DXPConfiguration(InputSource dxpSource) throws ParserInstantiationException, net.sf.saxon.s9api.SaxonApiException, InvalidPipelineException Creates a DXPConfigurationS9 object from an InputSource. Unlike other constructors there is no option to control entity resolving and validation is always performed. It is recommended that the supplied InputSource should have a systemId set, otherwise validation issues may arise.- Parameters:
dxpSource- An InputSource describing a DXP configuration- Throws:
ParserInstantiationException- if there are problems creating the parsernet.sf.saxon.s9api.SaxonApiException- if there are parsing errors or other s9api related problemsInvalidPipelineException- if the DXP contains errors (beyond standard validation errors)
-
DXPConfiguration
public DXPConfiguration(net.sf.saxon.s9api.XdmNode dxpSource) throws InvalidPipelineException, IllegalArgumentException Creates a DXPConfigurationS9 object from a supplied XdmNode tree. As such a tree will have been parsed there is no opportunity for DTD based validity checking. Users must ensure that the supplied tree is valid.- Parameters:
dxpSource- An XdmNode tree containing a DXP pipeline definition- Throws:
InvalidPipelineException- if the DXP contains errors (beyond standard validation errors)IllegalArgumentException- if the supplied XdmNode is not a DOCUMENT or ELEMENT node
-
-
Method Details
-
generate
public final PipelinedComparator generate(Map<String, Boolean> booleanOverrides, Map<String, throws ClassNotFoundException, MalformedURLException, ParserInstantiationException, FilterClassInstantiationException, FilterConfigurationException, FilterParameterizationException, FeatureNotRecognizedException, FeatureSettingNotSupportedException, PropertyNotRecognizedException, ParameterValueConflict, NonUniqueParameterNameException, UnknownParameterException, ConditionalFilterXPathExceptionString> stringOverrides) Generates a PipelinedComparatorS9 from this instance of a DXPConfigurationS9.
This method allows parameters to be overridden when the pipeline is constructed. The Map arguments should correspond to the declared 'pipelineParameters' in the associated DXP. An easy way to achieve this is to use and modify the Maps returned with
AbstractDPConfiguration.getBooleanParameters()andAbstractDPConfiguration.getStringParameters().This method throws a large number of exceptions. Further details of the circumstances in which they are thrown are documented in the javadoc descriptions of the Exception classes themselves. Should fine-grain exception handling not be required, it is possible to catch the
DeltaXMLExceptionsupertypes for all but two (ClassNotFoundExceptionandMalformedURLException) of the exceptions thrown by this method.- Parameters:
booleanOverrides- parameter settings to override the boolean pipeline parametersstringOverrides- parameter settings to override the string pipeline parameters- Returns:
- a configured PipelineComparatorS9
- Throws:
ClassNotFoundException- if a class specified in a DXP class element cannot be locatedMalformedURLException- if a DXP URL elements contents are malformedParserInstantiationException- if the PipelinedComparatorS9 constructor throws this exceptionFilterClassInstantiationException- if there are problems instantiating a Java class based filterFilterConfigurationException- if there is a problem instantiating or configuring an XSLT based filterFilterParameterizationException- if there are problems setting the parameters on a Java filterFeatureNotRecognizedException- if the feature, in a parserFeature element, is not recognizedFeatureSettingNotSupportedException- if the setting of the specified parser feature is not supportedPropertyNotRecognizedException- if the specified outputProperty is not recognizedParameterValueConflict- if the attributes used to specify a filter or other parameter are in conflictNonUniqueParameterNameException- if the PipelineParameter names are not uniqueUnknownParameterException- if the referenced parameter name is not known/declaredConditionalFilterXPathException- if there is a problem with an XPath expression on a conditional filterXPathFilterParameterException- if there is a problem with an XPath expression being used as a filter parameter
-
generate
public final PipelinedComparator generate(Map<String, Boolean> booleanOverrides, Map<String, throws ClassNotFoundException, MalformedURLException, ParserInstantiationException, FilterClassInstantiationException, FilterConfigurationException, FilterParameterizationException, FeatureNotRecognizedException, FeatureSettingNotSupportedException, PropertyNotRecognizedException, ParameterValueConflict, NonUniqueParameterNameException, UnknownParameterException, IllegalArgumentException, ConditionalFilterXPathExceptionString> stringOverrides, net.sf.saxon.s9api.Processor proc) Generates a PipelinedComparatorS9 from this instance of a DXPConfigurationS9.
This method allows a Saxon s9api Processor to be specified and should be used if you intend to supply XdmNode inputs to the generated PipelinedComparatorS9.
This method allows parameters to be overridden when the pipeline is constructed. The Map arguments should correspond to the declared 'pipelineParameters' in the associated DXP. An easy way to achieve this is to use and modify the Maps returned with
AbstractDPConfiguration.getBooleanParameters()andAbstractDPConfiguration.getStringParameters().This method throws a large number of exceptions. Further details of the circumstances in which they are thrown are documented in the javadoc descriptions of the Exception classes themselves. Should fine-grain exception handling not be required, it is possible to catch the
DeltaXMLExceptionsupertypes for all but two (ClassNotFoundExceptionandMalformedURLException) of the exceptions thrown by this method.- Parameters:
booleanOverrides- parameter settings to override the boolean pipeline parametersstringOverrides- parameter settings to override the string pipeline parametersproc- a Saxon processor to be used for the NamePool and filter compilation- Returns:
- a configured PipelineComparatorS9
- Throws:
ClassNotFoundException- if a class specified in a DXP class element cannot be locatedMalformedURLException- if a DXP URL elements contents are malformedParserInstantiationException- if the PipelinedComparatorS9 constructor throws this exceptionFilterClassInstantiationException- if there are problems instantiating a Java class based filterFilterConfigurationException- if there is a problem instantiating or configuring an XSLT based filterFilterParameterizationException- if there are problems setting the parameters on a Java filterFeatureNotRecognizedException- if the feature, in a parserFeature element, is not recognizedFeatureSettingNotSupportedException- if the setting of the specified parser feature is not supportedPropertyNotRecognizedException- if the specified outputProperty is not recognizedParameterValueConflict- if the attributes used to specify a filter or other parameter are in conflictNonUniqueParameterNameException- if the PipelineParameter names are not uniqueUnknownParameterException- if the referenced parameter name is not known/declaredIllegalArgumentException- if the Processor argument is nullConditionalFilterXPathException- if there is a problem with an XPath expression on a conditional filterXPathFilterParameterException- if there is a problem with an XPath expression being used as a filter parameter
-
isCorePipeline
public boolean isCorePipeline()States whether this represents a core (XML Compare) pipeline or not. As .dxp is a common file extension for core dxp files and sync dxp files, this method provides an easy way of determining if this dxp file represents a core pipeline.- Returns:
- true if this is a comparator pipeline, otherwise false
-
getFileExtension
Returns the contents of the DXPoutputFileExtension/@extensionattribute. This can be used by applications to alter the behaviour of an application based on the type of data generated. For example a pipeline producing HTML, using an extension of "html", may be processed differently (shown in a browser), to a pipeline with an "xml" extension.- Returns:
- the extension attribute, or the default value of "
xml"
-
generate
public final PipelinedComparator generate() throws ClassNotFoundException, MalformedURLException, ParserInstantiationException, FilterClassInstantiationException, FilterConfigurationException, FilterParameterizationException, FeatureNotRecognizedException, FeatureSettingNotSupportedException, PropertyNotRecognizedException, ParameterValueConflict, NonUniqueParameterNameException, UnknownParameterException, ConditionalFilterXPathExceptionGenerates a PipelinedComparatorS9 from the DXP configuration loaded into this instance of a DXPConfigurationS9. This method allows does not allow parameter overriding.
This method throws a large number of exceptions. Further details of the circumstances in which they are thrown are documented in the javadoc descriptions of the Exception classes themselves. Should fine-grain exception handling not be required, it is possible to catch the
DeltaXMLExceptionsupertypes for all but two (ClassNotFoundExceptionandMalformedURLException) of the exceptions thrown by this method.- Returns:
- a configured PipelineComparatorS9
- Throws:
ClassNotFoundException- if a class specified in a DXP class element cannot be locatedMalformedURLException- if a DXP URL elements contents are malformedParserInstantiationException- if the PipelinedComparatorS9 constructor throws this exceptionFilterClassInstantiationException- if there are problems instantiating a Java class based filterFilterConfigurationException- if there is a problem instantiating or configuring an XSLT based filterFilterParameterizationException- if there are problems setting the parameters on a Java filterFeatureNotRecognizedException- if the feature, in a parserFeature element, is not recognizedFeatureSettingNotSupportedException- if the setting of the specified parser feature is not supportedPropertyNotRecognizedException- if the specified outputProperty is not recognizedParameterValueConflict- if the attributes used to specify a filter or other parameter are in conflictNonUniqueParameterNameException- if the PipelineParameter names are not uniqueUnknownParameterException- if the referenced parameter name is not known/declaredConditionalFilterXPathException- if there is a problem with an XPath expression on a conditional filterXPathFilterParameterException- if there is a problem with an XPath expression being used as a filter parameter
-
getFormattedPipelineSummaryTable
public static String getFormattedPipelineSummaryTable(Collection<DXPConfiguration> dxpConfigs, int width, int indent) A table summarising the provided pipelines as a multi-line string. There is a minimum width of 40, any provided width less than 40 is treated as 40.- Parameters:
dxpConfigs- The dxpConfigurations to summarise.width- the maximum width of each line for the description (not including the indent)indent- the number of spaces to prefix each line with.- Returns:
- a table summarising the provided pipeline as a multi-line string.
- Since:
- 6.2
-
getId
Returns the id attribute from a DXP/DCP file. The id attribute is compulsory on a valid DXP or DCP file butnullmay be returned on an invalid file.- Returns:
- the value of the id attribute
-
getSystemId
Returns the systemId of the loaded DXP/DCP file. The value will depend on how the DXP/DCP file was loaded. The following list provides a summary.- Loaded as an
InputSource- returns the result ofInputSource.getSystemId() - Loaded as a
File- returns the result ofFile.toURI().toURL().toExternalForm() - Loaded as an XdmNode - returns the result of
XdmNode.getDocumentURI()
- Returns:
- the SystemId of the loaded DXP/DCP file, null if unknown or cannot be determined
- See Also:
- Loaded as an
-
getDescription
Returns the contents of the description attribute of a DXP/DCP File. This attribute provides a more human friendly description of the pipeline and can be used in command-lines or selection boxes for example.- Returns:
- the contents of description attribute
-
getBooleanParameterList
Returns the boolean parameters declared in a configuration file. This method can be used in UIs and other applications which may wish to display parameter options prior to creating a pipeline instance.- Returns:
- a list of boolean DXP/DCP parameter definitions.
-
getStringParameterList
Returns the string parameters declared in a configuration file. This method can be used in UIs and other applications which may wish to display parameter options prior to creating a pipeline instance.- Returns:
- a list of string DXP/DCP parameter definitions.
-
getParameterList
Returns the parameters declared in a configuration file. This method can be used in UIs and other applications which may wish to display parameter options prior to creating a pipeline instance.- Returns:
- a list of DXP/DCP parameter definitions.
-
getBooleanParameters
Returns the boolean parameters declared in a configuration file. This method can be used in UIs and other applications which may wish to display parameter options prior to creating a pipeline instance. For example it is possible to obtain the Map provided by this method and then pass the Map, possibly modified, as an argument to the applicablegenerate(Map, Map)orDCPConfiguration.generate(Map, Map)method.- Returns:
- a Map describing the boolean parameters and their default values
- See Also:
-
generate(Map, Map)DCPConfiguration.generate(Map, Map)AbstractDPConfiguration.getStringParameters()
-
getParameterDescriptions
Returns the description of each of the parameters in a configuration file. This method can be used in UIs and other applications which may wish to display parameters prior to creating a pipeline instance.- Returns:
- a Map containing each of the parameters by name along with a textual description
-
getStringParameters
Returns the String parameters declared in a configuration file. This method can be used in UIs and other applications which may wish to display parameter options prior to creating a pipeline instance. For example, it is possible to obtain the Map provided by this method and then pass the Map, possibly modified, as an argument to the applicablegenerate(Map, Map)orDCPConfiguration.generate(Map, Map)method.- Returns:
- a Map describing the string parameters and their default values
- See Also:
-
generate(Map, Map)DCPConfiguration.generate(Map, Map)AbstractDPConfiguration.getBooleanParameters()
-
getFullDescription
Returns the contents of the fullDescription element.- Returns:
- the contents of the description element or an empty String.
-
getFormattedParametersDescription
Returns the contents of the parameter elements as a formatted table. This can be used to provide multi-line information to the user about the pipeline's parameters.- Returns:
- the contents of the description and parameter elements or an empty String.
-
getFormattedParametersDescription
Returns the contents of the parameter elements as a formatted table. This can be used to provide multi-line information to the user about the pipeline's parameters.- Parameters:
width- the maximum width of each line for the description (not including the indent)indent- the number of spaces to prefix each line with.- Returns:
- the contents of the description and parameter elements or an empty String.
-
setURIResolver
Specifies the URIResolver to be used with the generated comparator and also during compilation of XSLT scripts. A URIResolver used in this way is useful when resolving files referenced by
<xsl:import>,<xsl:include>anddocument()- 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.
-
setURIResolver
Specifies the URIResolver to be used with the generated comparator and also during compilation of XSLT scripts. A URIResolver used in this way is useful when resolving files referenced by
<xsl:import>,<xsl:include>anddocument()This method is equivalent to calling
setURIResolver(resolver, true).- Parameters:
resolver- An implementation of the URIResolver interface, or null
-
getURIResolver
Returns the user specified URIResolver.- Returns:
- the resolver that was last set using one of the setURIResolver methods.
-
toString
Provides a string representation of the configuration based on the systemId of the DXP/DCP file.
-