URLConnection connection = url.openConnection();
connection.setUseCaches(false);
scdlStream = connection.getInputStream();
}
} catch ( Exception e ) {
throw new ContributionReadException(e);
}
XMLStreamReader reader = inputFactory.createXMLStreamReader(scdlStream);
reader.nextTag();
// Read the composite model
Composite composite = (Composite)extensionProcessor.read(reader);
if (composite != null) {
composite.setURI(uri.toString());
}
// For debugging purposes, write it back to XML
// if (composite != null) {
// try {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
// extensionProcessor.write(composite, outputFactory.createXMLStreamWriter(bos));
// Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray()));
// OutputFormat format = new OutputFormat();
// format.setIndenting(true);
// format.setIndent(2);
// XMLSerializer serializer = new XMLSerializer(System.out, format);
// serializer.serialize(document);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
return composite;
} catch (XMLStreamException e) {
throw new ContributionReadException(e);
} finally {
try {
if (scdlStream != null) {
scdlStream.close();
scdlStream = null;