throws DOMException
{
AttributeSet retval = new AttributeSet();
int len = source.getLength();
AttributesEx ex = null;
retval.list = new Vector(len);
if (source instanceof AttributesEx) {
ex = (AttributesEx) source;
}
for (int i = 0; i < len; i++) {
// Process the namespaceURI according to DOM Level 2 spec
String uri;
String qName = source.getQName(i);
if ("xmlns".equals(qName)
|| "xmlns".equals(XmlNames.getPrefix(qName))) {
// Associate the right namespaceURI with "xmlns" attributes
uri = XmlNames.SPEC_XMLNS_URI;
} else {
uri = source.getURI(i);
// Translate "" of SAX2 to null. See DOM2 spec under Node
// namespaceURI
if ("".equals(uri)) {
uri = null;
}
}
AttributeNode attrNode =
new AttributeNode(uri, qName,
source.getValue(i),
ex == null // remember if it was specified
? true
: ex.isSpecified(i),
ex == null // remember any default value
? null
: ex.getDefault(i));
retval.list.addElement(attrNode);
}
return retval;
}