@Override
    public void startElement(String uri, String localName, String qName,
            Attributes atts) throws SAXException {
        try {
            printLead();
            writer.write('<');
            if ("http://www.w3.org/1998/Math/MathML" == uri) {
                writer.write("math ");                
            } else if ("http://www.w3.org/2000/svg" == uri) {
                writer.write("svg ");                                
            } else if ("http://www.w3.org/1999/xhtml" != uri) {
                writer.write("otherns ");                                
            }
            writer.write(localName);
            writer.write(">\n");
            level++;
            if ("http://www.w3.org/1999/xhtml" == uri
                    && "template".equals(localName)) {
                printLead();
                writer.write("content\n");
                level++;
            }

            TreeMap<String, String> map = new TreeMap<>();
            for (int i = 0; i < atts.getLength(); i++) {
                String ns = atts.getURI(i);
                String name;
                if ("http://www.w3.org/1999/xlink" == ns) {
                    name = "xlink " + atts.getLocalName(i);
                } else if ("http://www.w3.org/XML/1998/namespace" == ns) {
                    name = "xml " + atts.getLocalName(i);                    
                } else if ("http://www.w3.org/2000/xmlns/" == ns) {
                    name = "xmlns " + atts.getLocalName(i);                    
                } else if ("" != uri) {
                    name = atts.getLocalName(i);                    
                } else {
                    name = "otherns " + atts.getLocalName(i);                    
                }
                map.put(name, atts.getValue(i));
            }
            for (Map.Entry<String, String> entry : map.entrySet()) {
                printLead();
                writer.write(entry.getKey());
                writer.write("=\"");
                writer.write(entry.getValue());
                writer.write("\"\n");
            }
        } catch (IOException e) {
            throw new SAXException(e);
        }
    }
@see org.xml.sax.ContentHandler#characters(char[], int, int)
src/nu/validator/servlet/TreeDumpContentHandler.java