Enum Class EqualToXmlPattern.NamespaceAwareness
- All Implemented Interfaces:
Serializable,Comparable<EqualToXmlPattern.NamespaceAwareness>,Constable
- Enclosing class:
- EqualToXmlPattern
LEGACY represents the old way that namespaces were treated. This
had a lot of unpredictability and some behaviours were more of a side effect of other
implementation details, rather than intentional. A key detail is that the original DocumentBuilderFactory was not namespace aware, but the XSLT transform performed by DiffBuilder.ignoreComments() seems to return a document that is semi-namespace aware, so some
namespace aware functionality was available. Now DiffBuilder.ignoreComments() has been
replaced by setting the DocumentBuilderFactory to ignore comment on read (much more
performant and predictable), so is only used to produce the legacy namespace aware behaviour.
STRICT and NONE represent firmer, more
intentional behaviour around how namespaces are handled. The details of how each option behaves
are documented below:
LEGACY behaviour:
- Namespace prefixes do not need to be bound to a namespace URI.
- Element namespace prefixes (and their corresponding namespace URIs) are ignored (e.g.
`<th:thing>Match this</th:thing>` == `<st:thing>Match this</st:thing>`)
- Element prefixes seem to effectively be totally removed from the document by the
XSLT transform performed by
DiffBuilder.ignoreComments()(and no namespace URI is assigned to the element).
- Element prefixes seem to effectively be totally removed from the document by the
XSLT transform performed by
- Attributes are compared by their full name (i.e. namespace prefixes are NOT ignored)
(e.g. `<thing th:attr="abc">Match this</thing>` != `<thing st:attr="abc">Match
this</thing>`)
- The XSLT transform performed by
DiffBuilder.ignoreComments()does not assign a namespace URI to attributes, so XMLUnit uses the attribute's full name.
- The XSLT transform performed by
- xmlns namespaced attributes are ignored (e.g. `<thing
xmlns:th="https://thing.com">Match this</thing>` == `<thing
xmlns:st="https://stuff.com">Match this</thing>`)
- XMLUnit ignores all attributes namespaced to http://www.w3.org/2000/xmlns/, which
all xmlns prefixed attributes are assigned to by the XSLT transform performed by
DiffBuilder.ignoreComments().
- XMLUnit ignores all attributes namespaced to http://www.w3.org/2000/xmlns/, which
all xmlns prefixed attributes are assigned to by the XSLT transform performed by
- Element default namespace attributes (i.e. `xmlns` attributes) are NOT ignored unless
NAMESPACE_URI comparison type is explicitly excluded (e.g. `<thing
xmlns="https://thing.com">Match this</thing>` != `<thing
xmlns="https://stuff.com">Match this</thing>`)
- Like xmlns namespaced attributes, XMLUnit ignores all attributes namespaced to
http://www.w3.org/2000/xmlns/, which all xmlns attributes are assigned to by the
XSLT transform performed by
DiffBuilder.ignoreComments(). - The difference between default xmlns attributes and xmlns prefixed
attributes is that the XSLT transform performed by
DiffBuilder.ignoreComments()assigns the namespace URI of default xmlns attributes to the attributed element, which is why matching will fail (unless NAMESPACE_URI comparison type is explicitly excluded).
- Like xmlns namespaced attributes, XMLUnit ignores all attributes namespaced to
http://www.w3.org/2000/xmlns/, which all xmlns attributes are assigned to by the
XSLT transform performed by
STRICT behaviour:
- Namespace prefixes need to be bound to a namespace URI.
- Element and attribute namespace URIs are compared, but their prefixes are ignored.
- Namespace URIs can be explicitly excluded. Although, due to how XMLUnit's engine is implemented, excluding NAMESPACE_URI does not work with attributes (see XMLUnit issue).
- The namespaces defined by xmlns namespaced attributes are compared, but the attributes
themselves are ignored (e.g. `<thing xmlns:th="https://thing.com">Match
this</thing>` == `<thing xmlns:st="https://stuff.com">Match this</thing>`)
- XMLUnit ignores all attributes namespaced to http://www.w3.org/2000/xmlns/, which all default and prefixed xmlns attributes are assigned to by when the document builder factory is namespace aware.
NONE behaviour:
- Namespace prefixes do not need to be bound to a namespace URI.
- Element and attribute are compared by their full name and all namespace URIs are ignored.
- xmlns attributes are not ignored and are treated like any other attribute.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionReturns the enum constant of this class with the specified name.static EqualToXmlPattern.NamespaceAwareness[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
STRICT
-
LEGACY
-
NONE
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-