Skip to content

Commit d136666

Browse files
committed
[bugfix] fn:transform resolve without a base
just yield the relative URI unchanged, we were sticking the xmldb prefix in front.
1 parent 4398385 commit d136666

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

exist-core/src/main/java/org/exist/xquery/functions/fn/transform/URIResolution.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,21 @@ public class URIResolution {
5151
* @return resolved URI
5252
* @throws URISyntaxException if resolution is not possible
5353
*/
54-
static AnyURIValue resolveURI(final AnyURIValue relative, final AnyURIValue base) throws URISyntaxException {
54+
static AnyURIValue resolveURI(final AnyURIValue relative, final AnyURIValue base) throws URISyntaxException, XPathException {
5555
var relativeURI = new URI(relative.getStringValue());
5656
if (relativeURI.isAbsolute()) {
5757
return relative;
5858
}
5959
var baseURI = new URI(base.getStringValue() );
60+
if (!baseURI.isAbsolute()) {
61+
return relative;
62+
}
6063
try {
6164
var xBase = XmldbURI.xmldbUriFor(baseURI);
6265
var resolved = xBase.getURI().resolve(relativeURI);
6366
return new AnyURIValue(XmldbURI.XMLDB_URI_PREFIX + resolved);
6467
} catch (URISyntaxException e) {
6568
return new AnyURIValue(baseURI.resolve(relativeURI));
66-
} catch (XPathException e) {
67-
throw new RuntimeException(e);
6869
}
6970
}
7071

exist-core/src/test/java/org/exist/xquery/functions/fn/transform/FunTransformTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ void versionNumbers() throws Transform.PendingException {
5656
});
5757
}
5858

59+
@Test public void emptyResolution() throws XPathException, URISyntaxException {
60+
var base = new AnyURIValue("");
61+
var relative = new AnyURIValue("path/to/functions1.xsl");
62+
assertEquals(new AnyURIValue("path/to/functions1.xsl"), URIResolution.resolveURI(relative, base));
63+
}
64+
5965
@Test public void resolution() throws XPathException, URISyntaxException {
6066
var base = new AnyURIValue("xmldb:exist:///db/apps/fn_transform/tei-toc2.xsl");
6167
var relative = new AnyURIValue("functions1.xsl");

0 commit comments

Comments
 (0)