rdf - Java code for Converting string message into Jena model -


I have a string message from the AMQP message broker that has RDF statements. I want to hide it in Jena model using Java and then merge the converted model into another model with another model. How can I do this?

It can be divided into three logical steps, some of which you may have already done:

  1. Separate RDF details from non-RDF text
  2. Identify the syntax used for RDF (can be part of # 1) < Li> Parse the resulting string in Apache Jen model

    The first two are domain-specific, then you will not likely get much help even if you can not provide some example input, except that a different question (such as : 'How can I split a string based on the presence of RDF syntax?'))

    For the third, it is very fast and easy to assume that you have N -Triples is a document in the form that you want Is derived from l to parse it in the following Jyunet test and the ability to interact with its contents is shown. final string nTriplesDoc = "pdf: east: S>; vase: ex: P & gt; & lt; vase: East: O>. "; Last model model = modelfacity.createDefaultModel (); Try (Last InputStream = new ByteArrayInputStream (nTriplesDoc.getBytes ("UTF-8")) {/ * Naturally, instead of using N-Triple, you replace the syntax of your real * content * / model. The final resource p = ResourceFactory.createProperty ("Pulse: ex: P"); Final Resource O = ResourceFactory.createResource ("kalash: ex: o"); emphasis (model contains (s, p, o));

    Edit / Part II

    come After watching the comment, I thought it was prudent to add another note about the merger of the model. In Jena, you can merge the model by adding all your triplets together. This can make some remaining models The garbage that is collected, which can not be the best scenario for your system.

      last model model = modelfatter. Add Model to (); // Model ... ... We model 1 = Modlfaccr .create (); // Add Things to Model 1 ... Final Model Merge = ModelFactory.create (); Merger.add (model0); Merger.add (MODEL1);   

    In this example, two source models need to be gathered either using either one of the existing models as the destination for all triples or a model of two underlying graphs Will be intelligent (resulting in both graphs being repeated):

      last model union = modelfactor.CreateModelForGraph (new union (model 0.getGraph (), Model 1.getGraph ()));   

    I also leave an assumption that you can get the string object from your AMQP server, so that the answer is just # 3 from the first half Is also related to your scenario.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -