Discussion:
Controlling the Output graph in CONSTRUCT query
Mahmood Ahmad
2016-11-04 11:33:16 UTC
Permalink
Hi,

Is there a way to control the output graph generated by the CONSTRUCT query? I know FILTER is one such option with NOT EXISTS.

The example output that I get in Apache Jena Fuseki 2.4.0 (used on Windows 10) is like below that I get in Turtle format:

"<http://www.xyz.com#UUID>"
skos:prefLabel "Preferred Label" ;
skos:broader "Broader entity";
a:aCode "Some Code" ;
a:aLevel "Some Level" ;
skos:narrower "Some narrower entity" .

If I don't like to have certain properties not to be displayed in the output graph, I tried to use NOT EXISTS in the FILTER option as follows:

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix a: <http://www.xyz.com/vocab#>

CONSTRUCT {
?snew skos:prefLabel ?pl ;
skos:broader ?b ;
a:aCode ?ac ;
?p ?o .
}
WHERE
{
?olds skos:prefLabel ?pl ;
skos:broader ?b ;
a:aCode ?ac ;
?p ?o .
BIND(CONCAT(CONCAT(STRBEFORE(STR(?olds), "#"), "#"), STRUUID()) AS ?snew) .
FILTER NOT EXISTS { ?snew a:aLevel ?le ;
?snew skos:narrower ?na ;
?p ?o . }
}

I have tried this with trying to exclude only one of the unwanted properties. I have also tried this with MINUS, without success. The output generated has no effect.

Any way out on this? I'll appreciate!

Regards
Mahmood

================================================
Dr Mahmood Ahmad
KTP Associate

School of Computer Science
University of Manchester
and
Telematicus
Newport Street
Macclesfield
SK11 6QJ
United Kingdom

E: ***@telematicus.com<mailto:***@telematicus.com>
E: ***@manchester.ac.uk<mailto:***@manchester.ac.uk>
Martynas Jusevičius
2016-11-04 11:45:05 UTC
Permalink
Why are you applying FILTER on ?snew and not ?olds?

On Fri, Nov 4, 2016 at 12:33 PM, Mahmood Ahmad
Post by Mahmood Ahmad
Hi,
Is there a way to control the output graph generated by the CONSTRUCT query? I know FILTER is one such option with NOT EXISTS.
"<http://www.xyz.com#UUID>"
skos:prefLabel "Preferred Label" ;
skos:broader "Broader entity";
a:aCode "Some Code" ;
a:aLevel "Some Level" ;
skos:narrower "Some narrower entity" .
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix a: <http://www.xyz.com/vocab#>
CONSTRUCT {
?snew skos:prefLabel ?pl ;
skos:broader ?b ;
a:aCode ?ac ;
?p ?o .
}
WHERE
{
?olds skos:prefLabel ?pl ;
skos:broader ?b ;
a:aCode ?ac ;
?p ?o .
BIND(CONCAT(CONCAT(STRBEFORE(STR(?olds), "#"), "#"), STRUUID()) AS ?snew) .
FILTER NOT EXISTS { ?snew a:aLevel ?le ;
?snew skos:narrower ?na ;
?p ?o . }
}
I have tried this with trying to exclude only one of the unwanted properties. I have also tried this with MINUS, without success. The output generated has no effect.
Any way out on this? I'll appreciate!
Regards
Mahmood
================================================
Dr Mahmood Ahmad
KTP Associate
School of Computer Science
University of Manchester
and
Telematicus
Newport Street
Macclesfield
SK11 6QJ
United Kingdom
Mahmood Ahmad
2016-11-04 12:35:13 UTC
Permalink
That's because I was BINDing first and then FILTERing later. That is why I thought I should apply FILTER on ?snew.

However, FILTERing first on ?olds and then BINDing does not produce desired result either.

Regards

-----Original Message-----
From: Martynas Jusevičius [mailto:***@graphity.org]
Sent: 04 November 2016 11:45
To: ***@jena.apache.org
Subject: Re: Controlling the Output graph in CONSTRUCT query

Why are you applying FILTER on ?snew and not ?olds?
Post by Mahmood Ahmad
Hi,
Is there a way to control the output graph generated by the CONSTRUCT query? I know FILTER is one such option with NOT EXISTS.
"<http://www.xyz.com#UUID>"
skos:prefLabel "Preferred Label" ;
skos:broader "Broader entity";
a:aCode "Some Code" ;
a:aLevel "Some Level" ;
skos:narrower "Some narrower entity" .
<http://www.w3.org/2001/XMLSchema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix a: <http://www.xyz.com/vocab#>
CONSTRUCT {
?snew skos:prefLabel ?pl ;
skos:broader ?b ;
a:aCode ?ac ;
?p ?o .
}
WHERE
{
?olds skos:prefLabel ?pl ;
skos:broader ?b ;
a:aCode ?ac ;
?p ?o .
BIND(CONCAT(CONCAT(STRBEFORE(STR(?olds), "#"), "#"), STRUUID()) AS ?snew) .
FILTER NOT EXISTS { ?snew a:aLevel ?le ;
?snew skos:narrower ?na ;
?p ?o . }
}
I have tried this with trying to exclude only one of the unwanted properties. I have also tried this with MINUS, without success. The output generated has no effect.
Any way out on this? I'll appreciate!
Regards
Mahmood
================================================
Dr Mahmood Ahmad
KTP Associate
School of Computer Science
University of Manchester
and
Telematicus
Newport Street
Macclesfield
SK11 6QJ
United Kingdom
Loading...