return null;
}
try {
// if it's already an absolute one, return it
URI uri = new URI(systemId);
return systemId;
}
catch (URI.MalformedURIException ex) {
}
URI base = null;
// if there isn't a base uri, use the working directory
if (baseSystemId == null || baseSystemId.length() == 0) {
base = new URI("file", "", getUserDir(), null, null);
}
// otherwise, use the base uri
else {
try {
base = new URI(baseSystemId);
}
catch (URI.MalformedURIException e) {
// assume "base" is also a relative uri
String dir = getUserDir();
dir = dir + baseSystemId;
base = new URI("file", "", dir, null, null);
}
}
// absolutize the system id using the base
URI uri = new URI(base, systemId);
// return the string rep of the new uri (an absolute one)
return uri.toString();
// if any exception is thrown, it'll get thrown to the caller.
}
// check for bad parameters id
if (systemId == null || systemId.length() == 0) {
return systemId;
}
// if id already expanded, return
try {
URI uri = new URI(systemId.trim());
if (uri != null) {
return systemId;
}
}
catch (URI.MalformedURIException e) {
// continue on...
}
// normalize id
String id = fixURI(systemId);
// normalize base
URI base = null;
URI uri = null;
try {
if (baseSystemId == null || baseSystemId.length() == 0 ||
baseSystemId.equals(systemId)) {
String dir = getUserDir();
base = new URI("file", "", dir, null, null);
}
else {
try {
base = new URI(fixURI(baseSystemId).trim());
}
catch (URI.MalformedURIException e) {
if (baseSystemId.indexOf(':') != -1) {
// for xml schemas we might have baseURI with
// a specified drive
base = new URI("file", "", fixURI(baseSystemId).trim(), null, null);
}
else {
String dir = getUserDir();
dir = dir + fixURI(baseSystemId);
base = new URI("file", "", dir, null, null);
}
}
}
// expand id
uri = new URI(base, id.trim());
}
catch (Exception e) {
// let it go through
}
if (uri == null) {
return systemId;
}
return uri.toString();
} // expandSystemId(String,String):String