puzzle over namespace qualification and absolute vs. relative location paths
Saturday, 16 June 2012 · 2 messages
CS
C. M. Sperberg-McQueen16 Jun 2012 02:35 #
An unexpected phenomenon has arisen in the XQuery course I'm teaching today and tomorrow; I wonder if anyone on this list can shed any light on it.
To reproduce:
1 build a database containing the document
http://blackmesatech.com/2012/06/data/sonnet92.xml
2 evaluate the following expressions
(a) . (displays the entire document)
(b) ./* (ditto)
(c) declare namespace n = "http://www.tei-c.org/ns/1.0";
./n:TEI (again returns entire document)
This one didn't surprise me; it's what I expected.
(d) /TEI (ditto)
This one surprised me, since the TEI element in the
document is namespace-qualified, and I would not have
expected the expression to match anything.
At this point, I would be tempted to say "well, maybe
when we built the database, BaseX set the default
element namespace in the static context to the TEI
namespace." That would explain the evaluation of this
expression.
But ...
(e) ./TEI (returns nothing)
If the default element namespace in the static context were
the TEI namespace, I would expect this to work. If it were
NOT the TEI namespace, I would expect (d) to fail.
I'm having trouble explaining to the participants in my course (or to myself) why expressions (d) and (e) return different results.
What am I missing?
best regards,
Michael Sperberg-McQueen
CG
Christian Grün16 Jun 2012 15:16 #
Dear Michael,
Quoted text · C. M. Sperberg-McQueen · 5 lines
> (d) /TEI (ditto) > > This one surprised me, since the TEI element in the > document is namespace-qualified, and I would not have > expected the expression to match anything.
This was due to a bug in the query optimization step that has recently been fixed. The latest snapshot (and Version 7.3, which will be released in 1, 2 days) will return the expected results:
http://files.basex.org/releases/latest/
Sorry for that,
Christian
Written for BaseX 7.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery