in cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java [248:323]
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
throws SAXException {
if (getContentHandler() != null) {
getContentHandler().startElement(namespaceURI, localName, qName, atts);
}
String relativeRef = findExternalResource(namespaceURI, localName, atts);
if (relativeRef == null) {
return; // not found
}
try {
// absolutize URL.
String lsi = locator.getSystemId();
String ref;
URI relRefURI = new URI(relativeRef);
if (relRefURI.isAbsolute()) {
ref = relativeRef;
} else {
if (lsi.startsWith("jar:")) {
int bangIdx = lsi.indexOf('!');
if (bangIdx > 0) {
ref = lsi.substring(0, bangIdx + 1)
+ new URI(lsi.substring(bangIdx + 1)).resolve(new URI(relativeRef)).toString();
} else {
ref = relativeRef;
}
} else {
ref = new URI(lsi).resolve(new URI(relativeRef)).toString();
}
}
if (parent != null) {
ref = Options.normalizeSystemId(ref);
if (parent.get(ref) != null) {
return;
}
InputSource is = null;
// allow entity resolver to find the actual byte stream.
if (parent.getEntityResolver() != null) {
is = parent.getEntityResolver().resolveEntity(null, ref);
}
if (is == null) {
is = new InputSource(ref);
} else {
ref = is.getSystemId();
}
if (parent.get(ref) != null) {
is.getByteStream().close();
return;
}
parent.parse(ref, is, false);
}
} catch (URISyntaxException e) {
String msg = e.getMessage();
if (new File(relativeRef).exists()) {
msg = "Filename is not a URI " + ' ' + msg;
}
SAXParseException spe = new SAXParseException2(
"Unable to parse " + relativeRef + ": " + msg,
locator, e);
fatalError(spe);
throw spe;
} catch (IOException e) {
SAXParseException spe = new SAXParseException2(
"Unable to parse " + relativeRef + ": " + e.getMessage(),
locator, e);
fatalError(spe);
throw spe;
}
}