Skip to content

ixml: implement if_ixml_node~get_namespace_uri - #1235

Merged
larshp merged 1 commit into
open-abap:mainfrom
abap2UI5:claude/nifty-meitner-ema3y8-namespace-uri
Sep 15, 2026
Merged

larshp merged 1 commit into
open-abap:mainfrom
abap2UI5:claude/nifty-meitner-ema3y8-namespace-uri

Conversation

@oblomov-dev

Copy link
Copy Markdown
Contributor

What is wrong

The method is a stub, src/ixml/cl_ixml.clas.locals_imp.abap:

METHOD if_ixml_node~get_namespace_uri.
  ASSERT 1 = 'todo'.
ENDMETHOD.

so asking a parsed node which namespace it belongs to ends the program rather
than answering:

parse( |<n:root xmlns:n="urn:x"><n:item>A</n:item></n:root>| )->get_root_element( )->get_namespace_uri( ).
" ASSERTION_FAILED

The prefix itself is readable — get_namespace_prefix returns n — but a
prefix says nothing on its own: it is local to the document, and the uri is
what identifies the namespace. Anything that has to tell one namespace from
another (a SOAP envelope, an OData document, an abapGit file) needs the uri,
and today cannot ask for it.

The change

The declaration that binds a prefix is an ordinary attribute:
xmlns:<prefix>, or xmlns for a node without a prefix. It may stand on the
node itself or on any of its ancestors, and the nearest one wins — so the
lookup walks up the parents and returns the first binding it finds:

IF mv_namespace IS INITIAL.
  lv_name = 'xmlns'.
ELSE.
  CONCATENATE 'xmlns:' mv_namespace INTO lv_name.
ENDIF.

li_node = me.
WHILE li_node IS BOUND.
  li_map = li_node->get_attributes( ).
  IF li_map IS BOUND.
    li_attr = li_map->get_named_item( lv_name ).
    ...

An undeclared prefix has no uri:

The method was an `ASSERT 1 = 'todo'`, so asking a parsed node which namespace
it belongs to ended the program. The prefix was readable
(get_namespace_prefix returns it), the binding behind it was not - and the
prefix alone says nothing, it is the uri that identifies a namespace.

The declaration that binds it is an ordinary attribute: "xmlns:<prefix>", or
"xmlns" for a node without a prefix. It may stand on the node itself or on
any ancestor and the nearest one wins, so the lookup walks up the parents and
returns the first it finds. An undeclared prefix has no uri and stays
initial rather than raising.

lcl_document delegates to its node, as it does for get_attributes and
get_parent next to it.

Tests: a prefixed root, a child that inherits the declaration from its root,
a default namespace, a document without one, and an undeclared prefix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKSWLpid4QLV6XWAoPixbb
@oblomov-dev
oblomov-dev force-pushed the claude/nifty-meitner-ema3y8-namespace-uri branch from 3166402 to f23a353 Compare September 15, 2026 14:48
@larshp
larshp merged commit b8e1a89 into open-abap:main Sep 15, 2026
7 checks passed
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.

3 participants