serializer.output(result.getFitsXml(), out);
}
public static void outputStandardSchemaXml(FitsOutput fitsOutput, OutputStream out) throws XMLStreamException, IOException {
XmlContent xml = fitsOutput.getStandardXmlContent();
//create an xml output factory
Transformer transformer = null;
//initialize transformer for pretty print xslt
TransformerFactory tFactory = TransformerFactory.newInstance ();
String prettyPrintXslt = FITS_XML+"prettyprint.xslt";
try {
Templates template = tFactory.newTemplates(new StreamSource(prettyPrintXslt));
transformer = template.newTransformer();
}
catch(Exception e) {
transformer = null;
}
if(xml != null && transformer != null) {
xml.setRoot(true);
ByteArrayOutputStream xmlOutStream = new ByteArrayOutputStream();
OutputStream xsltOutStream = new ByteArrayOutputStream();
try {
//send standard xml to the output stream
XMLStreamWriter sw = xmlOutputFactory.createXMLStreamWriter(xmlOutStream);
xml.output(sw);
//convert output stream to byte array and read back in as inputstream
Source source = new StreamSource(new ByteArrayInputStream(xmlOutStream.toByteArray()));
Result rstream = new StreamResult(xsltOutStream);