In Jena there are some default ontologies like RDF, FOAF...
So we can add property to resource like:
resource.addProperty(FOAF.name, person.getMFirstName());
But I need another ontology that does not exist in Jena like SIOC, pimo that I have the URI for.
How can I do this?
Jena has a tool for generating Java classes that contain the constants from ontologies and RDF schemas: schemagen
Related
I'm trying to query a GraphDB repository on a server from java code where I'm using Jena. According to the GraphDB documentation (http://graphdb.ontotext.com/free/using-graphdb-with-jena.html#installing-graphdb-with-jena), it's possible to instatiate a model using Jena SesameDataset as follow :
import com.ontotext.jena.SesameDataset;
// Some code goes here...
SesameDataset dataset = new SesameDataset(repositoryConnection);
Model model =
ModelFactory.createModelForGraph(dataset.getDefaultGraph());
I'm looking for the "Jena SesameDataSet" library from a couple of days without success.
Do you know where I can find it (maven or jar file) ? Or do you know any mean of instantiating a jena Model that is backed by a GraphDB repository on a server (whose URL can be something like http://localhost:7200/repositories/TestRepo) ?
I wonder how can we make an ontology using Description logic syntax (A-box, T-box) for a staff of a university? What classes, objects, relations, parents, siblings, constraints and interrelationships among them we can make?
I made the below class diagram but not sure if anything else could be added to it.
UML class diagrams can be translated to TBoxes and object diagrams to ABoxes. See for instance https://henrietteharmse.files.wordpress.com/2017/11/uml-class-diagram-to-owl-and-sroiq-reference.pdf.
I'm using the XML Tree API and the XML Parser API in c++, and I would like to prohibit entities creation in my XML documents.
What is the best way to do that when using these API's?
I've only seen examples of how to prohibit DTD entities when using XML Reader, and none when using the XML Tree or Parser API.
Thanks!
When using the tree API, you can call xmlGetIntSubset and inspect the xmlDtd structure to check whether a document contains entity declarations. When using the SAX parser, you can register an entityDeclSAXFunc callback.
Is there an ant task for generating an XSD from POJOs?
I'm presuming that you want to serialize a Java POJO object and then use XSD to validate the serialised XML data, or author new object instances which can instantiated via your de-serialization process.
Thing is Java XML serialization comes in two favours (Examples follow):
Xstream XML is dynamically generated from fixed object class description
XMLBeans Java classes dynamically generated from fixed XML Schema
Now perhaps you're using something else that combines both approaches?
What I'd recommend is create (or generate) an XSD based on the XML your object creates when serialized. Relatively speaking Java objects don't change that often and when they do a far great challenge is supporting multiple versions (Reading data encoded for the older version of your object). To address this challenge I'd recommend reading the following article for one possible solution:
http://java.dzone.com/articles/migrate-serialized-java
I created a DSL via Xtext and now I need to transform the models created in the editor into another model(s). I suppose the most straightforward way is to employ some kind of M2M transformation framework, but i need to access the model behind the textual file.
Question: how can I get a reference to the model?
The models created by Xtext have also a resource factory created for them. If you try to load the textual file as an EMF model, EMF will look for resource factories available for the extension of your textual file. From there, Xtext will transform the textual file in an EMF model and give EMF the model created. You can see this mechanism in action by right clicking on your textual file and selecting "open with" and "sample reflective ecore model editor". So something like this should work:
ResourceSet rs = new ResourceSetImpl();
Resource r = rs.getResource(uriOfYourTextualFile, true);
List<EObject> contentOfYourFile = r.getContents();