text() in XQuery
Thursday, 22 January 2015 · 2 messages
CG
Hi Ana,
Quoted text · Ana Victória Ladeira · 1 line
> Sorry for bothering and thank you for the attention.
You are welcome. Your need to declare the default namespace in order to get results:
declare namespace v3 ="http://www.loc.gov/mods/v3";
for $doc in collection('ExemploBibtex')
where matches(document-uri($doc), 'quantuminformation.xml')
return $doc/v3:modsCollection/v3:mods/v3:titleInfo/v3:title/text()You can also use wildcards, and you can specify the filename in the argument of the collection() function:
for $doc in collection('ExemploBibtex/quantuminformation.xml')
return $doc/*:modsCollection/*:mods/*:titleInfo/*:title/text()Hope this helps,
Christian
AL
Ana Victória Ladeira22 Jan 2015 20:24 #
Hi!
I'm relatively new to BaseX/XQuery and currently using a XML with the following format:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<modsCollection xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd
">
<mods ID="ISI:000330282600027" version="3.0">
<titleInfo>
<title>Minimum Relative Entropy for Quantum Estimation: Feasibility and
General
Solution</title>
</titleInfo>The file is called "quantuminformation.xml", inside the DB "ExemploBibtex"
I'm trying to extract the titles of all articles in the document, using the following query:
for $doc in collection('ExemploBibtex')
where matches(document-uri($doc), 'quantuminformation.xml')
return $doc/modsCollection/mods/titleInfo/title/text()It doesn't matter if I use the text() or
fn:string, the result is always empty.
What am I doing wrong?
Sorry for bothering and thank you for the attention.Written for BaseX 7.9. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery