void (Element element) { // how many times do you add more than 8 namespaces in one go... // we can add more if we need to... final List<Namespace> toadd = new ArrayList<>(8); final Namespace mns = element.getNamespace(); // check to see whether the Namespace is new-to-scope. Namespace[] newscope = checkNamespace(toadd, mns, scope[depth]); if (element.hasAdditionalNamespaces()) { for (final Namespace ns : element.getAdditionalNamespaces()) { if (ns == mns) { continue; } // check to see whether the Namespace is new-to-scope. newscope = checkNamespace(toadd, ns, newscope); } } if (element.hasAttributes()) { for (final Attribute a : element.getAttributes()) { final Namespace ns = a.getNamespace(); if (ns == Namespace.NO_NAMESPACE) { // Attributes are allowed to be in the NO_NAMESPACE without // changing the in-scope set of the Element.... special-case continue; } if (ns == mns) { continue; } // check to see whether the Namespace is new-to-scope. newscope = checkNamespace(toadd, ns, newscope); } } pushStack(mns, newscope, toadd); }