parser.setFeature(Parser.defaultAttributesFeature, true);
parser.setContentHandler(x);
InputSource is = new InputSource(in);
is.setEncoding("UTF-8");
parser.parse(is);
XhtmlValidator validator = new XhtmlValidator();
xhtml = w.toString();
bytes = (XHTML_START + xhtml).getBytes("UTF-8");
in = new ByteArrayInputStream(bytes);
validator.isValid(in);
String[] errors = validator.getErrors();
if (errors.length > 0) {
System.out.println(">>>>>");
for (int i = 0; i < errors.length; i++) {
System.out.println(errors[i]);
}