[fix] Resolve namespace for prefixed attribute names in range index conditions#6094
[fix] Resolve namespace for prefixed attribute names in range index conditions#6094joewiz wants to merge 2 commits intoeXist-db:developfrom
Conversation
9ddb80f to
9221d28
Compare
…x conditions The range index condition's @Attribute accepted prefixed names like "wwp:field" but ignored the namespace prefix, binding it to the null namespace. This caused two bugs: 1. A prefixed attribute (wwp:field) and an unprefixed attribute (field) were treated as identical by the indexer. 2. The matches() method used DOM getAttribute() with the raw prefixed string instead of getAttributeNS() with the resolved namespace URI. Fix by resolving the prefix against the namespace map declared on the <index> element (the same map already used for qname resolution on <create> elements), and using getAttributeNS() for namespace-aware attribute lookup. Also update collection.xconf.xsd to allow xs:string (not xs:NCName) for the condition @Attribute, consistent with how @Qname is typed elsewhere in the schema. Closes eXist-db#5189 Co-Authored-By: Claude Opus 4.6 <[email protected]>
…ndex Tests verify that range index conditions using namespace-prefixed attribute names (e.g. wwp:field) correctly index matching elements and that the query optimizer rewrites predicates on prefixed attributes. Co-Authored-By: Claude Opus 4.6 <[email protected]>
9221d28 to
b16d534
Compare
Documentation update notesSuggested additions to the "Conditional Indexes" section of https://exist-db.org/exist/apps/doc/newrangeindex:
🤖 Co-authored with Claude Code |
Summary
wwp:field) in range index<condition>elementscollection.xconf.xsdto accept prefixed attribute namesCloses #5189
What Changed
RangeIndexConfigAttributeCondition.java— The constructor now accepts aMap<String, String> namespacesparameter (the same namespace map already used by<create qname="...">resolution). When the@attributevalue contains a prefix, the prefix is resolved to a namespace URI. Thematches()method now usesgetAttributeNS()for namespaced attributes instead ofgetAttribute()with the raw prefixed string.ComplexRangeIndexConfigElement.java— Passes thenamespacesmap through to theRangeIndexConfigAttributeConditionconstructor.collection.xconf.xsd— ChangedattributeReqtype fromxs:NCNametoxs:string, consistent with how@qnameis typed elsewhere in the schema. (xs:QNameis unsuitable here because XSD QName validation requires the prefix to be resolvable in the schema instance context.)prefixed-conditions.xql— 6 new XQSuite tests verifying that both prefixed (wwp:field) and unprefixed (field) attribute conditions correctly index matching elements and that the query optimizer rewrites predicates on both.Test Plan
RangeIndexConfigTestunit test passes🤖 Generated with Claude Code