<commit_before><?xml version="1.0"?>

<!--    This file contains example queries for the web interface
        (see webapp/xquery/xquery.xq
-->
<example-queries>
    <query>
        <description>Simple fulltext query on Shakespeare plays</description>
        <code><![CDATA[for $speech in //SPEECH[LINE &= 'love']
return $speech]]></code>
    </query>
    <query>
        <description>Fulltext query using near</description>
        <code><![CDATA[for $speech in //SPEECH[SPEAKER &= 'witch' and near(., 'fenny snake')]
return $speech]]></code>
    </query>
    <query>
        <description>Show the context of a match</description>
        <code><![CDATA[for $speech in //SPEECH[near(LINE, 'to be or not')]
let $scene := $speech/ancestor::SCENE,
    $act := $scene/ancestor::ACT,
    $play := $scene/ancestor::PLAY
    return
        <hit>
            <play title="{$play/TITLE}">
                <act title="{$act/TITLE}">
                    <scene title="{$scene/TITLE}">{$speech}</scene>
                </act>
            </play>
        </hit>]]></code>
    </query>
    <query>
        <description>Group hits by play</description>
        <code><![CDATA[let $speech := //SPEECH[LINE &= "passion*"]
let $plays := (for $s in $speech return root($s))
for $play in $plays/PLAY
let $hits := $play//$speech
return
	<play title="{$play/TITLE}" hits="{count($hits)}">
		{$hits}
	</play>]]></code>
    </query>
    <query>
        <description>Show table of contents for Macbeth</description>
        <code><![CDATA[
<toc>{
    for $act in doc("/db/shakespeare/plays/macbeth.xml")/PLAY/ACT
    return
        <act>
            {$act/TITLE}
            {
                for $scene in $act/SCENE return
                    <scene>
                        {$scene/TITLE}
                        <actors>
                        {
                            for $speaker in distinct-values($scene//SPEAKER)
                            order by $speaker return
                                <actor>{$speaker}</actor>
                        }
                        </actors>
                    </scene>
            }
        </act>
}</toc>]]></code>
    </query>
    <query>
            <description>Find books by author</description>
            <code><![CDATA[xquery version "1.0";
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
declare namespace dc="http://purl.org/dc/elements/1.1/";

for $p in distinct-values(doc('/db/library/biblio.rdf')//dc:creator)
let $books := //rdf:Description[dc:creator&=$p]
return
        <result>
                <creator titles="{count($books)}">{$p}</creator>
                {for $b in $books return $b/dc:title}
        </result>]]></code>
    </query>
    <query>
    	<description>Find a city by name</description>
	<code><![CDATA[
(:  This script accesses the mondial database, which can be
    found at http://dbis.informatik.uni-goettingen.de/Mondial/ :)
for $city in /mondial//city[name&='tre*']
return
	<result>
		{$city}
		<country>{$city/ancestor::country/name}</country>
		<province>{$city/ancestor::province/name}</province>
	</result>]]></code>
    </query>
	<query>
		<description>Show countries with decreasing population</description>
		<code><![CDATA[for $c in //country[population_growth < 0]
order by $c/name
return
<country>
  {$c/name, $c/population_growth}
</country>
]]></code>
	</query>
    <query>
    	<description>Find spanish provinces and their cities</description>
        <code><![CDATA[xquery version "1.0";
(:  This script accesses the mondial database, which can be
    found at http://dbis.informatik.uni-goettingen.de/Mondial/ :)

let $country := /mondial/country[name = 'Spain']
for $province in $country/province
order by $province/name
return
	<province>
		{$province/name}
		{
			for $city in $country//city[@province=$province/@id]
			order by $city/name
			return $city
		}
	</province>]]></code>
    </query>
    <query>
        <description>List all organizations Germany is a member of</description>
        <code><![CDATA[
    (:  This script accesses the mondial database, which can be
        found at http://dbis.informatik.uni-goettingen.de/Mondial/ :)
        id(/mondial/country[@car_code="D"]/@memberships)]]></code>
    </query>
    <query>
        <description>Countries having a common border with Austria</description>
        <code><![CDATA[id(/mondial/country[name = "Austria"]/border/@country)/name
        ]]></code>
    </query>
    <query>
        <description>For each country, list 3 cities with highest population</description>
        <code><![CDATA[(:  This script accesses the mondial database, which can be
    found at http://dbis.informatik.uni-goettingen.de/Mondial/ :)
for $country in /mondial/country
let $cities := 
    (for $city in $country//city[population] 
    order by xs:integer($city/population) descending 
    return $city)
order by $country/name
return
    <country name="{$country/name}">
    {
        $cities[1 to 3]<commit_msg>Fixed an invalid predicate expression in example query.<commit_after><?xml version="1.0"?>

<!--    This file contains example queries for the web interface
        (see webapp/xquery/xquery.xq
-->
<example-queries>
    <query>
        <description>Simple fulltext query on Shakespeare plays</description>
        <code><![CDATA[for $speech in //SPEECH[LINE &= 'love']
return $speech]]></code>
    </query>
    <query>
        <description>Fulltext query using near</description>
        <code><![CDATA[for $speech in //SPEECH[SPEAKER &= 'witch' and near(., 'fenny snake')]
return $speech]]></code>
    </query>
    <query>
        <description>Show the context of a match</description>
        <code><![CDATA[for $speech in //SPEECH[near(LINE, 'to be or not')]
let $scene := $speech/ancestor::SCENE,
    $act := $scene/ancestor::ACT,
    $play := $scene/ancestor::PLAY
    return
        <hit>
            <play title="{$play/TITLE}">
                <act title="{$act/TITLE}">
                    <scene title="{$scene/TITLE}">{$speech}</scene>
                </act>
            </play>
        </hit>]]></code>
    </query>
    <query>
        <description>Group hits by play</description>
        <code><![CDATA[let $speech := //SPEECH[LINE &= "passion*"]
let $plays := (for $s in $speech return root($s))
for $play in $plays/PLAY
let $hits := $play//$speech
return
	<play title="{$play/TITLE}" hits="{count($hits)}">
		{$hits}
	</play>]]></code>
    </query>
    <query>
        <description>Show table of contents for Macbeth</description>
        <code><![CDATA[
<toc>{
    for $act in doc("/db/shakespeare/plays/macbeth.xml")/PLAY/ACT
    return
        <act>
            {$act/TITLE}
            {
                for $scene in $act/SCENE return
                    <scene>
                        {$scene/TITLE}
                        <actors>
                        {
                            for $speaker in distinct-values($scene//SPEAKER)
                            order by $speaker return
                                <actor>{$speaker}</actor>
                        }
                        </actors>
                    </scene>
            }
        </act>
}</toc>]]></code>
    </query>
    <query>
            <description>Find books by author</description>
            <code><![CDATA[xquery version "1.0";
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
declare namespace dc="http://purl.org/dc/elements/1.1/";

for $p in distinct-values(doc('/db/library/biblio.rdf')//dc:creator)
let $books := //rdf:Description[dc:creator&=$p]
return
        <result>
                <creator titles="{count($books)}">{$p}</creator>
                {for $b in $books return $b/dc:title}
        </result>]]></code>
    </query>
    <query>
    	<description>Find a city by name</description>
	<code><![CDATA[
(:  This script accesses the mondial database, which can be
    found at http://dbis.informatik.uni-goettingen.de/Mondial/ :)
for $city in /mondial//city[name&='tre*']
return
	<result>
		{$city}
		<country>{$city/ancestor::country/name}</country>
		<province>{$city/ancestor::province/name}</province>
	</result>]]></code>
    </query>
	<query>
		<description>Show countries with decreasing population</description>
		<code><![CDATA[for $c in //country[population_growth < 0]
order by $c/name
return
<country>
  {$c/name, $c/population_growth}
</country>
]]></code>
	</query>
    <query>
    	<description>Find spanish provinces and their cities</description>
        <code><![CDATA[xquery version "1.0";
(:  This script accesses the mondial database, which can be
    found at http://dbis.informatik.uni-goettingen.de/Mondial/ :)

let $country := /mondial/country[name = 'Spain']
for $province in $country/province
order by $province/name
return
	<province>
		{$province/name}
		{
			for $city in $country//city[@province=$province/@id]
			order by $city/name
			return $city
		}
	</province>]]></code>
    </query>
    <query>
        <description>List all organizations Germany is a member of</description>
        <code><![CDATA[
    (:  This script accesses the mondial database, which can be
        found at http://dbis.informatik.uni-goettingen.de/Mondial/ :)
        id(/mondial/country[@car_code="D"]/@memberships)]]></code>
    </query>
    <query>
        <description>Countries having a common border with Austria</description>
        <code><![CDATA[id(/mondial/country[name = "Austria"]/border/@country)/name
        ]]></code>
    </query>
    <query>
        <description>For each country, list 3 cities with highest population</description>
        <code><![CDATA[(:  This script accesses the mondial database, which can be
    found at http://dbis.informatik.uni-goettingen.de/Mondial/ :)
for $country in /mondial/country
let $cities := 
    (for $city in $country//city[population] 
    order by xs:integer($city/population) descending 
    return $city)
order by $country/name
return
    <country name="{$country/name}">
    {
        subsequence($cities, 1, 3)
{'fraction_non_alphanumeric': 0.16315316215406134, 'fraction_numerical': 0.004196223398940953, 'mean_word_length': 2.4624697336561745, 'pattern_counts': {'":': 0, '<': 245, '<?xml version=': 2, '>': 241, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6160241', 'n_tokens_mistral': 3329, 'n_tokens_neox': 3118, 'n_words': 734}