Hello,

I have a small database of library catalog records that I am trying to run some simple queries on, but I'm running into a namespace problem.

Some docs in the database have the following structure, with a wrapper collection element and two record elements:

<marc:collection xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd">
  <marc:record type="Bibliographic">
    ...
  </marc:record>
  <marc:record type="Holdings">
    ...
  </marc:record>
</marc:collection>

But others lack a wrapper collection and have only a single record element, which also lacks a namespace declaration, like so:

<marc:record type="Bibliographic">
    ...
</marc:record>


So, I run the following query (using the DBA query interface):

declare namespace marc = "http://www.loc.gov/MARC21/slim";

let $m := collection("marc-data")/marc:record[@type = "Bibliographic"]
return count($m)


And the count returns 0. However, if I change the predicate in the let clause to:

let $m := collection("marc-data")/*[local-name() = "record"][@type = "Bibliographic"]

the count returns 45.

If I am declaring the namespace in my query prolog and associating it with the same prefix as the one used in my XML documents, why don't I get the desired prefix/namespace mapping? I'm probably missing something basic, but this didn't immediately make sense to me.

Thank you,
Tim


--
Tim A. Thompson
Metadata Librarian (Spanish/Portuguese Specialty)
Princeton University Library