Skip to content

Fix base-uri() returning empty string instead of the document path #204

Open
Laurettta wants to merge 2 commits intodevelop-7.x.xfrom
7.x.x/bugfix/base-uri-returns-db-instead-of-document-path
Open

Fix base-uri() returning empty string instead of the document path #204
Laurettta wants to merge 2 commits intodevelop-7.x.xfrom
7.x.x/bugfix/base-uri-returns-db-instead-of-document-path

Conversation

@Laurettta
Copy link
Copy Markdown

Description:
base-uri() was returning an empty string for in-memory documents loaded from disk.
The root cause was that getBaseURI() in DocumentImpl was checking for an xml:base
attribute on the root element first, but when that attribute wasn't there, it returned
empty string instead of falling through. Removed that block so getDocumentURI() is
checked first, which gives the right result.

Reference:
closes #186

Tests:
Added three JUnit tests in DocumentImplTest:

  • getBaseURI_withDocumentURI: confirms the document URI is returned when set
  • getBaseURI_ignoresXmlBaseOnRoot: confirms xml:base on the root element no longer
    overrides the document URI
  • getBaseURI_noDocumentURI: confirms empty string is returned when no document URI
    is set (existing fallback behaviour preserved)

…t path

  Closes #186
  The xml:base lookup in getBaseURI() was returning empty string when the attribute didn't exist. Removed it so we fall through to getDocumentURI() which gives the correct result.
@Laurettta Laurettta requested a review from adamretter May 1, 2026 09:15
@Laurettta Laurettta added the bug Something isn't working label May 1, 2026
@cla-bot cla-bot Bot added the cla-signed label May 1, 2026
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 1, 2026

Not up to standards ⛔

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Comment thread exist-core/src/test/java/org/exist/dom/memtree/DocumentImplTest.java Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cla-signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants