Package org.xmlunit.diff
Class XPathContext
java.lang.Object
org.xmlunit.diff.XPathContext
- All Implemented Interfaces:
Cloneable
Helper class that keeps track of the XPath of matched nodes during
comparison.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classDOM based implementation ofXPathContext.NodeInfo.private static classstatic interfaceRepresentation of a node used byXPathContext. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStarts with an empty context.XPathContext(Map<String, String> prefix2uri) Starts with an empty context and a given namespace mapping.XPathContext(Map<String, String> prefix2uri, Node root) Starts with the context of an optional root node and an optional namespace mapping.XPathContext(Node root) Starts with the context of a root node. -
Method Summary
Modifier and TypeMethodDescriptionprivate static intadd1OrIncrement(String name, Map<String, Integer> map) Increments the value name maps to or adds 1 as value if name isn't present inside the map.voidaddAttribute(QName attribute) Adds knowledge about a single attribute of the current node.voidaddAttributes(Iterable<? extends QName> attributes) Adds knowledge about the current node's attributes.voidappendChildren(Iterable<? extends XPathContext.NodeInfo> children) Adds knowledge about the current node's children appending to the knowledge already present.clone()Creates a deep copy of this XPathContext.private StringStringifies the XPath of the current node's parent.getXPath()Stringifies the XPath of the current node.private StringgetXPath(Iterator<XPathContext.Level> dIterator) voidnavigateToAttribute(QName attribute) Moves from the current node to the given attribute.voidnavigateToChild(int index) Moves from the current node to the given child node.voidMoves back to the parent.voidsetChildren(Iterable<? extends XPathContext.NodeInfo> children) Adds knowledge about the current node's children replacing existing knowledge.
-
Field Details
-
path
-
uri2Prefix
-
COMMENT
- See Also:
-
PI
- See Also:
-
TEXT
- See Also:
-
OPEN
- See Also:
-
CLOSE
- See Also:
-
SEP
- See Also:
-
ATTR
- See Also:
-
EMPTY
- See Also:
-
-
Constructor Details
-
XPathContext
public XPathContext()Starts with an empty context. -
XPathContext
Starts with the context of a root node. -
XPathContext
Starts with an empty context and a given namespace mapping.- Parameters:
prefix2uri- maps from prefix to namespace URI.
-
XPathContext
Starts with the context of an optional root node and an optional namespace mapping.- Parameters:
prefix2uri- maps from prefix to namespace URI.root- optional root node that determines the initial XPath
-
-
Method Details
-
addAttributes
Adds knowledge about the current node's attributes. -
addAttribute
Adds knowledge about a single attribute of the current node. -
setChildren
Adds knowledge about the current node's children replacing existing knowledge. -
appendChildren
Adds knowledge about the current node's children appending to the knowledge already present. -
getXPath
Stringifies the XPath of the current node. -
getParentXPath
Stringifies the XPath of the current node's parent. -
clone
Creates a deep copy of this XPathContext. -
getXPath
-
getName
-
add1OrIncrement
Increments the value name maps to or adds 1 as value if name isn't present inside the map.- Returns:
- the new mapping for name
-
invert