setUp(source);
// This should cause the creation of a second page with a number
// attribute
ODOMXPath path = new ODOMXPath("catalogue/page[2]/@number");
ODOMObservable newNode = path.create((ODOMElement) root, factory);
assertTrue("New node not an attribute (is a " +
newNode.getClass().getName() + ")",
newNode instanceof Attribute);
assertEquals("Created page attribute path not as",
"/root/catalogue/page[2]/@number",
new ODOMXPath(newNode).getExternalForm());
// This should cause the creation of a new item with nested name
// element
path = new ODOMXPath("catalogue/page[2]/item/name");
newNode = path.create((ODOMElement) root, factory);
assertTrue("New node not an element (is a " +
newNode.getClass().getName() + ")",
newNode instanceof Element);
assertEquals("Created item name element path not as",
"/root/catalogue/page[2]/item/name",
new ODOMXPath(newNode).getExternalForm());
// This should cause the creation of a text node within the previously
// created item's name element
path = new ODOMXPath(path, "text()");
newNode = path.create((ODOMElement) root, factory);
assertTrue("New node not a text (is a " +
newNode.getClass().getName() + ")",
newNode instanceof Text);
assertEquals("Created item name text path not as",
"/root/catalogue/page[2]/item/name/text()",
new ODOMXPath(newNode).getExternalForm());
}