jena

How to get nested RDF/XML from Jena?

我怕爱的太早我们不能终老 提交于 2019-12-05 12:25:49
I need to create RDF that looks like this: <rdf:Description rdf:about='uri1'> <namespace:level1> <rdf:Description> <namespace:blankNode rdf:resource='uri2'/> <namespace:text></namespace:text> </rdf:Description> </namespace:level1> </rdf:Description> <rdf:Description rdf:about="uri2"> some properties here </rdf:Description> As you can see, there are nested structures, as well as blank nodes. (I don't know if that's the exact terminology for the "blankNode" property in my structure.) If I use model.write(System.out, "RDF/XML-ABBREV"); then even the blank node is nested, which I don't want. Is

Single quad + most basic SPARQL query = 1 result in Jena, 2 results in Sesame - who is right?

人走茶凉 提交于 2019-12-05 11:16:01
Add just this one quad to an empty store: <http://x.com/s> <http://x.com/p> 2 <http://x.com/g> . Then execute this SPARQL query (taken from per Bob DuCharme's book 'Learning SPARQL', so this must be standard SPARQL for retrieving all quads across the dataset, regardless of implementation, right!?): SELECT ?g ?s ?p ?o WHERE { { ?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } } } But Jena and Sesame reply with different answers!!? Here's what I see: Jena Fuseki console on Tomcat 6.0.37 (version 2.10.0 - out-of-the-box, no configuration changes!) - (the correct answer as I understand things): ----------

How to extract RDF triples from XML file using an existing ontology?

半腔热情 提交于 2019-12-05 10:58:47
I am trying to extract RDF triples from XML files by using an existing ontology. I am using Java, and can use XPath to extract data from XML and Jena to read and write RDF documents and ontologies. How can I extract the relevant triples from the XML according to the existing ontology? Forget about XPath to extract triples, it way easier and less problematic with Jena. You can use the interface SimpleSelector together with model.listStatements from Jena. In this example I am using SimpleSelector to find all the triples with a single property but you can implement the any search you need by

Serializing JENA OntModel Changes

扶醉桌前 提交于 2019-12-05 09:49:10
问题 I need to keep a couple of Jena Models (OntModels, specifically) synchronized across a socket, and I'd like to do this one change at a time (for various reasons -- one being that each Statement added or removed from the OntModels is also adapting a JESS rule base.). I am able to listen to the add/remove events on the OntModels and then create simple event instances that wrap the added / removed Statements along with a ChangeType that indicates that the Statement was added or removed, but

Fuseki GC overhead limit exceeded during data import

懵懂的女人 提交于 2019-12-05 09:42:31
I'm trying to import LinkedMDB (6.1m triples) into my local version of jena-fuseki at startup: /path/to/fuseki-server --file=/path/to/linkedmdb.nt /ds and that runs for a minute, then dies with the following error: Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded at com.hp.hpl.jena.graph.Node$3.construct(Node.java:318) at com.hp.hpl.jena.graph.Node.create(Node.java:344) at com.hp.hpl.jena.graph.NodeFactory.createURI(NodeFactory.java:48) at org.apache.jena.riot.system.RiotLib.createIRIorBNode(RiotLib.java:80) at org.apache.jena.riot.system.ParserProfileBase

Add text search where clause to SPARQL query

最后都变了- 提交于 2019-12-05 08:52:07
I have been given what I thought would be a simple task - take an existing SPARQL query and adapt the WHERE clause to restrict results to entities where a specific text field contains a specific search term. However, I am entirely new to the SPARQL language and nothing I've tried is working. It seems I need to use the text:query (rdfs:label 'word' 10) syntax, but I haven't managed to successfully integrate this into the query below. What I need is to further filter the results of the below query where the rdfs:label triple has a value containing the search term. If any of you could provide

How to turn a SPARQL/SPIN query/rule into an RDF structure from Java?

不想你离开。 提交于 2019-12-04 20:57:14
I have been using TopQuadrant Composer Free Edition (TBC FE) to embed SPARQL/SPIN rules (primarily SPIN constructors) in my OWL ontologies stored as RDF. Part of this process is that the SPARQL source code is tokenized/encoded in an RDF structure according to http://spinrdf.org/sp.html which the schema specified in http://spinrdf.org/sp . It is this structure that actually gets interpreted by RDF4J to run the SPIN rules. I'm also using RDF4J as my triple store, reasoner, SPARQL endpoint, and SPIN rule engine. In addition, I'm generating custom Java code and GUIs to manipulate my data and rules

Programmatically generating OWL class hierarchy with Jena

风流意气都作罢 提交于 2019-12-04 20:06:10
I want to programmatically generate an ontology using OWL by supplying a vector. My goal is to be able to open the produced OWL file in Protégé and make use of Jena. Input Vector The vector which i want to pass: [[layer, network layer, data link layer, physical layer], [network, computer network], [data link], [ontology, ontology extraction]]. Expected Output The output should have the following tree-like hierarchy structure: layer -network layer -data link layer -physical layer network -computer network ontology -ontology extraction data link The hierarchical structure, where network layer is

Retrieving all paths in an OWL class hierarchy with SPARQL and Jena

余生长醉 提交于 2019-12-04 17:58:48
I have an RDF graph of with a hierarchy three levels deep. I want to retrieve all the paths starting from the root of the class hierarchy (i.e., owl:Thing ) down to classes in the third level without using a reasoner. For instance, I would like the path C 1 &rightarrow; C 2 &rightarrow; C 3 is a path, where each C i is a class at the i th level of the hierarchy. I need to retrieve all the paths in the RDF graph using the breadth first search algorithm with no considerations to the object properties in the graph. Given some data like this (where length of the class name is an indication of the

How to create owl file using JENA?

雨燕双飞 提交于 2019-12-04 17:03:12
I am stuck in the middle of ontology creation. I want to create an OWL file using Java which is my objective. I have created the hierarchical clusters but now I have to use those clusters in ontology creation. Thanks in advance. I have tried this so far. I got Dickinson's point. Now this is my code and I am getting an Exception as Exception in thread "main" com.hp.hpl.jena.shared.BadURIException: Only well-formed absolute URIrefs can be included in RDF/XML output: Code: 57/REQUIRED_COMPONENT_MISSING in SCHEME: A component that is required by the scheme is missing. JenaOwl.java public class