user6887048
user6887048

Reputation:

How can I have my SPARQL query results in Turtle format in Apache Jena with commandline interface?

I have a command

./bin/arq  --data ./bin/dbpedia_2015-10.nt  --query ./bin/166.rq 

which works perfect and I can see my result in my command line interface. I would like to use jena RIOT to have my result in the file.ttl . But as I am not familiar with commandline and linux I don't know how to do it. is there any suggestion. I dont want to use the dbpedia datasets niether I just need the results from my sparql query.

this is my code `

select DISTINCT ?instance ?domain ?range ?subClassOf  # 
where { 
   ?instance rdf:type ?type;
             rdfs:domain ?domain;
             rdfs:range ?range;
             rdfs:subClassOf* ?subClassOf.
}

` ' but I have the error when change it to construct '

construct { DISTINCT ?instance ?domain ?range ?subClassOf.}  
where { 
   ?instance rdf:type ?type;
             rdfs:domain ?domain;
             rdfs:range ?range;
             rdfs:subClassOf* ?subClassOf.
}

Upvotes: 0

Views: 825

Answers (2)

chrisis
chrisis

Reputation: 1993

As you say your aim is to produce Turtle output and Turtle is an RDF serialisation format you need to CONSTRUCT RDF triples. e.g.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
CONSTRUCT { ?instance rdf:type ?type;
            rdfs:domain ?domain ;
            rdfs:range ?range;
            rdfs:subClassOf ?subClassOf .
}
where { 
   ?instance rdf:type ?type;
             rdfs:domain ?domain;
             rdfs:range ?range;
             rdfs:subClassOf* ?subClassOf.
}

Upvotes: 1

UninformedUser
UninformedUser

Reputation: 8465

It will be in Turtle syntax once you use a CONSTRUCT or DESCRIBE query.

Upvotes: 1

Related Questions