RDF change the format to include prefix

200 Views Asked by At

I am using d2rq.org to change my relational database data to RDF format, which i can write the result dump using http://d2rq.org/dump-rdf

and i did that, but the generated triples are as:

<http://www.bla.com/to#Media3348> <http://www.bla.com/to#hasGenre> <http://www.bla.com/to#Genre1> .

however, I prefer to have prefixed-entities, not full-length URIs.

I am extracting the data using:

map:Genre a d2rq:ClassMap;
    d2rq:dataStorage map:database;
    d2rq:class to:Genre;
    d2rq:uriPattern "http://www.bla.com/to#Genre@@M3.GENRE.GENRE_ID@@";
. 

and even if I change the mapping file to

d2rq:uriPattern "to:Genre@@M3.GENRE.GENRE_ID@@";

the result is:

<to:Genre1> 

they always include the < >

1

There are 1 best solutions below

0
On BEST ANSWER

By default, dump-rdf produces output in N-Triples format. N-Triples doesn't support prefixed names, so it will always write out full URIs in pointy brackets.

What you want is output in Turtle format. Turtle supports abbreviation of URIs with prefixed names. So there can be this at the beginning of the file:

@prefix to: <http://www.bla.com/to#>.

And having declared this prefix, one can then write the prefixed name to:Something instead of the full URI <http://www.bla.com/to#Something>.

You can instruct dump-rdf to use Turtle output format by adding -f TURTLE to the command line (as AKSW already pointed out).

Note that N-Triples works better for large databases because less memory is consumed.