I'm writing a library that generates complex XQuery expressions that target documents from two different namespaces. However, when I'm generating the query I don't know the particular namespace for each element I have to query, so I'm currently generating a disjunction of the two possible combinations:
//*[ns1:foo/ns1:bar = "some condition" or ns2:foo/ns2:bar = "some condition"]
Is there any way to generate this expression more nicely and more optimal in terms of performance?
One possible solution I found is to use:
declare default element namespace "*"
in which case I could simply generate:
//*[foo/bar = "some condition"]
but looks like that may add additional performance overhead as I cannot enumerate the two possible namespace there and use wildcard instead.
//*[local-name()='foo']/bar[*condition here*]suffice? - JWiley