Code example for Attributes

Methods: getLength, getLocalName, getQName, getURI

0
            @Override public void startElement(String uri, String localName,
                    String qName, Attributes attributes) {
                assertEquals("", uri);
                assertEquals("", localName);
                assertEquals("a:foo", qName);
                assertEquals(1, attributes.getLength());
                assertEquals("", attributes.getURI(0));
                assertOneOf("a:bar", "", attributes.getLocalName(0));
                assertEquals("a:bar", attributes.getQName(0));
            } 
        }); 
    } 
 
    public void testNoPrefixesYesNamespaces() throws Exception { 
        parse(false, true, "<foo bar=\"baz\"/>", new DefaultHandler() {
            @Override public void startElement(String uri, String localName,
                    String qName, Attributes attributes) {
                assertEquals("", uri);
                assertEquals("foo", localName);
                assertEquals("foo", qName);
                assertEquals(1, attributes.getLength());