checkParserStateNs(xpp, 2, xpp.END_TAG, 2, "uri1", "bar", false, -1);
checkParserStateNs(xpp, 2, XmlPullParser.END_TAG, 2, "uri1", "bar", false, -1);
    public void testMisc() throws Exception {        XmlSerializer ser = factory.newSerializer();        StringWriter sw = new StringWriter();        ser.setOutput(sw);                assertEquals(0, ser.getDepth());        assertEquals(null, ser.getNamespace());        assertEquals(null, ser.getName());                // all comments etc        ser.startDocument(null, Boolean.TRUE);        assertEquals(0, ser.getDepth());        assertEquals(null, ser.getNamespace());        assertEquals(null, ser.getName());                        final String docdecl = " foo [\n"+            "<!ELEMENT foo (#PCDATA|bar)* >\n"+            "<!ELEMENT pbar (#PCDATA) >\n"            +"]";        ser.docdecl(docdecl);        ser.processingInstruction("pi test");        final String iws = "\n\t";        ser.ignorableWhitespace(iws);                assertEquals(0, ser.getDepth());        assertEquals(null, ser.getNamespace());        assertEquals(null, ser.getName());                ser.startTag(null, "foo");        assertEquals(1, ser.getDepth());        assertEquals(null, ser.getNamespace());        assertEquals("foo", ser.getName());                        //check escaping & < > " '        final String attrVal = "attrVal&<>\"''&amp;";        //final String attrVal = "attrVal&;";        ser.attribute(null, "attrName", attrVal);                assertEquals(1, ser.getDepth());        assertEquals(null, ser.getNamespace());        assertEquals("foo", ser.getName());                ser.entityRef("amp");        final String cdsect = "hello<test>\"test";        ser.cdsect(cdsect);                ser.setPrefix("ns1", "usri2");                assertEquals(1, ser.getDepth());        assertEquals(null, ser.getNamespace());        assertEquals("foo", ser.getName());                ser.startTag("uri1", "bar");        assertEquals(2, ser.getDepth());        assertEquals("uri1", ser.getNamespace());        assertEquals("bar", ser.getName());                final String text = "test\n\ntest";        char[] buf = text.toCharArray();        ser.text(buf, 0, buf.length);                final String comment = "comment B- ";        ser.comment(comment);        assertEquals(2, ser.getDepth());        assertEquals("uri1", ser.getNamespace());        assertEquals("bar", ser.getName());                assertEquals(2, ser.getDepth());        assertEquals("uri1", ser.getNamespace());        assertEquals("bar", ser.getName());                        ser.endDocument(); // should close unclosed foo and bar start tag        assertEquals(0, ser.getDepth());        assertEquals(null, ser.getNamespace());        assertEquals(null, ser.getName());                // -- now check that we get back what we serialized ...                String serialized = sw.toString();        //System.out.println(getClass()+" serialized="+serialized);        xpp.setInput(new StringReader(serialized));        xpp.setFeature(xpp.FEATURE_PROCESS_NAMESPACES, true);                checkParserStateNs(xpp, 0, xpp.START_DOCUMENT, null, 0, null, null, null, false, -1);                xpp.nextToken();        checkParserStateNs(xpp, 0, xpp.DOCDECL, null, 0, null, null, false, -1);        String gotDocdecl = xpp.getText();        if(gotDocdecl != null) {            assertEquals(printable(docdecl), printable(gotDocdecl));        }                xpp.nextToken();        checkParserStateNs(xpp, 0, xpp.PROCESSING_INSTRUCTION, null, 0, null, null, "pi test", false, -1);                        xpp.nextToken();        if(xpp.getEventType() == xpp.IGNORABLE_WHITESPACE) {            String expectedIws = gatherTokenText(xpp, xpp.IGNORABLE_WHITESPACE, true);            assertEquals(printable(iws), printable(expectedIws));        }                checkParserStateNs(xpp, 1, xpp.START_TAG, null, 0, "", "foo", null, false, 1);        checkAttribNs(xpp, 0, null, "", "attrName", attrVal);                xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null, "amp", "&", false, -1);                xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.CDSECT, null, 0, null, null, cdsect, false, -1);        assertEquals(false, xpp.isWhitespace());                xpp.nextToken();        checkParserStateNs(xpp, 2, xpp.START_TAG, 2, "uri1", "bar", false, 0);                String gotText = nextTokenGathered(xpp, xpp.TEXT, false);        assertEquals(printable(text), printable(gotText));                //xpp.nextToken();        checkParserStateNs(xpp, 2, xpp.COMMENT, null, 2, null, null, comment, false, -1);                xpp.nextToken();        checkParserStateNs(xpp, 2, xpp.END_TAG, 2, "uri1", "bar", false, -1);                xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.END_TAG, 0, "", "foo", false, -1);            }