Changeset 37138


Ignore:
Timestamp:
2023-01-15T00:56:33+13:00 (13 days ago)
Author:
davidb
Message:

Generic sparql.xsl that will work when added in to a collection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/apache-jena/trunk/src/transform/pages/sparql.xsl

    r37135 r37138  
    1414
    1515    <xsl:variable name="groupPath"><xsl:value-of select="/page/pageRequest/paramList/param[@name='group']/@value"/></xsl:variable>
     16
     17    <xsl:variable name="siteURL"><xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'siteURL']" /></xsl:variable>
     18    <xsl:variable name="sparqlEndpointProtocol">http</xsl:variable>
     19
     20    <xsl:variable name="fuseki3ServletProtocol">
     21      <xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'fuseki3_servlet_protocol']/@value"/>
     22    </xsl:variable>
     23    <xsl:variable name="fuseki3ServletDomain">
     24      <xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'fuseki3_servlet_domain']/@value"/>
     25    </xsl:variable>
     26    <xsl:variable name="fuseki3ServletOptPort">
     27      <xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'fuseki3_servlet_opt_port']/@value"/>
     28    </xsl:variable>
     29    <xsl:variable name="fuseki3ServletContext">
     30      <xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'fuseki3_servlet_context']/@value"/>
     31    </xsl:variable>
     32 
     33
     34   
     35    <!-- Apache Jena Fuseki v3 -->
     36
     37    <!--
     38        <xsl:variable name="sparqlEndpointHostAndOptPort">localhost:4040</xsl:variable>
     39        <xsl:variable name="sparqlGraphBasePrefix">http://localhost:8383</xsl:variable>
     40
     41        <xsl:variable name="sparqlEndpointPrefix1"></xsl:variable>
     42        <xsl:variable name="sparqlEndpointPrefix3"></xsl:variable>
     43        <xsl:variable name="sparqlEndpoint3">http://localhost:4040</xsl:variable>
     44       
     45        <xsl:variable name="graphURI"><xsl:value-of select="$sparqlGraphBasePrefix"/><xsl:value-of select="$siteURL"/><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$collName"/></xsl:variable>
     46    -->
     47
     48    <!--
     49    <xsl:variable name="sparqlEndpointHostAndOptPort">intermuse.sowemustthink.space</xsl:variable>
     50    <xsl:variable name="sparqlGraphBasePrefix">https://intermuse.so-we-must-think.space</xsl:variable> < ! - - FULL_GREENSTONE_URL_PREFIX marker --> <!-- This marker can only appear ONCE in file, as it is processed by sed - - >
     51
     52    <xsl:variable name="sparqlEndpointPrefix1">/greenstone3-lod</xsl:variable>
     53    <xsl:variable name="sparqlEndpointPrefix3">/greenstone3-lod3</xsl:variable>
     54    <xsl:variable name="sparqlEndpoint3">https://intermuse.sowemustthink.space/greenstone3-lod3</xsl:variable>
     55
     56    <xsl:variable name="graphURI"><xsl:value-of select="$sparqlGraphBasePrefix"/><xsl:value-of select="$siteURL"/><xsl:value-of select="$site_name"/>-library/collection/<xsl:value-of select="$collName"/></xsl:variable>
     57    -->
     58
     59
     60    <xsl:variable name="sparqlEndpointHostAndOptPort"><xsl:value-of select="$fuseki3ServletDomain"/><xsl:if test="$fuseki3ServletOptPort != ''">:<xsl:value-of select="$fuseki3ServletOptPort"/></xsl:if></xsl:variable>
     61    <xsl:variable name="sparqlGraphBasePrefix"><xsl:value-of select="$fuseki3ServletProtocol"/>://<xsl:value-of select="$fuseki3ServletDomain"/></xsl:variable>
     62    <xsl:variable name="sparqlEndpointPrefix3"><xsl:value-of select="$fuseki3ServletContext"/></xsl:variable>
     63    <xsl:variable name="sparqlEndpoint3"><xsl:value-of select="$fuseki3ServletProtocol"/>://<xsl:value-of select="$fuseki3ServletDomain"/><xsl:value-of select="$sparqlEndpointPrefix3"/></xsl:variable>
     64
     65    <xsl:variable name="graphURI"><xsl:value-of select="$sparqlGraphBasePrefix"/><xsl:value-of select="$siteURL"/>/<xsl:value-of select="$servletContext"/>/<xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$collName"/></xsl:variable>
     66
     67   
     68   
    1669    <!-- set page title -->
    1770    <xsl:template name="pageTitle">SPARQL Query</xsl:template>
    18 
     71   
    1972    <!-- set page breadcrumbs -->
    2073    <xsl:template name="breadcrumbs"><gslib:siteLink/><gslib:rightArrow/>
     
    50103
    51104        <p>
    52           Using this page you can query the linked-data in the Greenstone3 <i>eurovision</i> triplestore
    53           graph using <a href="https://en.wikipedia.org/wiki/SPARQL">SPARQL</a> query syntax.
    54           The default query provided in the text box below is effectively issuing a query that
    55           returns everything stored (a bit like matching with the wildcard '*' that some text-based search
    56           systems have), limited to show just the first 500 entries that matched.
     105          Using this page you can query the linked-data in the
     106          Greenstone3 triplestore graph using
     107          <a href="https://en.wikipedia.org/wiki/SPARQL">SPARQL</a>
     108          query syntax.  The default query provided in the text
     109          box below is effectively issuing a query that returns
     110          everything stored (a bit like matching with the wildcard
     111          '*' that some text-based search systems have), limited
     112          to show just the first 500 entries that matched.
    57113        </p>
    58114       
     
    85141          <li>
    86142            <!-- endpoint -->
    87             <a href="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/greenstone/data" download="greenstone3-eurovision-lod.trig">Full Export in TriG Syntax</a>
     143            <a href="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/greenstone/data" download="greenstone3-{$collNameChecked}-lod.trig">Full Export in TriG Syntax</a>
    88144
    89145          </li>
    90146          <li>
    91147            <!-- endpoint -->
    92             <a href="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/greenstone/data" download="greenstone3-eurovision-lod.ttl">Full Export in Turtle Syntax</a>
    93 //{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/greenstone/data                       
     148            <a href="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/greenstone/data" download="greenstone3-{$collNameChecked}-lod.ttl">Full Export in Turtle Syntax</a>
     149            <!--
     150            //{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/greenstone/data                       
     151            -->
    94152          </li>
    95153        </ul>
     
    136194</xsl:text>
    137195          </textarea>
    138          
    139196          <div style="display:none;">
    140197        <div>
     
    154211            <option value=""></option>
    155212            <!-- endpoint -->
    156             <option value="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix1}/xml-to-html.xsl">xml-to-html</option>
    157             <option value="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix1}/xml-to-html-links.xsl" selected="selected">xml-to-html-links</option>
    158             <option value="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix1}/xml-to-html-plain.xsl">xml-to-html-plain</option>
     213            <option value="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/xml-to-html.xsl">xml-to-html</option>
     214            <option value="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/xml-to-html-links.xsl" selected="selected">xml-to-html-links</option>
     215            <option value="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/xml-to-html-plain.xsl">xml-to-html-plain</option>
    159216          </select>
    160217        </div>
     
    173230      </div>
    174231
    175       <div>
    176         <h2>Sample Queries</h2>
    177 
    178         <p>
    179           The sample queries provided below gradually increase in
    180           the query syntax complexity used.  They are intended
    181           primarily for illustrative purposes, to introduce a user
    182           unfamiliar to various aspects of SPARQL query syntax.
    183           Click on one of the <i>Load query above</i> buttons to load
    184           the relevant query syntax into the SPARQL Query textbox
    185           above, then press <i>Get Results</i> to initiate the
    186           query.
    187         </p>
    188          
    189         <div id="ssq-restrict-year" style="display: none;">
    190 <!-- -->
    191 <xsl:text>
    192 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    193 
    194 SELECT ?subject ?predicate ?object WHERE {
    195   GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    196     ?subject ?predicate ?object.
    197     ?subject gsdlextracted:Year "2000".   
    198   }
    199 }
    200 OFFSET 0 LIMIT 200
    201 </xsl:text>
    202         </div>
    203 
    204         <div id="ssq-restrict-year-then-filter" style="display: none;">
    205 <!-- -->
    206 <xsl:text>
    207 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    208 
    209 SELECT ?subject ?predicate ?object WHERE {
    210   GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    211     ?subject ?predicate ?object.
    212     ?subject gsdlextracted:Year "2000".   
    213 
    214     # The following removes a triple that stores JSON data that
    215     # is voluminous but not very interesting to look at
    216     FILTER (?predicate != gsdlextracted:JSON).
    217   }
    218 }
    219 OFFSET 0 LIMIT 200
    220 </xsl:text>
    221         </div>
    222        
    223 
    224         <div id="ssq-restrict-country-and-year" style="display: none;">
    225 <!-- -->
    226 <xsl:text>
    227 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    228 PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
    229  
    230 SELECT ?subject ?predicate ?object WHERE {
    231   GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    232     ?subject ?predicate ?object
    233 
    234     # The following removes a triple that stores JSON data that
    235     # is voluminous but not very interesting to look at
    236     FILTER (?predicate != gsdlextracted:JSON).
    237 
    238     ?subject gsdlextracted:Year ?year.
    239     ?subject gsdlextracted:Country ?country.   
    240     FILTER (?country = "France").
    241     FILTER (xsd:integer(?year) >= 1996 &amp;&amp; xsd:integer(?year) &lt;= 2000).
    242 
    243   }
    244 }
    245 OFFSET 0 LIMIT 200
    246 </xsl:text>
    247         </div>
    248 
    249 
    250        
    251         <div id="ssq-esc-entrants" style="display: none;">
    252 <!-- -->
    253 <xsl:text>
    254 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    255 PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
    256 PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
    257 
    258 SELECT ?esc_entrant_uri ?country ?year WHERE {
    259   GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    260     ?esc_entrant_uri dc:Relation.isPartOf &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;.
    261 
    262     ?esc_entrant_uri gsdlextracted:Year ?year.
    263     ?esc_entrant_uri gsdlextracted:Country ?country.   
    264   }
    265 }
    266 ORDER BY ASC(?year) ?country
    267 </xsl:text>
    268         </div>
    269 
    270         <div id="ssq-esc-entrants-with-key" style="display: none;">
    271 <!-- -->
    272 <xsl:text>
    273 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    274 PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
    275 PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
    276 PREFIX essentia: &lt;http://upf.edu/essentia#&gt;
    277 
    278 SELECT ?esc_entrant_uri ?country ?year ?musical_key ?scale ?strength_estimate WHERE {
    279   GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    280     ?esc_entrant_uri dc:Relation.isPartOf &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;.
    281 
    282     ?esc_entrant_uri gsdlextracted:Year ?year.
    283     ?esc_entrant_uri gsdlextracted:Country ?country.
    284     ?esc_entrant_uri essentia:tonal_key_edma_key ?musical_key.
    285     ?esc_entrant_uri essentia:tonal_key_edma_scale ?scale.
    286     ?esc_entrant_uri essentia:tonal_key_edma_strength ?strength_estimate.
    287   }
    288 }
    289 ORDER BY ASC(?year) ?country
    290 </xsl:text>
    291         </div>
    292        
    293 
    294         <div id="ssq-esc-winners-freq-count-scale" style="display: none;">
    295 <!-- -->
    296 <xsl:text>
    297 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    298 PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
    299 PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
    300 PREFIX essentia: &lt;http://upf.edu/essentia#&gt;
    301 
    302 
    303 SELECT ?scale (STR(COUNT(?scale)) as ?number_in_scale) WHERE {
    304 #SELECT ?scale ?country ?year WHERE {
    305   GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    306      
    307     ?esc_entrant_uri gsdlextracted:Place "1".
    308     # ?esc_entrant_uri essentia:tonal_key_edma_key ?musical_key.
    309     ?esc_entrant_uri essentia:tonal_key_edma_scale ?scale.
    310 
    311     ?esc_entrant_uri gsdlextracted:Year ?year.
    312     ?esc_entrant_uri gsdlextracted:Country ?country.   
    313   }
    314 }
    315 GROUP BY ?scale
    316 ORDER BY DESC(?number_in_scale)
    317 </xsl:text>
    318         </div>
    319 
    320        
    321         <div id="ssq-jury-votes-totals-1975" style="display: none;">
    322 <!-- -->
    323 <xsl:text>
    324 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    325 PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
    326 PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
    327 
    328 SELECT ?country ?year ?total WHERE {
    329   GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    330     ?esc_entrant_uri dc:Relation.isPartOf &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;.
    331 
    332     ?esc_entrant_uri gsdlextracted:SingVotesTotal ?total.
    333     BIND(xsd:integer(?total) AS ?total_int).
    334    
    335     ?esc_entrant_uri gsdlextracted:Year ?year
    336       FILTER(xsd:integer(?year) = 1975).
    337     ?esc_entrant_uri gsdlextracted:Country ?country.   
    338   }
    339 }
    340 ORDER BY DESC(?total_int)
    341 </xsl:text>
    342         </div>
    343 
    344        
    345         <div id="ssq-jury-votes-1975" style="display: none;">
    346 <!-- -->
    347 <xsl:text>
    348 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    349 PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
    350 PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
    351 
    352 SELECT ?country ?year ?jury_country ?jury_vote WHERE {
    353   GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    354     ?esc_entrant_uri dc:Relation.isPartOf &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;.
    355 
    356     ?esc_entrant_uri ?gsdlextracted_jury_country_uri ?jury_vote.
    357     BIND(STRENDS(str(?gsdlextracted_jury_country_uri),"-J") AS ?is_jury_vote)
    358     FILTER (?is_jury_vote).
    359     BIND(REPLACE(str(?gsdlextracted_jury_country_uri), ".*#(.*?)-J$", "$1") AS ?jury_country).
    360 
    361     ?esc_entrant_uri gsdlextracted:Year ?year
    362       FILTER(xsd:integer(?year) = 1975).
    363     ?esc_entrant_uri gsdlextracted:Country ?country.
    364 
    365      
    366   }
    367 }
    368 ORDER BY ASC(?year) ?country 
    369 </xsl:text>
    370         </div>
    371 
    372 
    373         <div id="ssq-winning-totals" style="display: none;">
    374 <!-- -->
    375 <xsl:text>
    376 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    377 PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
    378 PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
    379 
    380 SELECT ?year ?country ?total_max WHERE {
    381   GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    382 
    383     {
    384       SELECT ?year (STR(MAX(?total_int_inner)) as ?total_max) WHERE {
    385      
    386         ?esc_entrant_uri gsdlextracted:VoteGrandTotal ?total.
    387         BIND(xsd:integer(?total) AS ?total_int_inner).
    388    
    389         ?esc_entrant_uri gsdlextracted:Year ?year.
    390       }
    391       GROUP BY ?year
    392      }
    393 
    394     ?esc_entrant_uri gsdlextracted:VoteGrandTotal ?total_max.   
    395     ?esc_entrant_uri gsdlextracted:Year ?year.
    396     ?esc_entrant_uri gsdlextracted:Country ?country.
    397 
    398     BIND(xsd:integer(?total_max) as ?total_int).   
    399   }
    400 }
    401 ORDER BY DESC(?total_int)
    402 </xsl:text>
    403         </div>
    404 
    405 
    406         <div id="ssq-winning-freq-count" style="display: none;">
    407 <!-- -->
    408 <xsl:text>
    409 
    410 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    411 PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
    412 PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
    413 
    414 
    415 SELECT ?country (STR(COUNT(?country)) as ?number_of_vote_wins) WHERE {
    416   GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    417     {
    418       SELECT ?year (STR(MAX(?total_int)) as ?total_max) WHERE {     
    419         ?esc_entrant_uri gsdlextracted:VoteGrandTotal ?total.
    420         BIND(xsd:integer(?total) AS ?total_int).
    421    
    422         ?esc_entrant_uri gsdlextracted:Year ?year.
    423       }
    424       GROUP BY ?year
    425     }
    426 
    427     ?esc_entrant_uri gsdlextracted:VoteGrandTotal ?total_max.   
    428     ?esc_entrant_uri gsdlextracted:Year ?year.
    429     ?esc_entrant_uri gsdlextracted:Country ?country.   
    430   }
    431 }
    432 GROUP BY ?country
    433 ORDER BY DESC(?number_of_vote_wins)
    434 </xsl:text>
    435         </div>
    436 
    437 
    438 
    439         <div id="ssq-from-winning-to-losing" style="display: none;">
    440 <!-- -->
    441 <xsl:text>
    442        
    443 PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
    444 PREFIX xsd:  &lt;http://www.w3.org/2001/XMLSchema#&gt;
    445 PREFIX dc:   &lt;http://purl.org/dc/elements/1.1/&gt;
    446 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    447 
    448 SELECT (?country as ?Country) (?year AS ?WinningYear) (?total as ?WinningGrandTotal) (?next_year AS ?LosingYear) (?next_total as ?LosingGrandTotal)         
    449 WHERE {
    450     GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt;  {
    451         ?esc_entrant_uri gsdlextracted:Country ?country.
    452         ?esc_entrant_uri gsdlextracted:VoteGrandTotal ?total.
    453 
    454     ?esc_entrant_uri gsdlextracted:Place ?place.
    455         BIND(xsd:integer(?place) AS ?place_int).   
    456     FILTER(?place_int = 1).
    457 
    458     ?esc_entrant_uri gsdlextracted:Year ?year.
    459     BIND(xsd:integer(?year) AS ?year_int).
    460     BIND(?year_int + 1 AS ?next_year_int).
    461     BIND(str(?next_year_int) AS ?next_year).
    462 
    463         ?next_esc_entrant_uri gsdlextracted:Country ?country.
    464     ?next_esc_entrant_uri gsdlextracted:Year ?next_year.
    465    
    466         ?next_esc_entrant_uri gsdlextracted:VoteGrandTotal ?next_total.
    467 
    468         ?next_esc_entrant_uri gsdlextracted:ReverseFinishingPos ?rev_finishing_pos.
    469         BIND(xsd:integer(?rev_finishing_pos) AS ?rev_finishing_pos_int).
    470         FILTER(?rev_finishing_pos_int = 1).
    471    
    472    
    473    }
    474 }
    475 ORDER BY ?country
    476 </xsl:text>
    477         </div>
    478 
    479         <div id="ssq-country-info" style="display: none;">
    480 <!--
    481   Adapted from:
    482      https://stackoverflow.com/questions/40069644/retrieve-information-about-all-european-countries
    483 -->
    484 <xsl:text>
    485 
    486 PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
    487 
    488 PREFIX  dbo:  &lt;http://dbpedia.org/ontology/&gt;
    489 PREFIX  dbp:  &lt;http://dbpedia.org/property/&gt;
    490 PREFIX  dct:  &lt;http://purl.org/dc/terms/&gt;
    491 #PREFIX  geo:  &lt;http://www.opengis.net/ont/geosparql#&gt;
    492 
    493 PREFIX geo: &lt;http://www.w3.org/2003/01/geo/wgs84_pos#&gt;
    494 
    495 SELECT DISTINCT ?country_uri ?capital ?area ?populationTotal ?lat ?long
    496      ?currency ?gdpPppPerCapita ?giniCoefficient WHERE {
    497 
    498   SERVICE &lt;https://dbpedia.org/sparql&gt; {
    499 
    500     ?db_country_uri dbo:capital ?db_capital.
    501 
    502     BIND(?db_country_uri AS ?country_uri).
    503     BIND(str(?db_country_uri) AS ?country_uri_str).
    504     BIND(?db_capital AS ?capital).
    505 
    506 #    OPTIONAL {
    507 #      ?country_uri dbp:areaKm          ?area.         
    508 #      ?country_uri dbo:populationTotal ?populationTotal.
    509 #      ?country_uri geo:lat             ?lat.           
    510 #      ?country_uri geo:long            ?long.
    511 #    }
    512 
    513     OPTIONAL { ?country_uri dbp:areaKm          ?area.            }
    514     OPTIONAL { ?country_uri dbo:populationTotal ?populationTotal. }
    515     OPTIONAL { ?capital     geo:lat             ?lat.             }
    516     OPTIONAL { ?capital     geo:long            ?long.            }
    517    
    518     OPTIONAL { ?country_uri dbp:currencyCode    ?currency.        }
    519     OPTIONAL { ?country_uri dbp:gdpPppPerCapita ?gdpPppPerCapita.  }
    520 
    521     OPTIONAL { ?country_uri dbo:giniCoefficient ?giniCoefficient. }
    522   }
    523 
    524   ?esc_entrant_uri gsdlextracted:CountryDBURI ?country_uri_str.
    525 
    526 }
    527 ORDER BY ASC(?country_uri) 
    528 </xsl:text>
    529         </div>
    530 
    531      
    532        
    533         <ul class="ssq">
    534           <li>
    535         <b>Year Restricted (raw data rows):</b><br />
    536         <button type="button" class="load-ssq" id="load-ssq-restrict-year" onclick="ssq_load('ssq-restrict-year')">Load query above</button>
    537         <button type="button" class="exec-ssq" id="exec-ssq-restrict-year" onclick="ssq_execute()">Get Results</button><br />
    538         <p>Similar to the default query (all results returned) but restricted to entries associated with the year 2000.</p>
    539           </li>
    540 
    541           <div id="raw-sparql-show-more" class="showmore">
    542         <style>
    543           #showmore-button-raw-sparql-show-more { width: 260px; }
    544         </style>
    545        
    546         <li>
    547           <b>Year Restricted (raw data rows) then filter out <i>gsdlextracted:JSON</i> entries:</b><br/>
    548           <button type="button" class="load-ssq" id="load-ssq-restrict-year-then-filter" onclick="ssq_load('ssq-restrict-year-then-filter')">Load query above</button>
    549           <button type="button" class="exec-ssq" id="exec-ssq-restrict-year-then-filter" onclick="ssq_execute()">Get Results</button><br/>
    550           <p>
    551             Similar to the previous query (restricted to results from 2000) but filtering out the voluminous, but not very interesting to look at,
    552             <i>gsdlextracted:JSON</i>.
    553           </p>
    554           <p>
    555             This field is formed by Greenstone at ingest-time: it represents all the metadata fields for a particular country
    556             stored in the JSON format.  It is a handy item for the Greenstone3 runtime-system to access, but in the context of viewing the output
    557             of SPARQL queries at HTML only serves to pollute the generated result set with large text items.
    558           </p>
    559         </li>
    560        
    561         <li>
    562           <b>Country and Year Restricted (raw data rows):</b><br/>
    563           <button type="button" class="load-ssq" id="load-ssq-restrict-country-and-year" onclick="ssq_load('ssq-restrict-country-and-year')">Load query above</button>
    564           <button type="button" class="exec-ssq" id="exec-ssq-restrict-country-and-year" onclick="ssq_execute()">Get Results</button><br/>
    565          
    566           <p>Similar to the previous query, but restricted to entries about the country France, in the years 1996-2000.</p>
    567         </li>
    568           </div>
    569           <gsf:script>
    570         $('#raw-sparql-show-more').showMore({
    571               minheight: 0,
    572           buttontxtmore:"show further raw-data queries ...",
    573           buttontxtless:"... show less"
    574             });
    575           </gsf:script>     
    576 
    577           <li>
    578         <b>Eurovision Song Contest (ESC) entrants:</b><br/>
    579         <button type="button" class="load-ssq" id="load-ssq-esc-entrants" onclick="ssq_load('ssq-esc-entrants')">Load query above</button>
    580         <button type="button" class="exec-ssq" id="exec-ssq-esc-entrants" onclick="ssq_execute()">Get Results</button><br/>
    581        
    582         <p>List all the entrants (country and year) sorted by year, then by country.</p>
    583           </li>
    584 
    585           <li>
    586         <b>Eurovision Song Contest (ESC) entrants with (estimated) musical key:</b><br/>
    587         <button type="button" class="load-ssq" id="load-ssq-esc-entrants-with-key" onclick="ssq_load('ssq-esc-entrants-with-key')">Load query above</button>
    588         <button type="button" class="exec-ssq" id="exec-ssq-esc-entrants-with-key" onclick="ssq_execute()">Get Results</button><br/>
    589        
    590         <p>
    591           Similar to the above query that list all the entrants (country and year) sorted by year, then by country, but also displays
    592           the estimated key signature of the song, which is pre-computed using the Essentia audio content analysis toolkit
    593           when the collection is built.
    594         </p>
    595           </li>
    596 
    597           <li>
    598         <b>Musical scale comparison of winning entries:</b><br/>
    599         <button type="button" class="load-ssq" id="load-ssq-esc-winners-freq-count-scale" onclick="ssq_load('ssq-esc-winners-freq-count-scale')">Load query above</button>
    600         <button type="button" class="exec-ssq" id="exec-ssq-esc-winners-freq-count-scale" onclick="ssq_execute()">Get Results</button><br/>
    601        
    602         <p>
    603           Frequency count of the scale (major or minor) that
    604           winning songs were in.  The estimated musical scale
    605           of the song is an estimate, pre-computed using the
    606           Essentia audio content analysis toolkit when the
    607           collection is built.
    608         </p>
    609           </li>
    610 
    611                  
    612           <li>
    613         <b>Voting Totals in 1975:</b><br/>
    614         <button type="button" class="load-ssq" id="load-ssq-jury-votes-totals-1975" onclick="ssq_load('ssq-jury-votes-totals-1975')">Load query above</button>
    615         <button type="button" class="exec-ssq" id="exec-ssq-jury-votes-totals-1975" onclick="ssq_execute()">Get Results</button><br/>
    616        
    617         <p>In 1975 all voting was done exclusively by jury.  This query retrieves the
    618         totals of this Single voting format, and orders them by that score.</p>
    619           </li>
    620 
    621            
    622          
    623           <li>
    624         <b>Jury Votes Cast by Country in 1975:</b><br/>
    625         <button type="button" class="load-ssq" id="load-ssq-jury-votes-1975" onclick="ssq_load('ssq-jury-votes-1975')">Load query above</button>
    626         <button type="button" class="exec-ssq" id="exec-ssq-jury-votes-1975" onclick="ssq_execute()">Get Results</button><br/>
    627        
    628         <p>List all votes case in the 1975 competition.</p>
    629           </li>
    630 
    631 
    632           <li>
    633         <b>Most points won:</b><br/>
    634         <button type="button" class="load-ssq" id="load-ssq-winning-totals" onclick="ssq_load('ssq-winning-totals')">Load query above</button>
    635         <button type="button" class="exec-ssq" id="exec-ssq-winning-totals" onclick="ssq_execute()">Get Results</button><br/>
    636        
    637         <p>List the countries which won and their voting totals, sorted by total score.</p>
    638           </li>
    639 
    640           <li>
    641         <b>Number of Times Countries Have Won:</b><br/>
    642         <button type="button" class="load-ssq" id="load-ssq-winning-freq-count" onclick="ssq_load('ssq-winning-freq-count')">Load query above</button>
    643         <button type="button" class="exec-ssq" id="exec-ssq-winning-freq-count" onclick="ssq_execute()">Get Results</button><br/>
    644 
    645         <p>
    646           The number of times a country has won Eurovision
    647           across the years.  The includes the years when only
    648           Juries voted (1956-2000) through to the introduction
    649           of Televotes, where a variety of forms have been
    650           used such as only Televotes, a pre-combined score
    651           based on Televotes and Jury votes, to (from 2016
    652           onwards) where the Jury and Tele votes are
    653           explicitly given individually per country, then
    654           combined.
    655  
    656         </p>
    657         <p>
    658           This query works off the Voting Totals countries
    659           received, and so if you run the query you'll see
    660           that it computes (as of 2021) that France has won 6
    661           times, when the official record puts this at 5 for
    662           France.  This is due to a tie that occurred between
    663           Sweeden and France in the 1991 final, and how it was
    664           resolved.  From <a target="_blank"
    665           href="https://en.wikipedia.org/wiki/France_in_the_Eurovision_Song_Contest_1991"
    666           hrefXXXX="https://en.wikipedia.org/wiki/Le_Dernier_qui_a_parl%C3%A9...">Wikipedia</a>:
    667           “After the four-way tie at the 1969 contest, a
    668           tie-break system had been implemented, where a
    669           count-back on the number of top points awarded was
    670           used. Since both countries received four 12-points,
    671           but Sweden gaining five 10-points over France's two,
    672           Sweden was declared the winner with France coming
    673           second.” 
    674          
    675          
    676         </p>
    677           </li>
    678 
    679 
    680 
    681           <li>
    682         <b>From Hero to Zero!</b><br/>
    683         <button type="button" class="load-ssq" id="load-ssq-from-winning-to-losing" onclick="ssq_load('ssq-from-winning-to-losing')">Load query above</button>
    684         <button type="button" class="exec-ssq" id="exec-ssq-from-winning-to-losing" onclick="ssq_execute()">Get Results</button><br/>
    685 
    686         <p>
    687           List countries where, having won in one year, they
    688           have gone on to lose with the lowest score of the
    689           contest the following year.  Note this definition
    690           doesn't quite meet the given heading of <i>From Here
    691           to Zero</i>. There is in fact only one country, to
    692           date, where this has happened (nul-point the
    693           following year).  View the table to see who it is
    694           ...  then why not test out your SPARQL querying
    695           skills and see if you can modify the query used so
    696           it only returns the Hero to Zero case?
    697         </p>
    698           </li>
    699 
    700           <li>
    701         <b>Facts and Figures About Competing Countries:</b><br/>
    702         <button type="button" class="load-ssq" id="load-ssq-country-info" onclick="ssq_load('ssq-country-info')">Load query above</button>
    703         <button type="button" class="exec-ssq" id="exec-ssq-country-info" onclick="ssq_execute()">Get Results</button><br/>
    704        
    705         <p>
    706           Demographics about other related information about the countries the song contest entries are from.
    707           Query takes a bit longer to run than the previous ones.
    708         </p>
    709           </li>
    710          
    711         </ul>
    712 
    713         <p>
    714           Looking for something a bit more visual?  Why not head over to our
    715           <a href="{$library_name}/collection/{$collName}/page/sgvizler"><i>SGVizler page</i></a> and try the SPARQL-based visualization samples there.
    716         </p>
    717        
    718       </div>
     232
    719233    </xsl:template>
    720234   
Note: See TracChangeset for help on using the changeset viewer.