RMLio / RML-Mapper

Generate High Quality Linked Data from multiple originally (semi-)structured data (legacy)
http://RML.io
52 stars 20 forks source link

prefixes in RML #13

Closed m1ci closed 7 years ago

m1ci commented 7 years ago

Hi, how prefixes are handled in RML? We use RML in Java and in the output we dont get any prefix. Here is the code that we use:

        RMLDocRetrieval mapDocRetrieval = new RMLDocRetrieval();
        Repository repository = mapDocRetrieval.getMappingDoc(mappingFile, RDFFormat.TURTLE);

        //Extracting the RML Mapping Definitions
        RMLEngine engine = new StdRMLEngine();
        StdRMLMappingFactory mappingFactory = new StdRMLMappingFactory();
        RMLMapping mapping = mappingFactory.extractRMLMapping(repository);

        //Applying the RML Mapping
        RMLDataset output = engine.chooseSesameDataSet("dataset", null, null);
        output = engine.runRMLMapping(output, mapping, null, null, null);

can we somehow specify prefixes for the output? Thanks!

andimou commented 7 years ago

@m1ci on quick guess on top of my head, there should be a chance that you set the namespace on the repository level, i.e. something like repository.setNamespace("ex", "http://example.org/"); should work (but did not test).

Would you like to try and let me know?!

andimou commented 7 years ago

but it might not allow you, then doing the same around https://github.com/RMLio/RML-Processor/blob/master/src/main/java/be/ugent/mmlab/rml/dataset/StdRMLDataset.java#L42 and recompile might do the trick. Let me know if you try it.

radmirusmanov commented 7 years ago

@andimou thanks, we fixed it. Here is the code we use:

        //Retrieve the Mapping Document
        RMLDocRetrieval mapDocRetrieval = new RMLDocRetrieval();
        Repository repository = mapDocRetrieval.getMappingDoc(mappingFile, RDFFormat.TURTLE);

        //Extracting the RML Mapping Definitions
        RMLEngine engine = new StdRMLEngine();
        StdRMLMappingFactory mappingFactory = new StdRMLMappingFactory();
        RMLMapping mapping = mappingFactory.extractRMLMapping(repository);

        //Applying the RML Mapping
        RMLDataset output = engine.chooseSesameDataSet("dataset", null, null);
        output = engine.runRMLMapping(output, mapping, null, null, null);
        try 
        {
            output.getRepository().getConnection().setNamespace("dcterms", "http://purl.org/dc/terms/");
            output.getRepository().getConnection().setNamespace("foaf", "http://xmlns.com/foaf/0.1/");
        } 
        catch (RepositoryException ex) {
            Logger.getLogger(TriplesEngine.class.getName()).log(Level.SEVERE, null, ex);
        }
m1ci commented 7 years ago

@andimou thanks, for the quick reply and the tips!

pheyvaer commented 5 years ago

@AkbarKazimov I don't think that this is related to this issue. Could you create a new one for this?

AkbarKazimov commented 5 years ago

@AkbarKazimov I don't think that this is related to this issue. Could you create a new one for this?

I found what I was looking for. thanks