Skip to content

Commit

Permalink
Simplify URI resolver (see #144)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Oct 30, 2018
1 parent d237c01 commit 33ecf3a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,8 @@ public interface URIResolverExtension extends XMLEntityResolver {
public String resolve(String baseLocation, String publicId, String systemId);

@Override
default XMLInputSource resolveEntity(XMLResourceIdentifier rid) throws XNIException, IOException {
XMLInputSource is = null;
String id = rid.getPublicId();
if (id == null) {
id = rid.getNamespace();
}

String location = null;
if (id != null || rid.getLiteralSystemId() != null) {
location = this.resolve(rid.getBaseSystemId(), id, rid.getLiteralSystemId());
}

if (location != null) {
is = new XMLInputSource(rid.getPublicId(), location, location);
}
return is;
default XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ class DefaultURIResolverExtension implements URIResolverExtension {
public String resolve(String baseLocation, String publicId, String systemId) {
return systemId;
}

@Override
public XMLInputSource resolveEntity(XMLResourceIdentifier rid) throws XNIException, IOException {
XMLInputSource is = null;
String id = rid.getPublicId();
if (id == null) {
id = rid.getNamespace();
}

String location = null;
if (id != null || rid.getLiteralSystemId() != null) {
location = this.resolve(rid.getBaseSystemId(), id, rid.getLiteralSystemId());
}

if (location != null) {
is = new XMLInputSource(rid.getPublicId(), location, location);
}
return is;
}
}

/**
Expand Down

0 comments on commit 33ecf3a

Please sign in to comment.