private byte[] getXML(InputStream in, boolean includeXMLDeclaration) throws GeneralException {
// parse with xerces and re-serialize the fixed xml to a byte array
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputFormat fmt = new OutputFormat("XML", "UTF-8", true);
fmt.setIndent(2);
fmt.setLineWidth(120);
fmt.setPreserveSpace(false);
fmt.setOmitXMLDeclaration(!includeXMLDeclaration);
fmt.setOmitDocumentType(true);
XMLSerializer ser = new XMLSerializer(out, fmt);
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();