Class NamespaceConfiguration

java.lang.Object
com.deltaxml.core.config.namespaces.NamespaceConfiguration

public class NamespaceConfiguration extends Object
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 Details

    • NamespaceConfiguration

      public NamespaceConfiguration()
      Initialises a new empty NamespaceConfiguration instance with an empty default namespace and no user namespaces defined.
    • NamespaceConfiguration

      public NamespaceConfiguration(String defaultNamespace)
      Initialises a new NamespaceConfiguration instance with a default namespace.
      Parameters:
      defaultNamespace - the user defined default namespace.
      Throws:
      IllegalArgumentException - if any provided default namespace is null.
    • NamespaceConfiguration

      public NamespaceConfiguration(Map<String,String> userNamespaces)
      Initialises a new NamespaceConfiguration with a Map containing prefix and namespace pairs of namespace definitions.
      Parameters:
      userNamespaces - a Map containing prefix and namespace pairs of namespace definitions.
      Throws:
      IllegalArgumentException - if any provided prefix clashes with an internal prefix.
    • NamespaceConfiguration

      public NamespaceConfiguration(String defaultNamespace, Map<String,String> userNamespaces)
      Initialises a new NamespaceConfiguration with the given parameters.
      Parameters:
      defaultNamespace - the user defined default namespace.
      userNamespaces - a Map containing 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

      public Map<String,String> getUserNamespaces()
      Get the Map containing prefix and namespace pairs of namespace definitions.
      Returns:
      a Map containing prefix and namespace pairs of namespace definitions.
    • setUserNamespaces

      public void setUserNamespaces(Map<String,String> userNamespaces)
      Set the Map containing prefix and namespace pairs of namespace definitions.
      Parameters:
      userNamespaces - a Map containing prefix and namespace pairs of namespace definitions.
      Throws:
      IllegalArgumentException - if any provided prefix clashes with an internal prefix.
    • getDefaultNamespace

      public String getDefaultNamespace()
      Get the user defined default namespace.
      Returns:
      the user defined default namespace.
    • setDefaultNamespace

      public void setDefaultNamespace(String defaultNamespace)
      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

      public void addNamespace(String prefix, String uri)
      Insert or override a prefix and namespace pair in the userNamespaces Map.
      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

      public static Set<String> getInternalPrefixes()
      Returns the Set of 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 Set of internal namespace prefixes which cannot be overridden by a user namespace.