Package org.xmlunit.diff
Class XPathContext
- java.lang.Object
-
- org.xmlunit.diff.XPathContext
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXPathContext.DOMNodeInfoDOM based implementation ofXPathContext.NodeInfo.static interfaceXPathContext.NodeInfoRepresentation of a node used byXPathContext.
-
Constructor Summary
Constructors Constructor Description XPathContext()Starts 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.XPathContextclone()Creates a deep copy of this XPathContext.StringgetParentXPath()Stringifies the XPath of the current node's parent.StringgetXPath()Stringifies the XPath of the current node.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.voidnavigateToParent()Moves back to the parent.voidsetChildren(Iterable<? extends XPathContext.NodeInfo> children)Adds knowledge about the current node's children replacing existing knowledge.
-
-
-
Constructor Detail
-
XPathContext
public XPathContext()
Starts with an empty context.
-
XPathContext
public XPathContext(Node root)
Starts with the context of a root node.- Parameters:
root- the root node
-
XPathContext
public XPathContext(Map<String,String> prefix2uri)
Starts with an empty context and a given namespace mapping.- Parameters:
prefix2uri- maps from prefix to namespace URI.
-
-
Method Detail
-
navigateToChild
public void navigateToChild(int index)
Moves from the current node to the given child node.- Parameters:
index- index of child to navigate to
-
navigateToAttribute
public void navigateToAttribute(QName attribute)
Moves from the current node to the given attribute.- Parameters:
attribute- name of attribute to navigate to
-
navigateToParent
public void navigateToParent()
Moves back to the parent.
-
addAttributes
public void addAttributes(Iterable<? extends QName> attributes)
Adds knowledge about the current node's attributes.- Parameters:
attributes- attributes to add
-
addAttribute
public void addAttribute(QName attribute)
Adds knowledge about a single attribute of the current node.- Parameters:
attribute- attribute to add
-
setChildren
public void setChildren(Iterable<? extends XPathContext.NodeInfo> children)
Adds knowledge about the current node's children replacing existing knowledge.- Parameters:
children- children to add
-
appendChildren
public void appendChildren(Iterable<? extends XPathContext.NodeInfo> children)
Adds knowledge about the current node's children appending to the knowledge already present.- Parameters:
children- children to add
-
getXPath
public String getXPath()
Stringifies the XPath of the current node.- Returns:
- current XPath
-
getParentXPath
public String getParentXPath()
Stringifies the XPath of the current node's parent.- Returns:
- parent's XPath
-
clone
public XPathContext clone()
Creates a deep copy of this XPathContext.
-
-