boolean nsEnabled = false;
try { nsEnabled = getNamespaces(); }
catch (SAXException s) {}
String elementName = fStringPool.toString(elementTypeIndex);
AttributeList attrList = xmlAttrList.getAttributeList(attrListIndex);
// Until DOM2 is REC, the DOM2 methods are in XXXImpl
Element e;
if (nsEnabled) {
//System.out.println("createElementNS:"+
//fStringPool.toString(fStringPool.getURIForQName(elementTypeIndex)));
e = (ElementImpl)
((DocumentImpl)fDocument).createElementNS(
fStringPool.toString(fStringPool.getURIForQName(elementTypeIndex)),
fStringPool.toString(elementTypeIndex)
);
} else {
e = fDocument.createElement(elementName);
}
int attrListLength = attrList.getLength();
for (int i = 0; i < attrListLength; i++) {
if (nsEnabled) {
// REVISTNS:
int attName = xmlAttrList.getAttrName(i);
/***
// createAttributeNS code below has a bug.
// Should be interchangeable with setAttributeNS
Attr attr =
((DocumentImpl)fDocument).createAttributeNS(
fStringPool.toString(fStringPool.getURIForQName(attName)),
fStringPool.toString(attName)
);
attr.setNodeValue(attrList.getValue(i));
e.appendChild(attr);
/***/
// setAttributeNS can't set qualified name or prefix.
// Reported to W3C.
((ElementImpl)e).setAttributeNS(
fStringPool.toString(fStringPool.getURIForQName(attName)),
fStringPool.toString(attName),
attrList.getValue(i));
/***/
//DEBUGGING...
//System.out.println(" Attr uri, name, value");
//System.out.println(" "+
// fStringPool.toString(fStringPool.getURIForQName(attName))+", "+
// fStringPool.toString(attName)+", "+
// attrList.getValue(i)
//);
} else {
String attrName = attrList.getName(i);
String attrValue = attrList.getValue(i);
e.setAttribute(attrName, attrValue);
// REVISIT: Does this also apply to namespace attributes? -Ac
if (fDocumentImpl != null && !xmlAttrList.isSpecified(i)) {
((AttrImpl)e.getAttributeNode(attrName)).setSpecified(false);
}