Skip to content

[bugfix] fix base-uri() returning empty string instead of the document path #204

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

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

Conversation

@Laurettta
Copy link
Copy Markdown

@Laurettta Laurettta commented May 1, 2026

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.

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)

Closes #186

…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
Comment thread exist-core/src/test/java/org/exist/dom/memtree/DocumentImplTest.java Outdated
@evolvedbinary evolvedbinary deleted a comment from codacy-production Bot May 12, 2026
@Laurettta Laurettta changed the title Fix base-uri() returning empty string instead of the document path [bugfix] fix base-uri() returning empty string instead of the document path May 13, 2026
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