Code example for Attributes

Methods: getIndex, getLength, getLocalName, getURI, getValue

0
 
                assertSame("ns:default", uri);
                assertEquals("one", qName);
 
                // Check atts. 
                assertEquals(1, atts.getLength());
 
                assertSame("", atts.getURI(0));
                assertSame("a", atts.getLocalName(0));
                assertEquals("b", atts.getValue(0));
                assertEquals(0, atts.getIndex("", "a"));
                assertEquals("b", atts.getValue("", "a"));
 
                return; 
            } 
 
            if (localName == "two") {
                assertEquals(3, prefixMappings.size());
 
                assertTrue(oneStarted);
                assertFalse(twoStarted);
                assertFalse(oneEnded);
                assertFalse(twoEnded);
 
                twoStarted = true;
 
                assertSame("ns:1", uri);
                Assert.assertEquals("n1:two", qName);
 
                // Check atts. 
                assertEquals(2, atts.getLength());
 
                assertSame("", atts.getURI(0));
                assertSame("c", atts.getLocalName(0));
                assertEquals("d", atts.getValue(0));
                assertEquals(0, atts.getIndex("", "c"));
                assertEquals("d", atts.getValue("", "c"));
 
                assertSame("ns:1", atts.getURI(1));
                assertSame("e", atts.getLocalName(1));
                assertEquals("f", atts.getValue(1));
                assertEquals(1, atts.getIndex("ns:1", "e"));
                assertEquals("f", atts.getValue("ns:1", "e"));
 
                // We shouldn't find these. 
                assertEquals(-1, atts.getIndex("ns:default", "e"));
                assertEquals(null, atts.getValue("ns:default", "e"));
 
                return; 
            } 
 
            fail();