@Override
    protected void writeAttributes(Attributes atts)
            throws SAXException {
        int len = atts.getLength();
        boolean hasN = false, hasFacs = false, parsed = false;
        int parts = 0;
        ArrayList<Integer> toAdd = new ArrayList<Integer>();

        for (int i = 0; i < len; i++) {
            char ch[] = atts.getValue(i).toCharArray();



            String qName = atts.getQName(i);
            String localName = atts.getLocalName(i);
            if (inAB && localName.equals("id")) {
                localName = "xml:" + localName;
            }

            if (inAB && localName.equals("type")) {
                if (atts.getValue(i).equals("h")) {
                    ch = "head".toCharArray();
                }
            }

            write(' ');
            writeName(atts.getURI(i), localName,
                    qName, false);
            write("=\"");
            writeNonEsc(ch, 0, ch.length, true);
            write('"');
        }

        if (inDiv) {
            if (!hasN) {
                write(' ');
                writeName("", "n", "n", false);
                write("=\"\"");
            }
            if (!hasFacs) {
                write(' ');
                writeName("", "facs", "facs", false);
                write("=\"\"");
            }
        }
    }