File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
main/java/org/exist/xquery/functions/fn/transform
test/java/org/exist/xquery/functions/fn/transform Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -51,20 +51,21 @@ public class URIResolution {
51
51
* @return resolved URI
52
52
* @throws URISyntaxException if resolution is not possible
53
53
*/
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 {
55
55
var relativeURI = new URI (relative .getStringValue ());
56
56
if (relativeURI .isAbsolute ()) {
57
57
return relative ;
58
58
}
59
59
var baseURI = new URI (base .getStringValue () );
60
+ if (!baseURI .isAbsolute ()) {
61
+ return relative ;
62
+ }
60
63
try {
61
64
var xBase = XmldbURI .xmldbUriFor (baseURI );
62
65
var resolved = xBase .getURI ().resolve (relativeURI );
63
66
return new AnyURIValue (XmldbURI .XMLDB_URI_PREFIX + resolved );
64
67
} catch (URISyntaxException e ) {
65
68
return new AnyURIValue (baseURI .resolve (relativeURI ));
66
- } catch (XPathException e ) {
67
- throw new RuntimeException (e );
68
69
}
69
70
}
70
71
Original file line number Diff line number Diff line change @@ -56,6 +56,12 @@ void versionNumbers() throws Transform.PendingException {
56
56
});
57
57
}
58
58
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
+
59
65
@ Test public void resolution () throws XPathException , URISyntaxException {
60
66
var base = new AnyURIValue ("xmldb:exist:///db/apps/fn_transform/tei-toc2.xsl" );
61
67
var relative = new AnyURIValue ("functions1.xsl" );
You can’t perform that action at this time.
0 commit comments