Skip to content

Resolve the implicit xml namespace binding - #159

Open
ac1982 wants to merge 1 commit into
beevik:mainfrom
ac1982:fix/implicit-xml-namespace
Open

ac1982 wants to merge 1 commit into
beevik:mainfrom
ac1982:fix/implicit-xml-namespace

Conversation

@ac1982

@ac1982 ac1982 commented Oct 10, 2026

Copy link
Copy Markdown

For <root xml:lang="en"/>, root.SelectAttr("xml:lang").NamespaceURI() returns an empty string unless the document explicitly declares xmlns:xml. XML-prefixed elements have the same problem.

Namespaces in XML §3 defines the xml prefix as always bound to http://www.w3.org/XML/1998/namespace; a declaration is optional. Recognize that binding in the shared namespace lookup. Ordinary declared/default namespaces retain their existing handling.

The regression covers implicit and explicit declarations, a surrounding default namespace, xml:lang/xml:space, and a copied XML-prefixed element detached from its original declaration. All three subtests fail on the base revision and pass after this change. go test ./..., go test -race ./..., go vet ./..., go build ./..., and git diff --check pass on Go 1.27.1 / Linux arm64. Go 1.23 and other platforms were not run locally.

AI assistance: OpenAI Codex investigated, implemented, and ran these checks.

Signed-off-by: AC <ac@fabtek.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant