while(xpp.nextToken() != xpp.END_DOCUMENT) {
while(xpp.nextToken() != XmlPullParser.END_DOCUMENT) {
    public void testXmlRoundtrip() throws Exception {        XmlPullParser xpp = factory.newPullParser();        assertEquals(true, xpp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES));        // reset parser        xpp.setInput(null);        // attempt to set roundtrip        try {            xpp.setFeature(FEATURE_XML_ROUNDTRIP, true);        } catch(Exception ex) {        }        // did we succeeded?        boolean roundtripSupported = xpp.getFeature(FEATURE_XML_ROUNDTRIP);        if(!roundtripSupported) {            return;        }        PackageTests.addNote("* optional feature  "+FEATURE_XML_ROUNDTRIP+" is supported\n");        StringWriter sw = new StringWriter();        String s;        //StringWriter st = new StringWriter();        xpp.setInput(new StringReader(MISC_XML));        int[] holderForStartAndLength = new int[2];        char[] buf;        while(xpp.nextToken() != xpp.END_DOCUMENT) {            switch(xpp.getEventType()) {                case XmlPullParser.START_TAG:                    buf = xpp.getTextCharacters(holderForStartAndLength);                    s = new String(buf, holderForStartAndLength[0], holderForStartAndLength[1]);                    assertEquals("roundtrip START_TAG", xpp.getText(), s);                    sw.write(s);                    break;                case XmlPullParser.END_TAG:                    buf = xpp.getTextCharacters(holderForStartAndLength);                    s = new String(buf, holderForStartAndLength[0], holderForStartAndLength[1]);                    assertEquals("roundtrip END_TAG", xpp.getText(), s);                    sw.write(s);                    break;                case XmlPullParser.TEXT:                    buf = xpp.getTextCharacters(holderForStartAndLength);                    s = new String(buf, holderForStartAndLength[0], holderForStartAndLength[1]);                    assertEquals("roundtrip TEXT", xpp.getText(), s);                    sw.write(s);                    break;                case XmlPullParser.IGNORABLE_WHITESPACE:                    buf = xpp.getTextCharacters(holderForStartAndLength);                    s = new String(buf, holderForStartAndLength[0], holderForStartAndLength[1]);                    assertEquals("roundtrip IGNORABLE_WHITESPACE", xpp.getText(), s);                    sw.write(s);                    break;                case XmlPullParser.CDSECT:                    sw.write("<![CDATA[");                    buf = xpp.getTextCharacters(holderForStartAndLength);                    s = new String(buf, holderForStartAndLength[0], holderForStartAndLength[1]);                    assertEquals("roundtrip CDSECT", xpp.getText(), s);                    sw.write(s);                    sw.write("]]>");                    break;                case XmlPullParser.PROCESSING_INSTRUCTION:                    sw.write("<?");                    buf = xpp.getTextCharacters(holderForStartAndLength);                    s = new String(buf, holderForStartAndLength[0], holderForStartAndLength[1]);                    assertEquals("roundtrip PROCESSING_INSTRUCTION", xpp.getText(), s);                    sw.write(s);                    sw.write("?>");                    break;                case XmlPullParser.COMMENT:                    sw.write("<!--");                    buf = xpp.getTextCharacters(holderForStartAndLength);                    s = new String(buf, holderForStartAndLength[0], holderForStartAndLength[1]);                    assertEquals("roundtrip COMMENT", xpp.getText(), s);                    sw.write(s);                    sw.write("-->");                    break;                case XmlPullParser.ENTITY_REF:                    sw.write("&");                    buf = xpp.getTextCharacters(holderForStartAndLength);                    s = new String(buf, holderForStartAndLength[0], holderForStartAndLength[1]);                    assertEquals("roundtrip ENTITY_REF", xpp.getName(), s);                    sw.write(s);                    sw.write(";");                    break;                case XmlPullParser.DOCDECL:                    sw.write("<!DOCTYPE");                    buf = xpp.getTextCharacters(holderForStartAndLength);                    s = new String(buf, holderForStartAndLength[0], holderForStartAndLength[1]);                    assertEquals("roundtrip DOCDECL", xpp.getText(), s);                    sw.write(s);                    sw.write(">");                    break;                default:                    throw new RuntimeException("unknown token type");            }        }        sw.close();        String RESULT_XML_BUF = sw.toString();        assertEquals("rountrip XML", printable(MISC_XML), printable(RESULT_XML_BUF));    }