List returnList = new ArrayList();
List namespaces = desc.getNonNullNamespaceResolver().getNamespaces();
for (int i = 0; i < namespaces.size(); i++) {
Namespace next = (Namespace)namespaces.get(i);
//if isn't already on a parentadd namespace to this element
// marshalRecord.resolveNamespacePrefix(next.getNamespaceURI());
String prefix = marshalRecord.getNamespaceResolver().resolveNamespaceURI(next.getNamespaceURI());
if ((prefix == null) || prefix.equals("")) {
//if there is no prefix already declared for this uri in the nr add this one
//marshalRecord.attribute(XMLConstants.XMLNS_URL, XMLConstants.XMLNS_URL, XMLConstants.XMLNS + ":" + next.getPrefix(), next.getNamespaceURI());
marshalRecord.getNamespaceResolver().put(next.getPrefix(), next.getNamespaceURI());
returnList.add(next);
} else {
//if prefix is the same do nothing
if (!prefix.equals(next.getPrefix())) {
//if prefix exists for uri but is different then add this
//marshalRecord.attribute(XMLConstants.XMLNS_URL, XMLConstants.XMLNS_URL, XMLConstants.XMLNS + ":" + next.getPrefix(), next.getNamespaceURI());
marshalRecord.getNamespaceResolver().put(next.getPrefix(), next.getNamespaceURI());
returnList.add(next);
}
}
}
return returnList;