Skip to content

Follow up GH-357 in the documentation of Element#attribute - #367

Merged
kou merged 1 commit into
ruby:masterfrom
naitoh:fix_attribute_namespace_document
Aug 31, 2026
Merged

Follow up GH-357 in the documentation of Element#attribute#367
kou merged 1 commit into
ruby:masterfrom
naitoh:fix_attribute_namespace_document

Conversation

@naitoh

@naitoh naitoh commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

GH-360 documented REXML::Element#attribute as matching a namespace loosely, and said an unprefixed attribute is taken to be in the default namespace. GH-357 made the method ask
REXML::Attributes#get_attribute_ns first, so that is now only true when nothing matches strictly:

<root xmlns='ns0' xmlns:p='ns0' a='A' p:a='PA'/>

attribute("a", "ns0")   ->  p:a='PA', not a='A'

The two examples in the note still hold, because neither document has a prefixed attribute of the same local name for the strict match to find. It is the rule stated around them that no longer holds: an unprefixed attribute is taken to be in the default namespace only when nothing matches strictly.

Describe the method the way it now works -- strict first, then the compatibility fallback -- and add the example above, which is the only place the change is visible. Say of get_attribute_ns that it matches strictly and only strictly, rather than pointing at it as the way to match strictly, now that Element#attribute starts there too.

rubyGH-360 documented REXML::Element#attribute as matching a namespace
loosely, and said an unprefixed attribute is taken to be in the default
namespace.  rubyGH-357 made the method ask
REXML::Attributes#get_attribute_ns first, so that is now only true when
nothing matches strictly:

    <root xmlns='ns0' xmlns:p='ns0' a='A' p:a='PA'/>

    attribute("a", "ns0")   ->  p:a='PA', not a='A'

The two examples in the note still hold, because neither document has a
prefixed attribute of the same local name for the strict match to find.
It is the rule stated around them that no longer holds: an unprefixed
attribute is taken to be in the default namespace only when nothing
matches strictly.

Describe the method the way it now works -- strict first, then the
compatibility fallback -- and add the example above, which is the only
place the change is visible.  Say of get_attribute_ns that it matches
strictly and only strictly, rather than pointing at it as the way to
match strictly, now that Element#attribute starts there too.
@naitoh
naitoh requested a review from kou August 31, 2026 02:03
@kou

kou commented Aug 31, 2026

Copy link
Copy Markdown
Member

Thanks.

@kou
kou merged commit 0921a03 into ruby:master Aug 31, 2026
71 checks passed
@naitoh
naitoh deleted the fix_attribute_namespace_document branch August 31, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants