本文整理匯總了Java中org.jdom2.Namespace.XML_NAMESPACE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Namespace.XML_NAMESPACE屬性的具體用法?Java Namespace.XML_NAMESPACE怎麽用?Java Namespace.XML_NAMESPACE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.jdom2.Namespace
的用法示例。
在下文中一共展示了Namespace.XML_NAMESPACE屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testXPath
@Test
public void testXPath() {
Element root = new Element("root");
Element title1 = new Element("title");
Element title2 = new Element("title");
Element author = new Element("contributor");
Attribute role = new Attribute("role", "author");
Attribute lang = new Attribute("lang", "de", Namespace.XML_NAMESPACE);
author.setAttribute(role);
author.setAttribute(lang);
root.addContent(title1);
root.addContent(author);
root.addContent(title2);
new Document(root);
assertEquals("/root", MCRXPathBuilder.buildXPath(root));
assertEquals("/root/contributor", MCRXPathBuilder.buildXPath(author));
assertEquals("/root/title", MCRXPathBuilder.buildXPath(title1));
assertEquals("/root/title[2]", MCRXPathBuilder.buildXPath(title2));
assertEquals("/root/contributor/@role", MCRXPathBuilder.buildXPath(role));
assertEquals("/root/contributor/@xml:lang", MCRXPathBuilder.buildXPath(lang));
root.detach();
assertEquals("root", MCRXPathBuilder.buildXPath(root));
assertEquals("root/contributor", MCRXPathBuilder.buildXPath(author));
}