You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Mahmood Ahmad <ma...@telematicus.com> on 2016/11/04 11:33:16 UTC
Controlling the Output graph in CONSTRUCT query
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: Mahmood.Ahmad@telematicus.com<ma...@telematicus.com>
E: Mahmood.ahmad@manchester.ac.uk<ma...@manchester.ac.uk>
RE: Controlling the Output graph in CONSTRUCT query
Posted by Mahmood Ahmad <ma...@telematicus.com>.
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:martynas@graphity.org]
Sent: 04 November 2016 11:45
To: users@jena.apache.org
Subject: Re: Controlling the Output graph in CONSTRUCT query
Why are you applying FILTER on ?snew and not ?olds?
On Fri, Nov 4, 2016 at 12:33 PM, Mahmood Ahmad <ma...@telematicus.com> wrote:
> 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: Mahmood.Ahmad@telematicus.com<ma...@telematicus.com>
> E:
> Mahmood.ahmad@manchester.ac.uk<ma...@manchester.ac.uk>
>
>
Re: Controlling the Output graph in CONSTRUCT query
Posted by Martynas Jusevičius <ma...@graphity.org>.
Why are you applying FILTER on ?snew and not ?olds?
On Fri, Nov 4, 2016 at 12:33 PM, Mahmood Ahmad
<ma...@telematicus.com> wrote:
> 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: Mahmood.Ahmad@telematicus.com<ma...@telematicus.com>
> E: Mahmood.ahmad@manchester.ac.uk<ma...@manchester.ac.uk>
>
>