} else {
prefix = "";
localName = qName;
}
Element element = new Element(null, localName);
if (_locator != null) {
element.setLocation(new Location(_locator));
}
_currentNode.addChild(element);
// Add all current namespaces to this element
for (Iterator i = _prefixes.entrySet().iterator(); i.hasNext(); ) {
Map.Entry me = (Map.Entry) i.next();
element.addNamespace(new Namespace((String)me.getKey(), (String) me.getValue()));
}
// Then add all attributes
if (atts != null && atts.getLength() > 0) {
for (int i = 0; i < atts.getLength(); i++) {
String attName = atts.getQName(i);
String ns = null;
idx = attName.indexOf(':');
if (idx > 0) {
ns = element.getNamespaceURI(attName.substring(0, idx));
attName = attName.substring(idx + 1);
}
element.addAttribute(new Attribute(ns, attName, atts.getValue(i)));
}
}
// Set the namespace on this Element, if one is explicit or defaulted
if (prefix != null && prefix.length() > 0) {
String namespace = element.getNamespaceURI(prefix);
element.setNamespace(namespace);
} else {
String namespace = element.getNamespaceURI("");
if (namespace != null) {
element.setNamespace(namespace);
}
}
_nodeStack.push(element);
_currentNode = element;