Reputation: 463
I am new to semantic web. I have collected RDF statments regarding a person from dbpedia.org
and schema.org
; I mean from two different ontologies. Saved in single file. Now i have to query them to display a homepage (HTML) for that person. I have question regarding how we query two different ontologies or how do we merge them together; please give me an idea how to start with. I am using Apache Jena.
Upvotes: 1
Views: 793
Reputation: 3407
In your case the difficult task is to merge the two files that contain RDF ontologies. Once you've merged them you can query them in the same way in which you would query a single file.
If you have two RDF data files in a Turtle-like format (i.e., Turtle, TriG, N-Quads or N-Triples) and at least one of them does not contain blank nodes, then you can simply concatenate the two files into a new N-Quads or N-Triples file.
If both files contain blank nodes then you first need to standardize them apart as per RDF 1.1 semantics. For example, if you have two N-Triple files then the blank node name _:1
may occur in both files, denoting different blank nodes.
If one of the files is serialized in a tree-based format (i.e., RDF/XML, TriX, RDFa or JSON-LD) then you cannot simply concatenate the files and expect the result to be conformant. Specifically, XML-like formats require you to enclose all data within the opening and closing tags that represent the single root node. Similarly, JSON-like formats require you to enclose all data within opening and closing brackets (either curly or square brackets). In these circumstances you have to fully parse the two data files into an RDF graph and then fully serialize the graph to a single file. The tasks of parsing and serializing are quite difficult in the general case, so you most probably want to let an existing library handle this. You mention Jena which is certainly able to do this. Notice that if at least one of the files contains named graphs you need to load+save an RDF dataset instead of an RDF graph. Jena probably supports the latter too.
Upvotes: 1