for (int i = 0; i < NAMESPACES.length; i++) {
Namespace namespace = NAMESPACES[i];
map.put(namespace.getPrefix(), namespace.getURI());
}
// Check using string path.
verifyObjectState(new ODOMXPath(path), path, emptyMap);
verifyObjectState(new ODOMXPath(path, namespacesNull), path, emptyMap);
verifyObjectState(new ODOMXPath(path, NAMESPACES), path, map);
// Check using element.
Element parent = new Element("parent");
String xpath = "/parent/element";
Element element = new Element("element");
parent.addContent(element);
verifyObjectState(new ODOMXPath(element), xpath, emptyMap);
verifyObjectState(new ODOMXPath(element, namespacesNull), xpath, emptyMap);
verifyObjectState(new ODOMXPath(element, NAMESPACES), xpath, map);
// Check using attribute.
xpath = "/parent/@attribute";
parent = new Element("parent");
Attribute attribute = new Attribute("attribute", "");
parent.setAttribute(attribute);
verifyObjectState(new ODOMXPath(attribute), xpath, emptyMap);
verifyObjectState(new ODOMXPath(attribute, namespacesNull), xpath,
emptyMap);
verifyObjectState(new ODOMXPath(attribute, NAMESPACES), xpath, map);
// Check using text.
xpath = "/parent/text()";
parent = new Element("parent");
Text text = new Text("textExample");
parent.addContent(text);
verifyObjectState(new ODOMXPath(text), xpath, emptyMap);
verifyObjectState(new ODOMXPath(text, namespacesNull), xpath, emptyMap);
verifyObjectState(new ODOMXPath(text, NAMESPACES), xpath, map);
// Check using ODOMObservable.
xpath = "/parent/textExample";
parent = new Element("parent");
ODOMObservable node = (ODOMElement) factory.element("textExample");
parent.addContent((Element) node);
verifyObjectState(new ODOMXPath(node), xpath, emptyMap);
verifyObjectState(new ODOMXPath(node, namespacesNull), xpath, emptyMap);
verifyObjectState(new ODOMXPath(node, NAMESPACES), xpath, map);
// Check using element.
xpath = "/parent/element";
parent = new Element("parent");
Element start = new Element("startElement");
element = new Element("element");
parent.addContent(element);
verifyObjectState(new ODOMXPath(start, element), xpath, emptyMap);
verifyObjectState(new ODOMXPath(start, element, namespacesNull), xpath,
emptyMap);
verifyObjectState(new ODOMXPath(start, element, NAMESPACES), xpath, map);
// Check using attribute.
xpath = "/parent/@attribute";
parent = new Element("parent");
start = new Element("startElement");
attribute = new Attribute("attribute", "");
parent.setAttribute(attribute);
verifyObjectState(new ODOMXPath(start, attribute), xpath, emptyMap);
verifyObjectState(new ODOMXPath(start, attribute, namespacesNull), xpath,
emptyMap);
verifyObjectState(new ODOMXPath(start, attribute, NAMESPACES), xpath, map);
// Check using text.
xpath = "/parent/text()";
parent = new Element("parent");
text = new Text("textExample");
parent.addContent(text);
start = new Element("startElement");
verifyObjectState(new ODOMXPath(start, text), xpath, emptyMap);
verifyObjectState(new ODOMXPath(start, text, namespacesNull), xpath,
emptyMap);
verifyObjectState(new ODOMXPath(start, text, NAMESPACES), xpath, map);
// Check using ODOMObservable.
xpath = "/parent/textExample";
parent = new Element("parent");
node = (ODOMElement) factory.element("textExample");
parent.addContent((Element) node);
start = new Element("startElement");
verifyObjectState(new ODOMXPath(start, node), xpath, emptyMap);
verifyObjectState(new ODOMXPath(start, node, namespacesNull), xpath,
emptyMap);
verifyObjectState(new ODOMXPath(start, node, NAMESPACES), xpath, map);
// Check using ODOMObservable.
xpath = "/xpath/to/this/value/isOK";
ODOMXPath testXPath = new ODOMXPath("/xpath/to/this/value");
verifyObjectState(new ODOMXPath(testXPath, "isOK"), xpath, emptyMap);
verifyObjectState(new ODOMXPath(testXPath, "isOK", namespacesNull), xpath,
emptyMap);
verifyObjectState(new ODOMXPath(testXPath, "isOK", NAMESPACES), xpath,
map);
// Check using attribute.
xpath = "/start/element/@attribute";
parent = new Element("parent");
attribute = new Attribute("attribute", "");
parent.setAttribute(attribute);
ODOMXPath startXPath = new ODOMXPath("/start/element");
verifyObjectState(new ODOMXPath(startXPath, attribute), xpath, emptyMap);
verifyObjectState(new ODOMXPath(startXPath, attribute, namespacesNull),
xpath, emptyMap);
verifyObjectState(new ODOMXPath(startXPath, attribute, NAMESPACES), xpath,
map);
// Check using attribute.
xpath = "/start/element/relative/xpath";
parent = new Element("parent");
attribute = new Attribute("attribute", "");
parent.setAttribute(attribute);
startXPath = new ODOMXPath("/start/element");
ODOMXPath relative = new ODOMXPath("relative/xpath");
verifyObjectState(new ODOMXPath(startXPath, relative), xpath, emptyMap);
verifyObjectState(new ODOMXPath(startXPath, relative, namespacesNull),
xpath, emptyMap);
verifyObjectState(new ODOMXPath(startXPath, relative, NAMESPACES), xpath,
map);
}