You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When trying to get fn:transform#1 to behave in our environment, we found that base-uri#1 did not return what we expected. Rather than returning the path it returned /db.
BTW document-uri#1 did return the path, so that served as a workaround.
Expected behavior
We expect the path to $doc to be returned when calling base-uri($doc).
To Reproduce
With any document path:
let $disk-path as xs:string := 'file:///C:/intranet/components/benjamins.com/xsl/general-web-templates.xsl'
let $doc as document-node() := doc($disk-path)
return base-uri($doc)
Context (please always complete the following information)
Version: [Elemental 6.9.0]
Java: various
OS: Windows 11, Linux
We did not check whether a similar problem exists for in memory documents. Also, there is another open issue regarding fn:transform, #169 which might be related to this one.
I think the problem is in org.exists.dom.memtree.DocumentImpl, in the getBaseURI() method. This first thing it does is final Element el = getDocumentElement();. If el != null, which is true if the document has a root element, it determines the attribute value getAttributeNS(Namespaces.XML_NS, "base"). This makes sense, but the attribute value is the empty string, and the test in the following line is if(baseURI != null). Thus, "" is returned, and in FunBaseURI this is replaced by the contextBaseURI.
My suggestion would be to use hasAttributeNS in the first few lines of getBaseURI() in org.exist.dom.memtree.DocumentImpl:
public String getBaseURI() {
final Element el = getDocumentElement();
if (el != null) {
if (el.hasAttributeNS(Namespaces.XML_NS, "base")) {
final String baseURI = el.getAttributeNS(Namespaces.XML_NS, "base");
return baseURI;
}
}
Activity
nverwer commentedon Mar 16, 2026
I think the problem is in
org.exists.dom.memtree.DocumentImpl, in thegetBaseURI()method. This first thing it does isfinal Element el = getDocumentElement();. Ifel != null, which istrueif the document has a root element, it determines the attribute valuegetAttributeNS(Namespaces.XML_NS, "base"). This makes sense, but the attribute value is the empty string, and the test in the following line isif(baseURI != null). Thus,""is returned, and inFunBaseURIthis is replaced by thecontextBaseURI.My suggestion would be to use
hasAttributeNSin the first few lines ofgetBaseURI()inorg.exist.dom.memtree.DocumentImpl:adamretter commentedon Jul 17, 2026
Closed by #204 and #218