// get the object XML as it exists in the repository's
// persitent storage area.
byte[] bytes = TypeUtility.convertDataHandlerToBytes(apim.getObjectXML(pid));
try {
// use xerces to pretty print the xml, assuming it's well formed
OutputFormat fmt = new OutputFormat("XML", "UTF-8", true);
fmt.setIndent(2);
fmt.setLineWidth(120);
fmt.setPreserveSpace(false);
XMLSerializer ser = new XMLSerializer(outStream, fmt);
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();