try {
String xhtml = XHTML_START + badHTMLSnippet + XHTML_END;
bytes = xhtml.getBytes("UTF-8");
InputStream in = new ByteArrayInputStream(bytes);
Parser parser = new Parser();
HTMLSchema schema = new HTMLSchema();
parser.setProperty(Parser.schemaProperty, schema);
Writer w = new StringWriter();
XMLWriter x = new XMLWriter(w);
x.setOutputProperty(XMLWriter.METHOD, "xml");
x.setOutputProperty(XMLWriter.OMIT_XML_DECLARATION, "yes");
x.setPrefix(schema.getURI(), "");
parser.setFeature(Parser.namespacesFeature, false);
parser.setFeature(Parser.defaultAttributesFeature, true);
parser.setContentHandler(x);