use of org.exist.dom.NamedNodeMapImpl in project exist by eXist-db.
the class ElementImpl method getAttributes.
@Override
public NamedNodeMap getAttributes() {
final NamedNodeMapImpl map = new NamedNodeMapImpl(document, true);
int attr = document.alpha[nodeNumber];
if (-1 < attr) {
while (attr < document.nextAttr && document.attrParent[attr] == nodeNumber) {
map.setNamedItem(new AttrImpl(document, attr));
++attr;
}
}
// add namespace declarations attached to this element
int ns = document.alphaLen[nodeNumber];
if (ns < 0) {
return (map);
}
while (ns < document.nextNamespace && document.namespaceParent[ns] == nodeNumber) {
final NamespaceNode node = new NamespaceNode(document, ns);
map.setNamedItem(node);
++ns;
}
return map;
}
use of org.exist.dom.NamedNodeMapImpl in project exist by eXist-db.
the class ElementImpl method getAttributes.
@Override
public NamedNodeMap getAttributes() {
final org.exist.dom.NamedNodeMapImpl map = new NamedNodeMapImpl(ownerDocument, true);
if (hasAttributes()) {
try (final DBBroker broker = ownerDocument.getBrokerPool().getBroker();
final INodeIterator iterator = broker.getNodeIterator(this)) {
// skip self
iterator.next();
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final IStoredNode next = iterator.next();
if (next.getNodeType() != Node.ATTRIBUTE_NODE) {
break;
}
map.setNamedItem(next);
}
} catch (final EXistException | IOException e) {
LOG.warn("Exception while retrieving attributes: {}", e.getMessage());
}
}
if (declaresNamespacePrefixes()) {
for (final Map.Entry<String, String> entry : namespaceMappings.entrySet()) {
final String prefix = entry.getKey();
final String ns = entry.getValue();
final QName attrName = new QName(prefix, Namespaces.XMLNS_NS, XMLConstants.XMLNS_ATTRIBUTE);
final AttrImpl attr = new AttrImpl(attrName, ns, null);
attr.setOwnerDocument(ownerDocument);
map.setNamedItem(attr);
}
}
return map;
}
Aggregations