I use Jena API to read TTL files and get information form them using Sparql queries. This is the query I am using:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX test: <http://www.test.com/Test#>
select ?property (str(?value) as ?valueLiteral) (str(count(distinct ?
ind)) as ?noOfValueOccurrences)
where { ?ind rdf:type test:Lecturer. ?ind ?property ?
value.
?property a owl:DatatypeProperty .}
group by ?property ?value
order by ?property
My goal is to run Sparql queries on different TTL files, each of which will have different URI or IRIs. Since I m trying to automate the queries in Java, I need to be able to get <http://www.test.com/Test#>
or the IRI (from what I understood) when I read the .TTL file.
This is how I am trying to retrieve that:
public class Main {
BasicConfigurator.configure();
FileManager.get().addLocatorClassLoader(Main.class.getClassLoader());
Model model = FileManager.get().loadModel(pathToFile, "TTL");
System.out.println(model.getNsPrefixURI(""));
...
}
which returns
null
I m new to ontologies, I appreciate if you could help figure this out. Please let me know if the information I provided is not sufficient.
Thank you in advance