XMLReader parser = parserfactory.newSAXParser().getXMLReader();
SAXTransformerFactory serializerfactory =
(SAXTransformerFactory)SAXTransformerFactory.newInstance();
TransformerHandler handler = serializerfactory.newTransformerHandler();
DOMResult result = new DOMResult();
handler.setResult(result);
parser.setContentHandler(new WhitespaceFilter(handler));
InputSource inputsource = new InputSource(in);
inputsource.setSystemId(filename);
parser.parse(inputsource);
return (Document)result.getNode();
}