Hi,

tested this some more. This

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT DISTINCT ?graph ?graphTitle1 ?graphTitle2
WHERE {
GRAPH ?graph
{
        OPTIONAL { ?graph dcterms:title ?graphTitle1}
        OPTIONAL { ?graph dc:title ?graphTitle2}
}}

returns same set as this

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT DISTINCT ?graph ?graphTitle1
WHERE {
GRAPH ?graph
{
        OPTIONAL { ?graph dcterms:title ?graphTitle1}
}}

and same set as this

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT DISTINCT ?graph ?graphTitle1
WHERE {
GRAPH ?graph
{
        ?graph dcterms:title ?graphTitle1
}}





This returns dc:title

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT DISTINCT ?graph ?graphTitle1
WHERE {
GRAPH ?graph
{
       OPTIONAL  { ?graph dc:title ?graphTitle1 }
}}

and this returns the same


PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT DISTINCT ?graph ?graphTitle1
WHERE {
GRAPH ?graph
{
       ?graph dc:title ?graphTitle1
}}


To get all graphs, only this works:

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT DISTINCT ?graph ?graphTitle1
WHERE {
GRAPH ?graph
{
}}


For testing I added a minimum graph

PREFIX dc:        <http://purl.org/dc/elements/1.1/>

INSERT DATA
{
  GRAPH <http://www.lingsoft.fi/tmp>
  {
       <http://www.lingsoft.fi/tmp> dc:title    "tmp title"
  }
}

and this behaves like the rest of graphs.

I'm using this db: apache-jena-fuseki-2.3.1

Br,
Mikael


On 29.5.2016 12:36, Andy Seaborne wrote:
On 27/05/16 14:23, Mikael Pesonen wrote:

Hi,

This query does what i want, that is, lists all graphs having the term
"digitalisaatio"@fi:

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?s ?graphTitle1  ?graphTitle2
WHERE {
GRAPH ?graph
{
         ?s skos:prefLabel "digitalisaatio"@fi

         OPTIONAL { ?graph dcterms:title ?graphTitle1 }
}}



But when I add new param
OPTIONAL { ?graph dc:title ?graphTitle2}

so that new query is this:
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?s ?graphTitle1  ?graphTitle2
WHERE {
GRAPH ?graph
{
         ?s skos:prefLabel "digitalisaatio"@fi

         OPTIONAL { ?graph dcterms:title ?graphTitle1 }
         OPTIONAL { ?graph dc:title ?graphTitle2}
}}

This will depend on your data model.

Do you have a complete, minimal example? (some small amount of data and a query that you expect to work).

I dont get all the graphs anymore. OPTIONAL should never filter out
data, just add? There must be a logical explanation, but I'm not getting
it. Im using Fuseki.

Which version?

    Andy

By the way:

OPTIONAL { ?graph (dcterms:title|dc:title) ?graphTitle1 }

asks for either dcterms:title or dc:title or both.


Br,
Mikael



--
www.lingsoft.fi

Speech Applications - Language Management - Translation - Reader's and Writer's 
Tools - Text Tools - E-books and M-books

Mikael Pesonen
System Engineer

e-mail: mikael.peso...@lingsoft.fi
Tel. +358 2 279 3300

Time zone: GMT+2

Helsinki Office
Eteläranta 10
FI-00130 Helsinki
FINLAND

Turku Office
Linnankatu 10 A
FI-20100 Turku
FINLAND

Reply via email to