in taverna-scufl2-ucfpackage/src/main/java/org/apache/taverna/scufl2/ucfpackage/UCFPackage.java [198:250]
protected void prepareContainerXML() throws IOException {
if (containerXml == null || createdContainerXml
&& containerXml.getValue().getRootFilesOrAny() == null)
return;
/* Check if we should prune <rootFiles> */
Iterator<Object> iterator = containerXml.getValue().getRootFilesOrAny()
.iterator();
boolean foundAlready = false;
while (iterator.hasNext()) {
Object anyOrRoot = iterator.next();
if (!(anyOrRoot instanceof JAXBElement))
continue;
@SuppressWarnings("rawtypes")
JAXBElement elem = (JAXBElement) anyOrRoot;
if (!elem.getDeclaredType().equals(RootFiles.class))
continue;
RootFiles rootFiles = (RootFiles) elem.getValue();
if (foundAlready
|| (rootFiles.getOtherAttributes().isEmpty() && rootFiles
.getAnyOrRootFile().isEmpty())) {
// Delete it!
System.err.println("Deleting unneccessary <rootFiles>");
iterator.remove();
}
foundAlready = true;
}
Marshaller marshaller;
try {
marshaller = createMarshaller();
// XMLStreamWriter xmlStreamWriter = XMLOutputFactory
// .newInstance().createXMLStreamWriter(outStream);
// xmlStreamWriter.setDefaultNamespace(containerElem.getName()
// .getNamespaceURI());
//
// xmlStreamWriter.setPrefix("dsig",
// "http://www.w3.org/2000/09/xmldsig#");
// xmlStreamWriter.setPrefix("xmlenc",
// "http://www.w3.org/2001/04/xmlenc#");
try (OutputStream outStream = odfPackage
.insertOutputStream(CONTAINER_XML)) {
// FIXME: Set namespace prefixes and default namespace
marshaller.setProperty("jaxb.formatted.output", true);
// TODO: Ensure using default namespace
marshaller.marshal(containerXml, outStream);
}
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException("Could not parse " + CONTAINER_XML, e);
}
}