/** * Add a mapping for a namespaceURI to the specified prefix to the top * frame in the stack. If the prefix is already mapped in that frame, * remap it to the (possibly different) namespaceURI. */ public void add(String namespaceURI, String prefix) { int idx = top; try { // Replace duplicate prefixes (last wins - this could also fault) for (int cursor = top; stack[cursor] != null; cursor--) { if (stack[cursor].getPrefix().equals(prefix)) { stack[cursor].setNamespaceURI(namespaceURI); idx = cursor; return; } } push(); stack[top] = new Mapping(namespaceURI, prefix); idx = top; } finally { // If this is the default namespace, note the new in-scope // default is here. if (prefix.length() == 0) { currentDefaultNS = idx; } } }
namespaceStack.push(); if (pretty) { for (int i = 0; i < indent; i++) {