Skip to content

base-uri#1 not set correctly #186

Closed
Closed

Description

@PieterLamers

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.

Activity

  1. nverwer commented on Mar 16, 2026

    @nverwer

    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;
                }
            }
    
  2. adamretter commented on Jul 17, 2026

    @adamretter
    Member

    Closed by #204 and #218

  3. added this to the elemental-6.10.1 milestone on Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions