if (baseURI == null) {
baseURI = si.getSystemId();
}
DOMSource ds = new DOMSource(el, baseURI);
schemaSourcesMap2.put(si.getSystemId() + ":" + si.getNamespaceURI(), ds);
LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
StaxUtils.copy(el, StaxUtils.createXMLStreamWriter(out));
schemaSourcesMap.put(si.getSystemId() + ":" + si.getNamespaceURI(), out.toByteArray());
}
for (XmlSchema sch : serviceInfo.getXmlSchemaCollection().getXmlSchemas()) {
if (sch.getSourceURI() != null
&& !schemaSourcesMap.containsKey(sch.getSourceURI() + ":"
+ sch.getTargetNamespace())) {
InputStream ins = null;
try {
URL url = new URL(sch.getSourceURI());
ins = url.openStream();
} catch (Exception e) {
//ignore, we'll just use what we have. (though
//bugs in XmlSchema could make this less useful)
}
LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
if (ins == null) {
sch.write(out);
} else {
IOUtils.copyAndCloseInput(ins, out);
}
schemaSourcesMap.put(sch.getSourceURI() + ":"
+ sch.getTargetNamespace(), out.toByteArray());
Source source = new StreamSource(out.createInputStream(), sch.getSourceURI());
schemaSourcesMap2.put(sch.getSourceURI() + ":"
+ sch.getTargetNamespace(), source);
}
}