Comments inline:

On 10/2/13 1:13 PM, "Alejandro Rodríguez González"
<[email protected]> wrote:

>Hi all,
>
>I'm trying to create a small program which convert an RDF file into quads
>adding context.
>
>I've been looking at the examples in the API and some information on
>Google, but I don't know exactly what I'm doing wrong.
>
>I create my quads in the following way:
>
>ArrayList<Quad> quads = new ArrayList<Quad>();
>quads.add(new Quad(this.assertionNode, this.rdfTypeNode,
> this.nanoPubSchemaAssertionNode, this.nanoPubNode));
>quads.add(new Quad(this.nanoPubNode, this.purlCoverageNode,
> getNodeFromString(coverageContent), this.provenanceNode));
>
>The "nodes" are created using NodeFactory. Just an example with the nodes
>used in the example presented before:
>
>this.assertionNode = NodeFactory.createLiteral("
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/a
>ssertion/6bfba5c26cedaa3caf460d36d25ceef0
>");
>
>this.nanoPubNode = NodeFactory.createLiteral("
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/n
>anopublication/6bfba5c26cedaa3caf460d36d25ceef0
>");
>
>this.provenanceNode = NodeFactory.createLiteral("
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/p
>rovenance/1380725119158
>");

If these are URIs you should be calling NodeFactory.createUri() not
NodeFactory.createLiteral()

>
>etc.
>
>Once I've created all my structure, I try to print it on screen and store
>it on a .nq file using this code:
>
> Dataset ds = TDBFactory.createDataset();
> DatasetGraph dsg = ds.asDatasetGraph();
> for (int i = 0; i < quads.size(); i++) {
> dsg.add(quads.get(i));
> }
> RDFDataMgr.write(new FileOutputStream(new File("output/nquad2.nq")),
> dsg, RDFFormat.NQUADS);
> System.out.println(dsg.toString());
>
>The output that I get in the console is the following:
>
>(dataset
>  (graph)
>  (graph "
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/a
>ssertion/6bfba5c26cedaa3caf460d36d25ceef0
>"
>    (triple "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; "
>http://www.nanopub.org/nschema#Assertion"; "
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/n
>anopublication/6bfba5c26cedaa3caf460d36d25ceef0
>")
>  )
>  (graph "
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/n
>anopublication/6bfba5c26cedaa3caf460d36d25ceef0
>"
>    (triple "http://purl.org/dc/elements/1.1/description"; "\"Output from
>SADI Service\"@en" "
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/p
>rovenance/1380725119158
>")
>  ))
>
>
>Which, it is the one that "I desire". However, in the file, I've the
>following:
>
>"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; "
>http://www.nanopub.org/nschema#Assertion"; "
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/n
>anopublication/6bfba5c26cedaa3caf460d36d25ceef0"
>"
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/a
>ssertion/6bfba5c26cedaa3caf460d36d25ceef0"
>.
>"http://purl.org/dc/elements/1.1/description"; "\"Output from SADI
>Service\"@en" "
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/p
>rovenance/1380725119158"
>"
>http://biordf.org:8080/cgi-bin/services/retrieveProteomeProtiens_sync.pl/n
>anopublication/6bfba5c26cedaa3caf460d36d25ceef0"
>.
>
>My questions are:
>
>1) Why is the order of the nodes different? I mean, I expect to have:
>context, s, p, o (like when it is printed)

Because Jena follows the NQuads specification and the NQuads specification
mandates that the context which is an optional field in NQuads is written
last.

>2) Why, even using RDFFormat.NQUADS the serialization is between " " and
>not between <> ?

Because as previously noted you created literals when your question
implies you meant to create URIs, as noted earlier use
NodeFactory.createURI() instead

Rob

>
>Probably I'm missing something ...
>
>Thanks for your time.
>
>Cheers,
>
>Alejandro
>
>-- 
>Dr. Alejandro Rodríguez González - PhD
>
>Bioinformatics at Centre for Plant Biotechnology and Genomics UPM-INIA
>Polytechnic University of Madrid
>http://www.alejandrorg.com
>Phone: +34 914524900 . Ext: 25550
>
>
>*Once the game is over, the king and the pawn go back in the same box. -
>Italian proverb*




Reply via email to