Description
In the database storage of BaseX, element and attribute names are indexed by their prefix:local
representation, and the namespace is retrieved at runtime. This is why some compile-time query optimizations are skipped if a database has namespaces.
There are cases, though, in which a more fine-grained namespace detection would be possible and desirable. For example, if a document only has non-default namespace declarations…
<a xmlns:pre='URI'><b>B</b></a>
…and if an element/attribute name in an XPath step has no namespace (e.g. //b
), it can safely be associated with elements of the accessed database. Steps with non-existing elements can then be replaced with empty sequences, or a text()
step can be attached to a path expression that may later be rewritten for index access.
Script:
create db simple <a xmlns:x='X'><b>B</b></a>
xquery /a[b = 'B']
close