Skip to content

Commit

Permalink
Attempt to workaround unparsed text problem
Browse files Browse the repository at this point in the history
  • Loading branch information
ndw committed Aug 26, 2023
1 parent 63e792c commit 465c11e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main/java/com/xmlcalabash/util/XProcURIResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,20 @@ public Source resolve(ResourceRequest request) throws XPathException {
String href = request.relativeUri == null ? request.uri : request.relativeUri;
String baseUri = request.baseUri == null ? request.uri : request.baseUri;
try {
return catalogResolver.resolve(href, baseUri);
Source source = catalogResolver.resolve(href, baseUri);
// Hack. Starting at maybe 10.9, Saxon got cranky about what comes back from
// attempting to read an unparsed text resource. It has to be a stream source.
// This is an attempt to work around that problem
if (ResourceRequest.TEXT_NATURE.equals(request.nature)
|| ResourceRequest.BINARY_NATURE.equals(request.nature)) {
try {
URL url = new URL(source.getSystemId());
return new StreamSource(url.openStream(), source.getSystemId());
} catch (IOException ex) {
// nevermind
}
}
return source;
} catch (TransformerException | IllegalArgumentException e) {
throw new XPathException("Exception from catalog resolver resolverURI()", e);
}
Expand Down

0 comments on commit 465c11e

Please sign in to comment.