Skip to content

Commit

Permalink
Expand system ID in the default URI resolver (see #186)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Nov 2, 2018
1 parent b935eba commit 8967764
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
public class NoNamespaceSchemaLocation {

private final Attr attr;

private final String location;

public NoNamespaceSchemaLocation(String xmlDocumentURI, Attr attr) {
this.location = getLocation(xmlDocumentURI, attr.getValue());
this.location = attr.getValue(); //getLocation(xmlDocumentURI, attr.getValue());
this.attr = attr;
}

Expand All @@ -35,7 +35,7 @@ private String getLocation(String xmlDocumentURI, String location) {
return location;
}
}

public Attr getAttr() {
return attr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public SchemaLocation(String base, String value) {
String locationHint = st.hasMoreTokens() ? st.nextToken() : null;
if (namespaceURI == null || locationHint == null)
break;
try {
locationHint = XMLEntityManager.expandSystemId(locationHint, base, false);
} catch (MalformedURIException e) {
// Do nothing
}
// try {
// //locationHint = XMLEntityManager.expandSystemId(locationHint, base, false);
// } catch (MalformedURIException e) {
// // Do nothing
// }
schemaLocationValuePairs.put(namespaceURI, locationHint);
} while (true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.util.List;
import java.util.Map;

import org.apache.xerces.impl.XMLEntityManager;
import org.apache.xerces.util.URI.MalformedURIException;
import org.apache.xerces.xni.XMLResourceIdentifier;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLInputSource;
Expand Down Expand Up @@ -45,7 +47,11 @@ class DefaultURIResolverExtension implements URIResolverExtension {

@Override
public String resolve(String baseLocation, String publicId, String systemId) {
return systemId;
try {
return XMLEntityManager.expandSystemId(systemId, baseLocation, false);
} catch (MalformedURIException e) {
return systemId;
}
}

@Override
Expand All @@ -55,7 +61,9 @@ public XMLInputSource resolveEntity(XMLResourceIdentifier rid) throws XNIExcepti
if (id == null) {
id = rid.getNamespace();
}

if (rid.getExpandedSystemId() != null) {

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

0 comments on commit 8967764

Please sign in to comment.