// in a DOM created programmatically, this is not necessarily the case. So we need to add
// namespace bindings for the namespace of the element and any attributes
if (node.get_NodeType().Value == XmlNodeType.Element) {
XmlElement elem = (XmlElement)node;
XmlNamedNodeMap atts = elem.get_Attributes();
IntSet codes = new IntHashSet();
NamePool pool = getNamePool();
for (int i = 0; i < atts.get_Count(); i++) {
XmlAttribute att = (XmlAttribute)atts.Item(i);
String attName = att.get_Name();
if (attName.equals("xmlns")) {
String prefix = "";
String uri = att.get_Value();
codes.add(pool.allocateNamespaceCode(prefix, uri));
} else if (attName.startsWith("xmlns:")) {
String prefix = attName.substring(6);
String uri = att.get_Value();
codes.add(pool.allocateNamespaceCode(prefix, uri));
} else if (att.get_NamespaceURI().length() != 0) {
codes.add(pool.allocateNamespaceCode(att.get_Prefix(), att.get_NamespaceURI()));
}
}
if (elem.get_NamespaceURI().length() != 0) {
codes.add(pool.allocateNamespaceCode(elem.get_Prefix(), elem.get_NamespaceURI()));
}
int count = codes.size();
int[] result = new int[count];
int p = 0;
for (IntIterator ii = codes.iterator(); ii.hasNext();) {
result[p++] = ii.next();
}
return result;
} else {
return null;