Skip to content

Commit 3fc96e8

Browse files
committed
[bugfix] Make sure that /db URIs are converted to xmldb:exist:///db URIs when setting Base URI for XSLT transformations
1 parent b8aace4 commit 3fc96e8

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.exist.dom.memtree.NamespaceNode;
5757
import org.exist.dom.persistent.NodeProxy;
5858
import org.exist.security.PermissionDeniedException;
59+
import org.exist.xmldb.XmldbURI;
5960
import org.exist.xquery.ErrorCodes;
6061
import org.exist.xquery.XPathException;
6162
import org.exist.xquery.XQueryContext;
@@ -490,7 +491,13 @@ private Tuple2<String, Source> getStylesheet(final MapType options) throws XPath
490491
final List<Tuple2<String, Source>> results = new ArrayList<>(1);
491492
final Optional<String> stylesheetLocation = Options.STYLESHEET_LOCATION.get(options).map(StringValue::getStringValue);
492493
if (stylesheetLocation.isPresent()) {
493-
results.add(Tuple(stylesheetLocation.get(), resolveStylesheetLocation(stylesheetLocation.get())));
494+
final String strStylesheetLocationUri;
495+
if (stylesheetLocation.get().startsWith("/db/")) {
496+
strStylesheetLocationUri = XmldbURI.EMBEDDED_SERVER_URI_PREFIX + stylesheetLocation.get();
497+
} else {
498+
strStylesheetLocationUri = stylesheetLocation.get();
499+
}
500+
results.add(Tuple(strStylesheetLocationUri, resolveStylesheetLocation(stylesheetLocation.get())));
494501
}
495502

496503
final Optional<Node> stylesheetNode = Options.STYLESHEET_NODE.get(options).map(NodeValue::getNode);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,14 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
181181

182182
// Parameter 1 & 2
183183
final Sequence inputNode = args[0];
184-
final Item stylesheetItem = args[1].itemAt(0);
184+
Item stylesheetItem = args[1].itemAt(0);
185+
if (stylesheetItem instanceof StringValue) {
186+
final StringValue sv = (StringValue) stylesheetItem;
187+
if (sv.toString().startsWith("/db/")) {
188+
// adjust /db like URI to xmldb:exist:///db/ like URI
189+
stylesheetItem = new StringValue(XmldbURI.EMBEDDED_SERVER_URI_PREFIX + sv.toString().substring(3));
190+
}
191+
}
185192

186193
// Parse 3rd parameter
187194
final Node options = args[2].isEmpty() ? null : ((NodeValue) args[2].itemAt(0)).getNode();

0 commit comments

Comments
 (0)