Class NamespaceConfiguration
java.lang.Object
com.deltaxml.core.config.namespaces.NamespaceConfiguration
This class is used to provide a
DocumentComparator with a set of prefix and namespace
pairs that can be used within XPath expressions provided to certain
configurations such as IgnoreChangesConfig or
SubtreeProcessingMode.
Any XML namespace prefixes used within XPath expressions that are provided to other configurations must be defined
via this class.-
Constructor Summary
ConstructorsConstructorDescriptionInitialises a new emptyNamespaceConfigurationinstance with an empty default namespace and no user namespaces defined.NamespaceConfiguration(String defaultNamespace) Initialises a newNamespaceConfigurationinstance with a default namespace.NamespaceConfiguration(String defaultNamespace, Map<String, String> userNamespaces) Initialises a newNamespaceConfigurationwith the given parameters.NamespaceConfiguration(Map<String, String> userNamespaces) Initialises a newNamespaceConfigurationwith aMapcontaining prefix and namespace pairs of namespace definitions. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNamespace(String prefix, String uri) Insert or override a prefix and namespace pair in the userNamespacesMap.Get the user defined default namespace.Returns theSetof internal namespace prefixes which cannot be overridden by a user namespace.Get theMapcontaining prefix and namespace pairs of namespace definitions.voidsetDefaultNamespace(String defaultNamespace) Set the default namespace used by XPath expressions provided to other configurations.voidsetUserNamespaces(Map<String, String> userNamespaces) Set theMapcontaining prefix and namespace pairs of namespace definitions.
-
Constructor Details
-
NamespaceConfiguration
public NamespaceConfiguration()Initialises a new emptyNamespaceConfigurationinstance with an empty default namespace and no user namespaces defined. -
NamespaceConfiguration
Initialises a newNamespaceConfigurationinstance with a default namespace.- Parameters:
defaultNamespace- the user defined default namespace.- Throws:
IllegalArgumentException- if any provided default namespace is null.
-
NamespaceConfiguration
Initialises a newNamespaceConfigurationwith aMapcontaining prefix and namespace pairs of namespace definitions.- Parameters:
userNamespaces- aMapcontaining prefix and namespace pairs of namespace definitions.- Throws:
IllegalArgumentException- if any provided prefix clashes with an internal prefix.
-
NamespaceConfiguration
Initialises a newNamespaceConfigurationwith the given parameters.- Parameters:
defaultNamespace- the user defined default namespace.userNamespaces- aMapcontaining prefix and namespace pairs of namespace definitions.- Throws:
IllegalArgumentException- if any provided prefix clashes with an internal prefix or if provided default namespace is null.
-
-
Method Details
-
getUserNamespaces
Get theMapcontaining prefix and namespace pairs of namespace definitions.- Returns:
- a
Mapcontaining prefix and namespace pairs of namespace definitions.
-
setUserNamespaces
Set theMapcontaining prefix and namespace pairs of namespace definitions.- Parameters:
userNamespaces- aMapcontaining prefix and namespace pairs of namespace definitions.- Throws:
IllegalArgumentException- if any provided prefix clashes with an internal prefix.
-
getDefaultNamespace
Get the user defined default namespace.- Returns:
- the user defined default namespace.
-
setDefaultNamespace
Set the default namespace used by XPath expressions provided to other configurations.- Parameters:
defaultNamespace- the user defined default namespace.- Throws:
IllegalArgumentException- if any provided default namespace is null.
-
addNamespace
Insert or override a prefix and namespace pair in the userNamespacesMap.- Parameters:
prefix- the namespace prefix used in the XPath e.g. "xsd".uri- the namespace associated with the given prefix e.g. "http://www.w3.org/2001/XMLSchema".- Throws:
IllegalArgumentException- if provided prefix clashes with an internal prefix.
-
getInternalPrefixes
Returns theSetof internal namespace prefixes which cannot be overridden by a user namespace. Use this to check which prefixes will be rejected by this class.- Returns:
- the
Setof internal namespace prefixes which cannot be overridden by a user namespace.
-