OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML));
serializer.setWriter(out);
ContentHandler contentHandler = serializer.asContentHandler();
TreeWalker walker = new TreeWalker(contentHandler);
try {
contentHandler.startDocument();
for (Node node : headEvents) {
walker.traverseFragment(node);
}
contentHandler.endDocument();
} catch (SAXException e) {