@Override
    public void startElement(String uri, String localName, String qName, Attributes attributes)
            throws SAXException {
        super.startElement(uri, localName, qName, attributes);

        if ("img".equals(localName) && attributes.getValue("alt") != null) {
            String nfo = "[image: " + attributes.getValue("alt") + ']';

            characters(nfo.toCharArray(), 0, nfo.length());
        }

        if ("a".equals(localName) && attributes.getValue("name") != null) {
            String nfo = "[bookmark: " + attributes.getValue("name") + ']';

            characters(nfo.toCharArray(), 0, nfo.length());
        }
    }
@Test
    public void aTagTest() throws Exception {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();

        XHTMLContentHandler xhtml = new XHTMLContentHandler(new RichTextContentHandler(
                new OutputStreamWriter(buffer, UTF_8)), new Metadata());
        xhtml.startDocument();
        AttributesImpl attributes = new AttributesImpl();
        attributes.addAttribute("", "", "name", "", "value");
        xhtml.startElement("a", attributes);
        xhtml.endDocument();

        assertEquals("\n\n\n\n[bookmark: value]", buffer.toString(UTF_8.name()));
    }