**/
private AttributeSet processAttributeList(AttributeList atts)
throws SAXException
{
if (atts == null) return new AttributeSetImpl(0);
//-- process all namespaces first
int attCount = 0;
boolean[] validAtts = new boolean[atts.getLength()];
for (int i = 0; i < validAtts.length; i++) {
String attName = atts.getName(i);
if (attName.equals(XMLNS)) {
_namespaces.addNamespace("", atts.getValue(i));
}
else if (attName.startsWith(XMLNS_PREFIX)) {
String prefix = attName.substring(XMLNS_PREFIX.length());
_namespaces.addNamespace(prefix, atts.getValue(i));
}
else {
validAtts[i] = true;
++attCount;
}
}
//-- process validAtts...if any exist
AttributeSetImpl attSet = null;
if (attCount > 0) {
attSet = new AttributeSetImpl(attCount);
for (int i = 0; i < validAtts.length; i++) {
if (!validAtts[i]) continue;
String namespace = null;
String attName = atts.getName(i);
int idx = attName.indexOf(':');
if (idx > 0) {
String prefix = attName.substring(0, idx);
if (!prefix.equals(XML_PREFIX)) {
attName = attName.substring(idx+1);
namespace = _namespaces.getNamespaceURI(prefix);
if (namespace == null) {
String error = "The namespace associated with "+
"the prefix '" + prefix +
"' could not be resolved.";
throw new SAXException(error);
}
}
}
attSet.setAttribute(attName, atts.getValue(i), namespace);
}
}
else attSet = new AttributeSetImpl(0);
return attSet;
} //-- method: processAttributeList