Hello,

So we came across a strange behaviour while building a webapp with BaseX and aren’t sure if it’s a bug or an edge case we can’t wrap our heads around. I’ll try to explain it the best I can, with basic examples attached.

First some context:
    - our app needs to fetch xml fragments stored in a database (one db per app instance) which can contains anywhere from 1 to X document(s)
    - these xml documents can be encoded in xml-TEI (which use attribute @xml:id) or xml-ead (which use @id) ; we plan to add support for more xml vocabularies in the future and thus can’t presume whichether attribute is used
    - so far we’ve used a function which checks for both attributes by writing it as `@*:id`, similar to the attached query `query2`


Now here’s the problem : this doesn’t seem to work to fetch element with an @xml:id attribute if and only if:
    - the document containing the target node only has 1 namespace declared in an @xmlns attribute (see `doc1a` and `doc1b`)
    - AND the document is the only one in the database we’re trying to fetch from


Here are the tests we conducted before reaching out to you:
    - `doc1a` and `doc1b` are identicals, and contain only 1 namespace encoded in an @xmlns attribute
    - `doc2` is the same as them except it has 2 (identical) namespaces, one declared in an @xmlns attribute and the other in @xmlns:ns
    - `query1` search for specific(s) <div> using `@xml:id='div2'`
    - `query2` is the same but writes it as `@*:id='div2'`

    - If we search in doc1a (OR doc1b) ALONE, query1 find the searched <div> [test1] but query2 fails [test2]
    - If we search in doc2 ALONE, both query1 and query2 find the searched <div> [test3 and test4]
    - If we search in any combination of 2 or more of these documents, both query1 and query2 find the searched <div> [test5 and test6]

This as been tested with BaseX versions 10.7, 11.7 and 12.2, both in our webapp and on the GUI – to the same result each time. Attached is a basex script which reproduce these tests.

So as I said, we’re not sure why it would do that – failing with 1 doc but working with 2 or more ? In any case we can build around that (by writing eg. `[@*:id or @xml:id]`), we’re just curious to know if it’s working as intended and if yes, if there is more to this that we should know of. 
Thank you for your time.

Best regards,
O.-V. Pain