Hi Charles,
If you're just looking to filter results by a known filename, you can do that right on the results of db:open() or collection(), followed by the rest of your XPath and filters.
for $myElement in db:open('myDB')[db:path(.)='myFile1.xml']/myRoot[@PMID='1234']/myElement return $myElement/text()
-Tamara
On Wed, May 18, 2022 at 2:09 PM Graydon graydonish@gmail.com wrote:
On Wed, May 18, 2022 at 02:23:54PM -0500, Charles Bearden scripsit:
Is there a way in XQuery I can identify a record in this database not
only
by its PubMed ID but also limit the result set by source document name? I know that `db:path($elem)` gives me the document name for an element,
but I
want to use the document name to help pick out the element from among several that may share its PMID.
db:path($elem)[local:test-function(.)]
is the usual pattern for this, but it sounds like you're really trying to index into this mass of records.
That makes me think of a map with a composite key -- concat($PMIDval,$db:path($elem)) -- and doing updates via map:merge. If the value for the individual map entry is the result of a path expression, you should get what amounts to a pointer to the node in the db, making this approach fast for retrieval.
That's not as good as a way to get a custom index the uses the document-uri() property of the document nodes (or possibly file:name() on the document-uri() property), but someone else certainly knows more about the feasability of that appraoch than I do.
-- Graydon Saunders | graydonish@gmail.com Þæs oferéode, ðisses swá mæg. -- Deor ("That passed, so may this.")