use of org.apache.xerces.dom.AttrNSImpl in project exist by eXist-db.
the class DocumentImplTest method checkNamespaces_xerces.
@Test
public void checkNamespaces_xerces() throws IOException, ParserConfigurationException, SAXException {
final Document doc;
try (final InputStream is = new UnsynchronizedByteArrayInputStream(DOC_WITH_NAMESPACES.getBytes(UTF_8))) {
doc = parseXerces(is);
}
final Element elem = doc.getDocumentElement();
final NamedNodeMap attrs = elem.getAttributes();
assertEquals(2, attrs.getLength());
int index = 0;
final Attr attr1 = (Attr) attrs.item(index++);
assertEquals(Node.ATTRIBUTE_NODE, attr1.getNodeType());
assertTrue(attr1 instanceof AttrNSImpl);
assertEquals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, attr1.getNamespaceURI());
assertEquals(null, attr1.getPrefix());
assertEquals(XMLConstants.XMLNS_ATTRIBUTE, attr1.getLocalName());
assertEquals(XMLConstants.XMLNS_ATTRIBUTE, attr1.getNodeName());
assertEquals("http://exist-db.org/xquery/repo", attr1.getValue());
final Attr attr2 = (Attr) attrs.item(index++);
assertEquals(Node.ATTRIBUTE_NODE, attr2.getNodeType());
assertTrue(attr2 instanceof AttrNSImpl);
assertEquals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, attr2.getNamespaceURI());
assertEquals(XMLConstants.XMLNS_ATTRIBUTE, attr2.getPrefix());
assertEquals("repo", attr2.getLocalName());
assertEquals(XMLConstants.XMLNS_ATTRIBUTE + ":repo", attr2.getNodeName());
assertEquals("http://exist-db.org/xquery/repo", attr2.getValue());
}
Aggregations