Code Monkey home page Code Monkey logo

rmlmapper-java's Introduction

RMLMapper

Maven Central

The RMLMapper executes RML rules to generate Linked Data. It is a Java library, which is available via the command line (API docs online). The RMLMapper loads all data in memory, so be aware when working with big datasets.

Want to get started quickly? Check out Releases on where to find the latest CLI build as a jar, and see Usage on how to use the commandline interface!

Table of contents

Features

Supported

  • local data sources:
    • Excel (.xlsx)
    • LibreOffice (.ods)
    • CSV files (including CSVW)
    • JSON files (JSONPath)
    • XML files (XPath)
  • remote data sources:
    • relational databases (MySQL, PostgreSQL, Oracle, and SQLServer)
    • Web APIs with W3C Web of Things
    • SPARQL endpoints
    • files via HTTP urls (via GET)
      • CSV files
      • JSON files (JSONPath (@ can be used to select the current object.))
      • XML files (XPath)
  • functions (most cases)
    • For examples on how to use functions within RML mapping documents, you can have a look at the RML+FnO test cases
  • configuration file
  • metadata generation
  • output formats: nquads (default), turtle, trig, trix, jsonld, hdt
  • join conditions
  • targets:
    • local file
    • VoID dataset
    • SPARQL endpoint with SPARQL UPDATE

Future

  • functions (all cases)
  • conditions (all cases)
  • data sources:
    • NoSQL databases
    • TPF servers

Releases

The standalone jar file (that has a commandline interface) for every release can be found on the release's page on GitHub. You can find the latest release here. This is the recommended way to get started with RMLMapper. Do you want to build from source yourself? Check Build.

Build

The RMLMapper is built using Maven. As it is also tested against Oracle (check here for details), it needs a specific set-up to run all tests. That's why we recommend to build without testing: mvn install -DskipTests=true. If you want, you can install with tests, and just skip the Oracle tests: mvn test -Dtest=!Mapper_OracleDB_Test.

A standalone jar can be found in /target.

Two jars are found in /target: a slim jar without bundled dependencies, and a standalone jar (suffixed with -all.jar) with all dependencies bundled.

Building with profile no-buildnumber disables using and updating buildNumber.properties (and uses 0 as build number), e.g.:

mvn clean package -P no-buildnumber

outputs for example target/rmlmapper-<version>-r0.jar

Usage

CLI

The following options are most common.

  • -m, --mapping <arg>: one or more mapping file paths and/or strings (multiple values are concatenated).
  • -o, --output <arg>: path to output file
  • -s,--serialization <arg>: serialization format (nquads (default), trig, trix, jsonld, hdt)

All options can be found when executing java -jar rmlmapper.jar --help, that output is found below.

usage: java -jar mapper.jar <options>
options:
 -b,--base-iri <arg>                 Base IRI used to expand relative IRIs
                                     in generated terms in the output.
 -c,--configfile <arg>               path to configuration file
 -d,--duplicates                     remove duplicates in the HDT,
                                     N-Triples, or N-Quads output
    --disable-automatic-eof-marker   Setting this option assumes input
                                     data has a kind of End-of-File
                                     marker. Don't use unless you're
                                     absolutely sure what you're doing!
 -dsn,--r2rml-jdbcDSN <arg>          DSN of the database when using R2RML
                                     rules
 -e,--metadatafile <arg>             path to output metadata file
 -f,--functionfile <arg>             one or more function file paths
                                     (dynamic functions with relative
                                     paths are found relative to the cwd)
 -h,--help                           show help info
 -l,--metadataDetailLevel <arg>      generate metadata on given detail
                                     level (dataset - triple - term)
 -m,--mappingfile <arg>              one or more mapping file paths and/or
                                     strings (multiple values are
                                     concatenated). r2rml is converted to
                                     rml if needed using the r2rml
                                     arguments.RDF Format is determined
                                     based on extension.
 -o,--outputfile <arg>               path to output file (default: stdout)
 -p,--r2rml-password <arg>           password of the database when using
                                     R2RML rules
 -psd,--privatesecuritydata <arg>    one or more private security files
                                     containing all private security
                                     information such as usernames,
                                     passwords, certificates, etc.
 -s,--serialization <arg>            serialization format (nquads
                                     (default), turtle, trig, trix,
                                     jsonld, hdt)
    --strict                         Enable strict mode. In strict mode,
                                     the mapper will fail on invalid IRIs
                                     instead of skipping them.
 -t,--triplesmaps <arg>              IRIs of the triplesmaps that should
                                     be executed in order, split by ','
                                     (default is all triplesmaps)
 -u,--r2rml-username <arg>           username of the database when using
                                     R2RML rules
 -v,--verbose                        show more details in debugging output                                                      

Accessing Web APIs with authentication

The W3C Web of Things Security Ontology is used to describe how Web APIs authentication should be performed but does not include the necessary credentials to access the Web API. These credentials can be supplied using the -psd <PATH> CLI argument. The PATH argument must point to one or more private security files which contain the necessary credentials to access the Web API.

An example can be found in the test cases src/test/resources/web-of-things.

Library

An example of how you can use the RMLMapper as an external library can be found at ./src/test/java/be/ugent/rml/readme/ReadmeTest.java

Docker

Dockerhub

We publish our Docker images automatically on Dockerhub for every release. You can find our images here: rmlio/rmlmapper-java.

Build image

You can use Docker to run the RMLMapper by following these steps:

  • Build the Docker image: docker build -t rmlmapper ..
  • Run a Docker container: docker run --rm -v $(pwd):/data rmlmapper -m mapping.ttl.

The same parameters are available as via the CLI. The RMLMapper is executed in the /data folder in the Docker container.

Including functions

There are three ways to include (new) functions within the RML Mapper

  • dynamic loading: you add links to java files or jar files, and those files are loaded dynamically at runtime
  • preloading: you register functionality via code, and you need to rebuild the mapper to use that functionality
  • add as dependency

Registration of functions is done using a Turtle file, which you can find in src/main/resources/functions.ttl

Dynamic loading

Create a Turtle file that describe the functions that need to be included and add the jar which contains those functions.

Note: the java or jar-files are found relative to the cwd. You can change the functions.ttl path (or use multiple functions.ttl paths) using a commandline-option (-f).

For example the snippets below dynamically link an fno:Function to a library, provided by a jar-file (CustomFunctions.jar). The example links a function that parses the latitude (50.2) out of the following string "POINT (50.2 5.3)".

functions.ttl contains the description of the function in Turtle:

@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix doap:    <http://usefulinc.com/ns/doap#> .
@prefix fno:     <https://w3id.org/function/ontology#> .
@prefix fnoi:    <https://w3id.org/function/vocabulary/implementation#> .
@prefix fnom:    <https://w3id.org/function/vocabulary/mapping#> .
@prefix grel:    <http://users.ugent.be/~bjdmeest/function/grel.ttl#> .
@prefix grelm:   <http://fno.io/grel/rmlmapping#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .

grel:parsePointLat a fno:Function ;
  fno:name "parsePointLat" ;
  rdfs:label "parsePointLat" ;
  dcterms:description "Parse the latitude from a point." ;
  fno:expects ( grel:valueParam ) ;
  fno:returns ( grel:stringOut ) .

grelm:javaString
    a                  fnoi:JavaClass ;
    doap:download-page "CustomFunctions.jar" ;
    fnoi:class-name    "CustomFunctions" .

grelm:parsePointLat
    a                    fno:Mapping ;
    fno:function         grel:parsePointLat ;
    fno:implementation   grelm:javaString ;
    fno:methodMapping    [ a                fnom:Function ;
                           fnom:method-name "parsePointLat" ] .

The accompanying java file CustomFunctions.java:

public class CustomFunctions {
  public static String parsePointLat(String s) {
    return s.replace("POINT ", "").replace('(', ' ').replace(')', ' ').trim().split("\\s+")[0];
  }
}

To dynamically include the custom function, compile the java-file and include functions.ttl with the -f option:

javac CustomFunctions.java && jar cvf CustomFunctions.jar CustomFunctions.class
java -jar mapper.jar -f functions.ttl <other options>

Preloading

This overrides the dynamic loading. An example of how you can use Preload a custom function can be found at ./src/test/java/be/ugent/rml/readme/ReadmeFunctionTest.java

Adding as dependency

This is most interesting if you use RMLMapper as a library in your own project. Just add the dependency to the function library you want to use in your project.

You can also add a function library as a Maven dependency in pom.xml of RMLMapper. You'll have to rebuild RMLMapper to use it.

Generating metadata

Conform to how it is described in the scientific paper [1], the RMLMapper allows to automatically generate PROV-O metadata. Specifically, you need the CLI arguments below. You can specify in which output file the metadata should be stored, and up to which level metadata should be stored (dataset, triple, or term level metadata).

 -e,--metadatafile <arg>          path to output metadata file
 -l,--metadataDetailLevel <arg>   generate metadata on given detail level
                                  (dataset - triple - term)

Testing

Command line

Run the tests via test.sh.

IntelliJ

Right-click src/test/java directory and select "Run 'All tests'".

Derived tests

Some tests (Excel, ODS) are derived from other tests (CSV) using a script (./generate_spreadsheet_test_cases.sh)

RDBs

Make sure you have Docker running. On Unix, others read-write permission (006) is required on /var/run/docker.sock in order to run the tests. The tests will fail otherwise, as Testcontainers can't spin up the container.

Problems

  • A problem with Docker (can't start the container) causes the SQLServer tests to fail locally. These tests will always succeed locally.
  • A problem with Docker (can't start the container) causes the PostgreSQL tests to fail locally on Windows 7 machines.

Dependencies

Dependency License
ch.qos.logback logback-classic Eclipse Public License 1.0 & GNU Lesser General Public License 2.1
com.github.fnoio function-agent-java MIT
com.github.fnoio grel-functions-java MIT
com.github.fnoio idlab-functions-java MIT
com.github.rdfhdt hdt-java GNU Lesser General Public License v3.0
com.github.tomakehurst:wiremock-jre8 Apache License 2.0
com.microsoft.sqlserver mssql-jdbc MIT
com.mysql mysql-connector-java GNU General Public License v2.0
com.oracle.database.jdbc:ojdbc11 Oracle Free Use Terms and Conditions
net.minidev json-smart Apache License 2.0
org.apache.jena fuseki-main Apache License 2.0
org.eclipse.rdf4j rdf4j-client Eclipse Distribution License v1.0
org.junit.jupiter junit-jupiter-api Eclipse Public License v2.0
org.junit.jupiter junit-jupiter-engine Eclipse Public License v2.0
org.junit.jupiter junit-jupiter-params Eclipse Public License v2.0
org.junit.vintage junit-vintage-engine Eclipse Public License v2.0
org.postgresql postgresql BSD
org.testcontainers jdbc MIT
org.testcontainers junit-jupiter MIT
org.testcontainers mssqlserver MIT
org.testcontainers mysql MIT
org.testcontainers oracle-xe MIT
org.testcontainers postgresql MIT

Commercial Support

Do you need...

  • training?
  • specific features?
  • different integrations?
  • bugfixes, on your timeline?
  • custom code, built by experts?
  • commercial support and licensing?

You're welcome to contact us regarding on-premise, enterprise, and internal installations, integrations, and deployments.

We have commercial support available.

We also offer consulting for all-things-RML.

Remarks

Typed spreadsheet files

All spreadsheet files are as of yet regarded as plain CSV files. No type information like Currency, Date... is used.

XML file parsing performance

The RMLMapper's XML parsing implementation (javax.xml.parsers) has been chosen to support full XPath. This implementation causes a large memory consumption (up to ten times larger than the original XML file size). However, the RMLMapper can be easily adapted to use a different XML parsing implementation that might be better suited for a specific use case.

Language tag support

The processor checks whether correct language tags are not, using a regular expression. The regex has no support for languages of length 5-8, but this currently only applies to 'qaa..qtz'.

Duplicate removal and serialization format

Performance depends on the serialization format (--serialization <format>) and if duplicate removal is enabled (--duplicates). Experimenting with various configurations may lead to better performance for your use case.

I have a question! Where can I get help?

Do you have any question related to writing RML mapping rules, the RML specification, etc., feel free to ask them here: https://github.com/kg-construct/rml-questions ! If you have found a bug or need a feature for the RMLMapper itself, you can make an issue in this repository.

Documentation

Generate static files at /docs/apidocs with:

mvn javadoc:javadoc

UML Diagrams

Architecture UML Diagram

How to generate with IntelliJ IDEA

(Requires Ultimate edition)

  • Right click on package: "be.ugent.rml"
  • Diagrams > Show Diagram > Java Class Diagrams
  • Choose what properties of the classes you want to show in the upper left corner
  • Export to file > .png | Save diagram > .uml

Sequence Diagram

Edit on draw.io
  • Go to draw.io
  • Click on 'Open Existing Diagram' and choose the .html file

[1]: A. Dimou, T. De Nies, R. Verborgh, E. Mannens, P. Mechant, and R. Van de Walle, โ€œAutomated metadata generation for linked data generation and publishing workflows,โ€ in Proceedings of the 9th Workshop on Linked Data on the Web, Montreal, Canada, 2016, pp. 1โ€“10. PDF

rmlmapper-java's People

Contributors

andpuydt avatar aronbuzogany avatar berombau avatar bjdmeest avatar driesmarzougui avatar duschu avatar dylanvanassche avatar elsdvlee avatar eyzeedev avatar gertjandemulder avatar ghsnd avatar julianrojas87 avatar mcndt avatar paulmillar avatar pheyvaer avatar robbe0x00 avatar s-minoo avatar thabils avatar themessik avatar thomas-delva avatar triver1 avatar wddridde avatar winniederidder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rmlmapper-java's Issues

Support SQLite db

I need to map a geopackage file, which is a SQLite database, for the smart waterway project (ends in 2021)

For now, I will try converting the SQLite to MySQL and start from there.

Return a more descriptive error when provided mapping file does not exist

Description

RML Mapper crashes with a parsing error for non-existing mapping files:

08:34:42.569 [main] ERROR be.ugent.rml.cli.Main               .main(315) - Unexpected end of file
org.eclipse.rdf4j.rio.RDFParseException: Unexpected end of file
	at org.eclipse.rdf4j.rio.turtle.TurtleParser.throwEOFException(TurtleParser.java:1317)
	at org.eclipse.rdf4j.rio.turtle.TurtleParser.verifyCharacterOrFail(TurtleParser.java:1133)
	at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseQNameOrBoolean(TurtleParser.java:1001)
	at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseValue(TurtleParser.java:578)
	at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseSubject(TurtleParser.java:406)
	at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseTriples(TurtleParser.java:347)
	at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseStatement(TurtleParser.java:216)
	at org.eclipse.rdf4j.rio.turtle.TurtleParser.parse(TurtleParser.java:178)
	at org.eclipse.rdf4j.rio.turtle.TurtleParser.parse(TurtleParser.java:130)
	at be.ugent.rml.store.RDF4JStore.read(RDF4JStore.java:111)
	at be.ugent.rml.cli.Main.main(Main.java:174)
	at be.ugent.rml.cli.Main.main(Main.java:35)

I find it useful to check if the mapping file exists before parsing it. This way, we can return an appropriate error message.

Steps to reproduce

  1. Execute the RML Mapper with -m <mapping file>. The name of the mapping file is a non-existing.
  2. The RML Mapper fails with a Turtle parsing error.

Environment

  • Ubuntu 18.04 LTS
  • OpenJDK 12.0.2 (64 bit)
  • RMLMapper 4.7.0

Extracting parent-children entities from XML

Hello!

I'm not sure whether this is a bug or whether I'm doing something wrong.

I have XML data in the following format:

<e id="g2" class="page">
  <e id="p1" class="par">
    <e id="l1" class="line">hello world</e>
    <e id="l2" class="line">just testing</e>
  </e>
  <e id="p2" class="par">
    <e id="l3" class="line">bye</e>
    <e id="l4" class="line">another line</e>
    <e id="l5" class="line">yet another line</e>
  </e>
  ...
</e>

I would like to produce the following RDF:

<http://example.org/par/p1> a ex:Paragraph .
<http://example.org/par/p1> ex:hasLine <http://example.org/line/l1> .
<http://example.org/par/p1> ex:hasLine <http://example.org/line/l2> .
<http://example.org/line/l1> a ex:Line .
<http://example.org/line/l2> a ex:Line .
<http://example.org/par/p2> a ex:Paragraph .
<http://example.org/par/p2> ex:hasLine <http://example.org/line/l3> .
<http://example.org/par/p2> ex:hasLine <http://example.org/line/l4> .
<http://example.org/par/p2> ex:hasLine <http://example.org/line/l5> .
<http://example.org/line/l3> a ex:Line .
<http://example.org/line/l4> a ex:Line .
<http://example.org/line/l5> a ex:Line .
...

So I came up with this RML to do it:

<#par> a rr:TriplesMap ;
  rml:logicalSource [
    rml:source "my.xml" ;
    rml:referenceFormulation ql:XPath ;
    rml:iterator "//*[@class='par']"
  ] ;
  rr:subjectMap [
    rr:template "http://example.org/par/{@id}" ;
    rr:class ex:Paragraph
  ] ;
  rr:predicateObjectMap [
    rr:predicate ex:hasLine ;
    rr:objectMap [
      rr:parentTriplesMap <#line> ;
      rr:joinCondition [
        rr:child "*[@class='line']/@id" ;
        rr:parent "@id"
      ]
    ]
  ] .

<#line> a rr:TriplesMap ;
  rml:logicalSource [
    rml:source "my.xml" ;
    rml:referenceFormulation ql:XPath ;
    rml:iterator "//*[@class='line']"
  ] ;
  rr:subjectMap [
    rr:template "http://example.org/line/{@id}" ;
    rr:class ex:Line
  ] .

But I'm not getting the expected output. There's only one "child" line per paragraph:

<http://example.org/par/p1> a ex:Paragraph .
<http://example.org/par/p1> ex:hasLine <http://example.org/line/l1> .
<http://example.org/line/l1> a ex:Line .
<http://example.org/line/l2> a ex:Line .
<http://example.org/par/p2> a ex:Paragraph .
<http://example.org/par/p2> ex:hasLine <http://example.org/line/l3> .
<http://example.org/line/l3> a ex:Line .
<http://example.org/line/l4> a ex:Line .
<http://example.org/line/l5> a ex:Line .
...

After some debugging I discovered the cause of this:

... basically, when it parses the argument (list of lines belonging to the paragraph, obtained by rr:child "*[@class='line']/@id" directive), it ignores the rest of the list and takes only the first element, so the list of possible children (lines) is matched only against the first candidate later in the code:

public static boolean equal(String str1, String str2) {

Looks like a bug... but probably I shouldn't use joinCondition for this in the first place?

If that's a bug, then rmlmapper should handle lists as possible parameters in FunctionModel.parseParameter and UtilFunctions should have another method to accompany equal(str1, str2) โ€“ for example, includes(list, str2) to check whether str2 is included in list.
At this point, I'm not too well-versed in Java to handle the magic happening in that code, so I'm afraid I won't be able to provide a decent pull request ๐Ÿ˜‰

If it's not a bug, could you advise how to handle it otherwise?

Thank you!

parenttriplesmap not found in nested function

considering the yarrrml document of RMLio/yarrrml-parser#68 ,
the mapper doens't find the parenttriplesmap and instead uses its own logical source.
I believe two things should happen:

  • An error should be given when the parenttriplesmap is not found, and the rmlmapper shouldn't continue (the rml document is invalid then, interpreting https://www.w3.org/TR/r2rml/#foreign-key, there should never be a rr:child without a rr:parentTriplesMap)
  • A debug statement should be given when the parenttriplesmap is found not as its direct ancestor, but due to a nested function
  • the parenttriplesmap should be looked for in every ancestor until one is found ;)

File grel_java_mapping.ttl does not exist

The class FunctionLoader tries to load the file "grel_java_mapping.ttl" but it doesn't exist in the resource folder so it throws exception.

Could anyone have a look?

Thanks a lot

IndexOutOfBoundsException

When I run the rmlmapper-java I get the following exception:

Exception in thread "main" 
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
	at java.util.ArrayList.get(ArrayList.java:429)

	at be.ugent.rml.Executor.generatePredicateObjectsForSubject(Executor.java:80)

	at be.ugent.rml.Executor.execute(Executor.java:60)
	at be.ugent.rml.cli.Main.main(Main.java:96)

When I run RML-Mapper with the same file I don't get an exception and everything works fine, so I think this must be a code bug.

RML file used:
file.txt

Function getting null values

When I try to use my function createAddress, it only gets null values making it return "null null null" as a result.

Commands used:
yarrrml -i file.yaml > rml.txt
java -jar ./rmlmapper-0.1.6.jar -m ./rml.txt -o ./out -f ./functions/functions.ttl

Files:
issue.zip

How to use a generated UUID in the subject's URI

To generate a UUID I have used the code snippet below:

<#UUIDGeneration>
a rr:TriplesMap;
rml:logicalSource [
rml:source "filename.xml" ;
rml:iterator "/Book";
rml:referenceFormulation ql:XPath
];
rr:subjectMap [
fnml:functionValue [
rr:predicateObjectMap [
rr:predicate fno:executes ;
rr:objectMap [ rr:constant grel:random ] ] ;
];
rr:termType rr:IRI
];

rr:predicateObjectMap [
rr:predicate ex:hasGeneratedUUID;
rr:objectMap [
fnml:functionValue [
rr:predicateObjectMap [
rr:predicate fno:executes ;
rr:objectMap [ rr:constant grel:random ] ]
]
]
].

Is there a way that I can assign that generated UUID to the subject's URI e.g.

rr:subjectMap [
rr:template "http://example.com#Book-{generatedURI}";
rr:class ex:Book
];

License information missing

Dear RMLio team,

unfortunately this repository does not contain a LICENSE file, so it's unclear under which license this project is released.

Would you please add a license file? Apache and MIT are great choices, as they make this library widely usable, but that's of course the choice of the owner.

Thanks,
Wolfgang

JDBC connectors

Hi!

Is there some preference for using DriverManager instead of DataSource for JDBC connections in RDBs.java?

The reason for asking is that I had to connect to a certain (non-default) schema in postgres DB, and it is recommended to specify the schema name as a param in the JDBC connection string as follows: jdbc:postgresql://localhost:5432/database?currentSchema=sc1. If I use this URL for "jdbcDSN", then it doesn't work โ€“ because treating it as a simple string in

connectionString += "?user=" + username + "&password=" + password;
creates an invalid URL (with two "?"s).

With DataSource one doesn't have to make user and password a part of the URL as above โ€“ instead, it provides somewhat uniform API for setting those params without having to "manually" manipulate jdbcDSN. It also seems to be a preferred method of dealing with JDBC connections, as stated in https://docs.oracle.com/javase/10/docs/api/java/sql/DriverManager.html

So... I could try and refactor that part of JDBC-related code to use DataSource, if there's no objections :) Provided, I have some time to spare soon.

no blank node in object position

Hi! I've just used the RML-mapper v4.5.1 and I've issues with the creation of blank nodes. I'm able to successfully create a BN in a subject position, but not in the object position of a triple:

rr:subjectMap [
	rr:template "mybn{F41}" ;
	rr:termType rr:BlankNode ;
	rr:class arp:Photograph
]
...

returns a BN (in Turtle output file): _:mybnABC

...
rr:predicateObjectMap [
	rr:predicate vann:example ;
	rr:objectMap [
		rr:template "mybn{F41}" ;
		rr:termType rr:BlankNode
	]
]

does not return a BN but an IRI (in Turtle output file): <mybnABC> .

My goal is to create output triples as follows:

ex:subj vann:example _:bn1 .
_:bn1 a arp:Photograph ;
      rdfs:label "some text" ;
      arp:hasFullFileName "http://ex.org/photo.jpg" .

Support variables

Is there a way to declare variables in order to reuse them in a mapping?
For example, if I have the root of my doc that contains an attribute with an id, then I could use it in an internal mapping. E.g.

<root id="10">
   <children>
      <child id = "1">

If I could declare var X = root/@id, then I could declare the subjectMap of child as htttp://somehost.com/{X}/{id} (this is required in our use case)

Question: How to map JSON property to a value instead of a predicate?

Hi, I have a JSON structure like this

{
    "1": {
           "first_name": "Alex",
           "last_name": "To",
           },
     "2": {
           "first_name": "Alex",
           "last_name": "To",
     }
}

where "1" and "2" are user ids so I want to map them into triples like these

:1    a     :Person .
:2    a     :Person .

Of course I can first transform the JSON into some other structure and then do RML mapping but my question is, is there a way to do such mapping without first transforming the JSON?

Thank you

rmlmapper with spring boot

Hi everyone,
I'm trying to integrate the library in a spring boot application. The problem is that there always are conflicts with dependency that I can not solve. In particular the stack trace I have is:

Schermata del 2019-10-15 21-38-40

POM:

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.3.RELEASE</version>
		<relativePath /> <!-- lookup parent from repository -->
	</parent>

	<groupId>cefriel</groupId>
	<artifactId>semanticfuelserver</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<java.version>8</java.version>
		<jackson.version>2.9.8</jackson.version>
		<junit.jupiter.version>5.5.2</junit.jupiter.version>
	</properties>

	<repositories>
		<repository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/milestone</url>
		</repository>
		<repository>
			<id>jitpack.io2</id>
			<url>https://jitpack.io</url>
		</repository>
	</repositories>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.slf4j</groupId>
					<artifactId>slf4j-api</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-logging</artifactId>
				</exclusion>

			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-autoconfigure</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-webflux</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.hibernate.validator</groupId>
					<artifactId>hibernate-validator</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.slf4j</groupId>
					<artifactId>slf4j-api</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-log4j2</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.slf4j</groupId>
					<artifactId>slf4j-api</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-yaml</artifactId>
		</dependency>
		<dependency>
			<groupId>org.webjars</groupId>
			<artifactId>bootstrap</artifactId>
			<version>3.3.7</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-test</artifactId>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>junit</groupId>
					<artifactId>junit</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.junit.platform</groupId>
			<artifactId>junit-platform-launcher</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-api</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>io.projectreactor</groupId>
			<artifactId>reactor-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-engine</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.github.RMLio</groupId>
			<artifactId>rmlmapper-java</artifactId>
			<version>4.5.1</version>
		</dependency>
	</dependencies>

JAR file usage issues

Hi,

I am using rmlmapper.jar in my spring boot maven project.

I am facing an issue where I am not able to ignore the SLF4J jar which rmlmapper refers to.

Need you help in ignoring the Spring and SLF4J classes from the rmlmapper.jar file.

I am not able to run this as a WAR file as the classpath has multiple bindings for SLF4J and DispatcherServlet class.

Thanks,
Venkatesh

Unable to generate custom mapping

I am trying to convert source xml/json file to RDF using a custom mapping file.

Source File:
[ { "ProviderID": 10005, "HospitalName": "MARSHALL MEDICAL CENTER SOUTH", "Phone Number": 2565938310, "Hospital Type": "Acute Care Hospitals", "Hospital overall rating": 1, "Location": "2505 U S HIGHWAY 431 NORTH BOAZ, AL 35957" }, { "ProviderID": 10012, "HospitalName": "DEKALB REGIONAL MEDICAL CENTER", "Phone Number": 2568453150, "Hospital Type": "Acute Care Hospitals", "Hospital overall rating": 2, "Location": "200 MED CENTER DRIVE FORT PAYNE, AL 35968" } ]

Custom mapping file:

@Prefix rr: http://www.w3.org/ns/r2rml#.
@Prefix rml: http://semweb.mmlab.be/ns/rml#.
@Prefix ql: http://semweb.mmlab.be/ns/ql#.
@Prefix xsd: https://www.w3.org/2001/XMLSchema#.
@Prefix emp: https://w3id.org/empathi/#.
@Prefix rdfs: https://www.w3.org/2000/01/rdf-schema#.
@Prefix ex: http://example.com/ns#.
ex:HospitalMapping a rr:TriplesMap;
rml:logicalSource [
rml:source "listOfHospitals.json" ;
rml:iterator "/hospital";
rml:referenceFormulation ql:JSONPath;
];
rr:subjectMap [
rr:template "/ProviderID";
rr:class emp:Facility
];
rr:predicateObjectMap [
rr:predicate emp:id;
rr:objectMap [
rml:reference "/ProviderID";
rr:datatype xsd:int
]
];
rr:predicateObjectMap [
rr:predicate emp:Location;
rr:objectMap [
rml:reference "Location"
]
].

We have run the RML mapper which got executed successfully but without any output (no output as result of the conversion). I have used /hospital as the iterator. Is there a way to create a better mapping file for this specific JSON?

Custom SQL selectors and referenceFormulation

It all started with me trying to use a custom SQL query in rml:logicalSource:

<#PersonTriples> a rr:TriplesMap ;
  rml:logicalSource [
    rml:source <#testDB> ;
    rr:sqlVersion rr:SQL2008 ;
    rml:referenceFormulation rr:SQL2008 ;
    rr:sqlQuery "SELECT name, email, product FROM surveys" ] ;
...

First, it could not find my query:

Exception in thread "main" java.lang.Error: The Logical Source of <http://example.com/base/#PersonTriples> does not include a SQL query nor a target table.
        at be.ugent.rml.records.RecordsFactory.getRDBsRecords(RecordsFactory.java:201)
        at be.ugent.rml.records.RecordsFactory.createRecords(RecordsFactory.java:87)
        at be.ugent.rml.Executor.getRecords(Executor.java:252)
        at be.ugent.rml.Executor.execute(Executor.java:58)
        at be.ugent.rml.cli.Main.main(Main.java:130)

A brief look-up in the sources revealed that rmlmapper actually expects rr:query instead of rr:sqlQuery. Moreover, the comparison table at http://rml.io/RML_R2RML.html mentions "rr:SQLQuery" which makes it even more confusing โ€“ "sql" should be in lower case there.

I think it still should be "rr:sqlQuery" as per R2RML specs.

Anyway, I replaced "rr:sqlQuery" with "rr:query", but then another error popped up:

Exception in thread "main" java.lang.Error: Unsupported rml:referenceFormulation for RDB source: http://www.w3.org/ns/r2rml#SQL2008
        at be.ugent.rml.records.RDBs.get(RDBs.java:60)
        at be.ugent.rml.records.RecordsFactory.getRDBsRecords(RecordsFactory.java:235)
        at be.ugent.rml.records.RecordsFactory.createRecords(RecordsFactory.java:87)
        at be.ugent.rml.Executor.getRecords(Executor.java:252)
        at be.ugent.rml.Executor.execute(Executor.java:58)
        at be.ugent.rml.cli.Main.main(Main.java:130)

It looks like it's indeed unsupported in rmlmapper judging by the source code, but it seems to be a valid RDB source and there's plenty examples with it throughout the RML specs (http://rml.io/spec.html).

Is it indeed all broken/unsupported or am I missing something?

Thank you!

is it possible to map TSV?

Hi there,
I have a TSV that I would like to map to RDF.
Is it possible to configure mapping of TSV to RDF? If yes, how?

there is
rml:referenceFormulation ql:CSV
but is there smth like rml:referenceFormulation ql:TSV ?

Thanks,
Milan

rr:ParentTriplesMap without join condition not working as described in the specification

Hi:

I was testing the <#TransportMapping> and the <#StopMapping> provided in the RML specification (http://rml.io/spec.html#example-input-0) and it seems that this implementation is not giving the expected results.

When using the last release of the rmlmapper-java (v4.3.3-r92) the result is the following one:

<http://trans.example.com/bus/25> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Transport>.
<http://trans.example.com/bus/25> <http://example.com/ns#type> <http://trans.example.com/vehicle/SingeDecker>.
<http://trans.example.com/bus/25> <http://example.com/ns#stop> <http://trans.example.com/stop/645>.
<http://trans.example.com/bus/25> <http://example.com/ns#stop> <http://trans.example.com/stop/651>.
<http://trans.example.com/bus/25> <http://example.com/ns#stop> <http://trans.example.com/stop/873>.
<http://trans.example.com/bus/25> <http://example.com/ns#stop> <http://trans.example.com/stop/651>.
<http://trans.example.com/bus/47> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Transport>.
<http://trans.example.com/bus/47> <http://example.com/ns#type> <http://trans.example.com/vehicle/DoubleDecker>.
<http://trans.example.com/bus/47> <http://example.com/ns#stop> <http://trans.example.com/stop/645>.
<http://trans.example.com/bus/47> <http://example.com/ns#stop> <http://trans.example.com/stop/651>.
<http://trans.example.com/bus/47> <http://example.com/ns#stop> <http://trans.example.com/stop/873>.
<http://trans.example.com/bus/47> <http://example.com/ns#stop> <http://trans.example.com/stop/651>.
<http://trans.example.com/stop/645> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Stop>.
<http://trans.example.com/stop/645> <http://example.com/ns#stop> "645"^^<http://www.w3.org/2001/XMLSchema#int>.
<http://trans.example.com/stop/645> <http://example.com/ns#stopLabel> "\n        Airport\n      ".
<http://trans.example.com/stop/651> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Stop>.
<http://trans.example.com/stop/651> <http://example.com/ns#stop> "651"^^<http://www.w3.org/2001/XMLSchema#int>.
<http://trans.example.com/stop/651> <http://example.com/ns#stopLabel> "\n        Conference center\n      ".
<http://trans.example.com/stop/873> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Stop>.
<http://trans.example.com/stop/873> <http://example.com/ns#stop> "873"^^<http://www.w3.org/2001/XMLSchema#int>.
<http://trans.example.com/stop/873> <http://example.com/ns#stopLabel> "\n        Central Park\n      ".
<http://trans.example.com/stop/651> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Stop>.
<http://trans.example.com/stop/651> <http://example.com/ns#stop> "651"^^<http://www.w3.org/2001/XMLSchema#int>.
<http://trans.example.com/stop/651> <http://example.com/ns#stopLabel> "\n        Conference center\n      ". 

This is not the behaviour described in the specification because it assigns all the stops to all the buses. So, for bus 25 we have stops 873, 645, 651 (twice) and the same stops for bus 47. Whereas, in the XML file, stop 645 is under bus 25, stop 873 under bus 47 and stop 651 under both buses.

However, when using the last release of the legacy implementation (RML-Mapper-v3.0.2) the output with the same RML mapping file and XML file is different and according to the specification.

<http://trans.example.com/stop/645> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Stop> .
<http://trans.example.com/stop/645> <http://example.com/ns#stop> "645"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://trans.example.com/stop/645> <http://example.com/ns#stopLabel> "Airport" .
<http://trans.example.com/stop/651> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Stop> .
<http://trans.example.com/stop/651> <http://example.com/ns#stop> "651"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://trans.example.com/stop/651> <http://example.com/ns#stopLabel> "Conference center" .
<http://trans.example.com/stop/873> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Stop> .
<http://trans.example.com/stop/873> <http://example.com/ns#stop> "873"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://trans.example.com/stop/873> <http://example.com/ns#stopLabel> "Central Park" .
<http://trans.example.com/bus/25> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Transport> . <http://trans.example.com/bus/25> <http://example.com/ns#stop> <http://trans.example.com/stop/645> .
<http://trans.example.com/bus/25> <http://example.com/ns#stop> <http://trans.example.com/stop/651> .
<http://trans.example.com/bus/25> <http://example.com/ns#type> <http://trans.example.com/vehicle/SingeDecker> .
<http://trans.example.com/bus/47> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#Transport> . <http://trans.example.com/bus/47> <http://example.com/ns#stop> <http://trans.example.com/stop/873> .
<http://trans.example.com/bus/47> <http://example.com/ns#stop> <http://trans.example.com/stop/651> .
<http://trans.example.com/bus/47> <http://example.com/ns#type> <http://trans.example.com/vehicle/DoubleDecker> .

Reading the Section 7 of the specification (http://rml.io/spec.html#relationships-among-logical-sources-rr-parenttriplesmap-rr-joincondition-rr-child-and-rr-parent), it says that a joinCondition is not needed when linking mappings with the same LogicalSource. Has this mechanism changed in the new library? Is it now mandatory to provide the joinCondition?

Predicates generated incorrectly when using Graphs

Using the following yarrrml mapping file:

prefixes:
  # Predefined
  gbfs: "http://example.com/terms#"
  geo: "http://www.w3.org/2003/01/geo/wgs84_pos#"
  ex: "http://example.com/"
  
sources:
  station_status:
    access: https://api-core.bikeshare.ae/gbfs/ar/station_status.json
    referenceFormulation: jsonpath
    iterator: $.data.stations[*]

mappings:
  station_status:
    graphs: ex:mygraph
    sources: station_status
    s: http://example.org/station/$(station_id)
    po:
      - [gbfs:num_docks_disabled, $(num_docks_disabled), xsd:integer]
      - [gbfs:num_docks_available, $(num_docks_available), xsd:integer]

I generated the RML file shown below through matey.

@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@prefix map: <http://mapping.example.com/>.

map:gm_0 a rr:GraphMap;
    rr:template "http://example.com/mygraph".
map:map_station_status_0 rml:logicalSource map:source_0;
    a rml:TriplesMap;
    rdfs:label "station_status";
    rr:subjectMap map:s_0;
    rr:predicateObjectMap map:pom_0, map:pom_1.
map:om_0 a rr:ObjectMap;
    rr:template "{num_docks_disabled}";
    rr:termType rr:Literal;
    rr:datatype <http://www.w3.org/2001/XMLSchema#integer>.
map:om_1 a rr:ObjectMap;
    rr:template "{num_docks_available}";
    rr:termType rr:Literal;
    rr:datatype <http://www.w3.org/2001/XMLSchema#integer>.
map:pm_0 a rr:PredicateMap;
    rr:constant <http://example.com/terms#num_docks_disabled>.
map:pm_1 a rr:PredicateMap;
    rr:constant <http://example.com/terms#num_docks_available>.
map:pom_0 a rr:PredicateObjectMap;
    rr:predicateMap map:pm_0;
    rr:objectMap map:om_0.
map:pom_1 a rr:PredicateObjectMap;
    rr:predicateMap map:pm_1;
    rr:objectMap map:om_1.
map:s_0 a rr:SubjectMap;
    rr:template "http://example.org/station/{station_id}";
    rr:graphMap map:gm_0.
map:source_0 a rml:LogicalSource;
    rdfs:label "station_status";
    rml:source "https://api-core.bikeshare.ae/gbfs/ar/station_status.json";
    rml:iterator "$.data.stations[*]";
    rml:referenceFormulation ql:JSONPath.

When using matey, the linked data is correctly generated as following:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix sd: <http://www.w3.org/ns/sparql-service-description#>.
@prefix gbfs: <http://example.com/terms#>.
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>.
@prefix ex: <http://example.com/>.

ex:mygraph {
<http://example.org/station/3> gbfs:num_docks_disabled "0"^^xsd:integer;
    gbfs:num_docks_available "13"^^xsd:integer
}
ex:mygraph {
<http://example.org/station/4> gbfs:num_docks_disabled "0"^^xsd:integer;
    gbfs:num_docks_available "5"^^xsd:integer
}
ex:mygraph {
<http://example.org/station/5> gbfs:num_docks_disabled "0"^^xsd:integer;
    gbfs:num_docks_available "9"^^xsd:integer
}
ex:mygraph {
<http://example.org/station/6> gbfs:num_docks_disabled "0"^^xsd:integer;
    gbfs:num_docks_available "5"^^xsd:integer
}
...

However, when I try to use rmlmapper-java to generate linked data from the generated RML file using the following command: java -jar rmlmapper-0.1.4-r19-jar-with-dependencies.jar -m rml.txt -o outfile. The predicates are incorrect (same as subject, see below).

<http://example.org/station/3> <http://example.org/station/3> "0"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/3> <http://example.org/station/3> "13"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/4> <http://example.org/station/4> "0"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/4> <http://example.org/station/4> "5"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/5> <http://example.org/station/5> "0"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/5> <http://example.org/station/5> "9"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/6> <http://example.org/station/6> "0"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/6> <http://example.org/station/6> "5"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/7> <http://example.org/station/7> "0"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/7> <http://example.org/station/7> "8"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/8> <http://example.org/station/8> "0"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/8> <http://example.org/station/8> "8"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/9> <http://example.org/station/9> "0"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
<http://example.org/station/9> <http://example.org/station/9> "16"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/mygraph>.
...

When not using graphs, I get the correct output:

<http://example.org/station/3> <http://example.com/terms#num_docks_disabled> "0"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/3> <http://example.com/terms#num_docks_available> "13"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/4> <http://example.com/terms#num_docks_disabled> "0"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/4> <http://example.com/terms#num_docks_available> "5"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/5> <http://example.com/terms#num_docks_disabled> "0"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/5> <http://example.com/terms#num_docks_available> "9"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/6> <http://example.com/terms#num_docks_disabled> "0"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/6> <http://example.com/terms#num_docks_available> "5"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/7> <http://example.com/terms#num_docks_disabled> "0"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/7> <http://example.com/terms#num_docks_available> "8"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/8> <http://example.com/terms#num_docks_disabled> "0"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/8> <http://example.com/terms#num_docks_available> "8"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/9> <http://example.com/terms#num_docks_disabled> "0"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/9> <http://example.com/terms#num_docks_available> "16"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/10> <http://example.com/terms#num_docks_disabled> "0"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/10> <http://example.com/terms#num_docks_available> "6"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/11> <http://example.com/terms#num_docks_disabled> "0"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/11> <http://example.com/terms#num_docks_available> "4"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://example.org/station/12> <http://example.com/terms#num_docks_disabled> "0"^^<http://www.w3.org/2001/XMLSchema#integer>.

Not accepting URI/prefixed tags

I got the example provided in the XML tutorial to work, but I'm having trouble once I switch to our actual data. Here is the snippet of data I am trying to run:

<?xml version="1.0" encoding="UTF-8"?>

<rdf:RDF
   xmlns:ns2="http://rdaregistry.info/Elements/w/"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
  <rdf:Description rdf:about="https://trellis.sinopia.io/repository/washington/1a09069d-8165-42ae-bfc0-f6b269b4d34b">
    <ns2:P10223 xml:lang="en">Beyond Einstein</ns2:P10223>
  </rdf:Description>
</rdf:RDF>

And this is the mapping I'm using:

@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <http://example.org/rules/> .
@prefix schema: <http://schema.org/> .
@prefix dbo: <http://dbpedia.org/ontology/> .
@prefix ns2: <http://rdaregistry.info/Elements/w/>.
@prefix bf: <http://id.loc.gov/ontologies/bibframe/>.

:TriplesMap a rr:TriplesMap;
  rml:logicalSource [
    rml:source "example.xml";
    rml:referenceFormulation ql:XPath;
    rml:iterator "/rdf:RDF/rdf:Description"
  ].

:TriplesMap rr:subjectMap [
  rml:reference "@rdf:about";
  rr:class bf:Title
].

:TriplesMap rr:predicateObjectMap [
  rr:predicate ns2:P10223;
  rr:objectMap [
    rml:reference "ns2:P10223"
  ]
].

But this mapping generates no triples.

However, if I modify the XML to have simple tags:

<?xml version="1.0" encoding="UTF-8"?>

<works
   xmlns:ns2="http://rdaregistry.info/Elements/w/"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
  <work id="https://trellis.sinopia.io/repository/washington/1a09069d-8165-42ae-bfc0-f6b269b4d34b">
    <title xml:lang="en">Beyond Einstein</title>
  </work>
</works>

and the RML to match:

@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <http://example.org/rules/> .
@prefix schema: <http://schema.org/> .
@prefix dbo: <http://dbpedia.org/ontology/> .
@prefix ns2: <http://rdaregistry.info/Elements/w/>.
@prefix bf: <http://id.loc.gov/ontologies/bibframe/>.

:TriplesMap a rr:TriplesMap;
  rml:logicalSource [
    rml:source "example.xml";
    rml:referenceFormulation ql:XPath;
    rml:iterator "/works/work"
  ].

:TriplesMap rr:subjectMap [
  rml:reference "@id";
  rr:class bf:Title
].

:TriplesMap rr:predicateObjectMap [
  rr:predicate ns2:P10223;
  rr:objectMap [
    rml:reference "title"
  ]
].

Then I get the desired output:

<https://trellis.sinopia.io/repository/washington/1a09069d-8165-42ae-bfc0-f6b269b4d34b> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://id.loc.gov/ontologies/bibframe/Title>.
<https://trellis.sinopia.io/repository/washington/1a09069d-8165-42ae-bfc0-f6b269b4d34b> <http://rdaregistry.info/Elements/w/P10223> "Beyond Einstein".

Is this an issue with RML mapper, or am I doing something wrong?

Output Format

Hi,

How to set the output format using the java code. I am getting the output as RDF triples now. I would like to get the output as JSON-LD. I would like to do this from the code. Do we need to define it somewhere with executor object ? Could you please help me on this ?

How to setup the config is not clear

Apparently there is 2 way to pass arguments to the program:

  • config.properties file
  • CommandLine client

We can provide a mapping file in the config.properties file and in the command line. It is working when the mapping file is provided only in the config.properties. Same for outputfile, which is confusing

Output path

At the moment, when I give for example file.txt as output argument, a file file.txt.nq is generated. I think it would be useful if the program used the given program argument as path for the output file just as in the old RML-Mapper.

Running failed

Dear,
This is what I have when running the rmlmapper-java:
C:\Users\Justine\git\rmlmapper-java\target>java -jar rmlmapper-4.2.0-r66.jar -m GetAllFDESShortData.xml -o output.ttl -v
Looking for file GetAllFDESShortData.xml in basePath C:\Users\Justine\git\rmlmapper-java\target
Registered service class org.eclipse.rdf4j.rio.datatypes.XMLSchemaDatatypeHandler
Registered service class org.eclipse.rdf4j.rio.datatypes.RDFDatatypeHandler
Registered service class org.eclipse.rdf4j.rio.datatypes.DBPediaDatatypeHandler
Registered service class org.eclipse.rdf4j.rio.datatypes.VirtuosoGeometryDatatypeHandler
Registered service class org.eclipse.rdf4j.rio.datatypes.GeoSPARQLDatatypeHandler
Registered service class org.eclipse.rdf4j.rio.languages.RFC3066LanguageHandler
Registered service class org.eclipse.rdf4j.rio.languages.BCP47LanguageHandler
Reading from C:\Users\Justine\git\rmlmapper-java\target\GetAllFDESShortData.xml
Registered service class org.eclipse.rdf4j.rio.binary.BinaryRDFParserFactory
Registered service class org.eclipse.rdf4j.rio.jsonld.JSONLDParserFactory
Registered service class org.eclipse.rdf4j.rio.n3.N3ParserFactory
Registered service class org.eclipse.rdf4j.rio.nquads.NQuadsParserFactory
Registered service class org.eclipse.rdf4j.rio.ntriples.NTriplesParserFactory
Registered service class org.eclipse.rdf4j.rio.rdfjson.RDFJSONParserFactory
Registered service class org.eclipse.rdf4j.rio.rdfxml.RDFXMLParserFactory
Registered service class org.eclipse.rdf4j.rio.trig.TriGParserFactory
Registered service class org.eclipse.rdf4j.rio.trix.TriXParserFactory
Registered service class org.eclipse.rdf4j.rio.turtle.TurtleParserFactory
org.eclipse.rdf4j.rio.RDFParseException: IRI included an unencoded space: '32' [line 1]
at org.eclipse.rdf4j.rio.helpers.RDFParserHelper.reportError(RDFParserHelper.java:322)
at org.eclipse.rdf4j.rio.helpers.AbstractRDFParser.reportError(AbstractRDFParser.java:684)
at org.eclipse.rdf4j.rio.turtle.TurtleParser.reportError(TurtleParser.java:1309)
at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseURI(TurtleParser.java:900)
at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseValue(TurtleParser.java:588)
at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseSubject(TurtleParser.java:429)
at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseTriples(TurtleParser.java:370)
at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseStatement(TurtleParser.java:239)
at org.eclipse.rdf4j.rio.turtle.TurtleParser.parse(TurtleParser.java:201)
at org.eclipse.rdf4j.rio.turtle.TurtleParser.parse(TurtleParser.java:143)
at org.eclipse.rdf4j.rio.Rio.parse(Rio.java:298)
at be.ugent.rml.Utils.readTurtle(Utils.java:244)
at be.ugent.rml.Utils.readTurtle(Utils.java:253)
at be.ugent.rml.cli.Main.main(Main.java:126)
Looking for file functions.ttl in basePath C:\Users\Justine\git\rmlmapper-java\target
Reading from C:\Users\Justine\AppData\Local\Temp\file9057145616842695711temp.ttl
Exception in thread "main" java.lang.NullPointerException
at be.ugent.rml.store.RDF4JStore.getQuads(RDF4JStore.java:70)
at be.ugent.rml.Initializer.getAllTriplesMaps(Initializer.java:44)
at be.ugent.rml.Initializer.(Initializer.java:24)
at be.ugent.rml.Executor.(Executor.java:47)
at be.ugent.rml.cli.Main.main(Main.java:186)

How can I correct it, please? Have I missed something?
Thanks for your reply.

Graphs not generated when using functions

I mapped the following yarrrml file to rml: mapping.yaml.txt

This gave me the following rml output: mapping.rml.txt

Then I used the following command to map the RML to RDF: java -jar rmlmapper-0.1.6.jar -m ./mapping.rml -o ./out/out.txt -f ./functions/functions.ttl

I don't get any graphs in my output however, I just get nTriples while I should get nQuads according to my yarrrml file.

CSV on the Web description implementation

Hi,
are there any plan for implementing the support of csvw:Table as rml:source in logical source?

Are there alternatives to customize separator and other dialect related properties (e.g. encoding and header presence) in parsing csv?

Tests failing

mvn clean install fails due to tests errors:

  Mapper_RDBs_Test.evaluate_XXXX_RDBs_PostgreSQL:652 ยป PSQL The connection attem...
  Mapper_RDBs_Test.evaluate_XXXX_RDBs_SQLServer:829->executeSQL:967 ยป SQLServer ...
  Mapper_RDBs_Test.evaluate_0002i_RDBs_SQLServer ยป  Unexpected exception, expect...

Tests run: 222, Failures: 0, Errors: 72, Skipped: 7

Here is my maven -version:

Apache Maven 3.5.2
Maven home: /usr/share/maven
Java version: 1.8.0_181, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-34-generic", arch: "amd64", family: "unix"

Do you plan to use Docker to make it run? To make sure it is running in the same environment for everyone using it

Please provide working example

Hi everyone,

it's currently really hard to get into RML. I tried with the examples found on https://rml.io/docs/rml/examples/ and on https://rml.io/specs/rml/. I also checked some issues where people asked for complete examles - unfortunately all without luck. It would be much appreciated if you could just provide a simple but working example.

Here is what I have right now. The .xml source I want to map looks like this:
input.xml

<?xml version = "1.0"?>
<Events>
 <Exhibition id="398">
 <Venue>STAM</Venue>
  <Location>
   <lat>51.076891</lat>
   <long>3.717222</long>
  </Location>
 </Exhibition>
 <Exhibition id="428">
 <Venue>ABC</Venue>
  <Location>
   <lat>55.076891</lat>
   <long>35.717222</long>
  </Location>
 </Exhibition>
</Events>

My mapping defintions look like this:
mapping.ttl

@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix crml:   <http://semweb.mmlab.be/ns/crml#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@prefix ex: <http://ex.com/>.
@base <http://example.com/base>.

<#EventMapping>
 a rr:TriplesMap;
  rml:logicalSource [
    rml:source "./input.xml";
    rml:referenceFormulation ql:XPath;
    rml:iterator "/Events/Exhibition" ];

  rr:subjectMap [
    rr:template "http://ex.com/{@id}";
  ];
	
  rr:predicateObjectMap [
	rr:predicate ex:hasName;

	rr:objectMap [
		rml:reference "eventName";
		]
  ].

I use the mapper like so:
java -jar .\rmlmapper.jar -m ".\mapping.ttl" -o ".\output.ttl"

The mapper runs without errors. The output file is created but is empty. Any ideas why? Btw I'm using your latest release. Appreciate your help!

A complete example

I tried to use the complete example here. The author mentioned that it is working with the older version of RML-Mapper however after running the same code for the newer version, it is not working. It would be of great help if you can provide a complete example for the latest version. @pheyvaer

rr:Template does not URLfy strings

When using the template construct in a predicate object map the json values are not URLfied as when using the same expression in a subject map.

Predicate object map example:

rr:predicateObjectMap [
rr:predicate etvonto:hasForm;
rr:objectMap [
rr:template "http://easytv.linkeddata.es/resource/LinguisticExpressionItem/{Sls}{Url}{Word}";
rr:termType rr:IRI
]
]

Resulting Triple (see difference between subject and predicate generation):

http://easytv.linkeddata.es/resource/SignedLinguisticExpression/this%20movie%20three%20I%20have%20seen%20timeshttps%3A%2F%2Fmedia.spreadthesign.com%2Fvideo%2Fmp4%2F1%2F105750.mp4 https://w3id.org/def/easytv#decomposition <http://easytv.linkeddata.es/resource/LinguisticExpressionItem/this movie three I have seen timeshttps://media.spreadthesign.com/video/mp4/1/105750.mp41> null

Trouble writing rml:reference for JSON data

Here is an example of the JSON data I am trying to write RML for:

{
  "@graph": [
    {
      "@id": "https://trellis.sinopia.io/repository/washington/0a4ea663-988e-474b-a25e-659b935b65a9",
      "P10004": [
        "http://id.loc.gov/authorities/genreForms/gf2015026020",
        "http://id.loc.gov/authorities/genreForms/gf2014026339"
      ]
    }
  ],
  "@context": {
    "P10004": {
      "@id": "http://rdaregistry.info/Elements/w/P10004",
      "@type": "@id"
    }
  }
}

Here is the mapping I have written:

@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://example.org/rules/> .
@prefix ns1: <http://rdaregistry.info/Elements/w/> .

ex:TestMap1 a rr:TriplesMap;
  rml:logicalSource [
    rml:source "/jsondata.json";
    rml:referenceFormulation ql:JSONPath;
    rml:iterator "$"
  ].

  ex:TestMap1 rr:subjectMap [
    rml:reference "@graph.@id"
  ].

  ex:TestMap1 rr:predicateObjectMap [
    rr:predicate ns1:P10004;
    rr:objectMap [
      rml:reference "@graph.P10004"
    ]
  ].

ex:TestMap2 a rr:TriplesMap;
  rml:logicalSource [
    rml:source "/jsondata.json";
    rml:referenceFormulation ql:JSONPath;
    rml:iterator "$"
  ].

  ex:TestMap2 rr:subjectMap [
    rml:reference "@context.P10004.@id"
  ].

  ex:TestMap2 rr:predicateObjectMap [
    rr:predicate rdfs:label;
    rr:objectMap [
      rml:reference "@context.P10004.@type"
    ]
  ].

When I try to run this, this is my output:

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<http://rdaregistry.info/Elements/w/P10004> rdfs:label "@id" .

It generates triples for TestMap2, which references the context section, but not TestMap1 with the graph section. I'm not sure what I'm doing wrong. Any help?

rmlmapper not generating outputfile when mapping the first column of input file

As requested in a previous issue:

rmlmapper is not producing an output file even though there are no errors given (or with the newest version of rmlmapper, it produces errors saying that there are no variables to complete the template). After trouble shooting I found out that rmlmapper seems to have issues when variables are in the first column of the input file. This issue was resolved for two inputfiles when I simply added a random first column to the data.

Files.zip

Primary interlinking and java.lang.OutOfMemoryError

Hi!

I have a simple table "surveys" (containing some survey data, in a postgresql DB) with the following columns (simplified for this report):

  • id - id of the survey (int)
  • name - name of the person taking the survey (string)
  • product - name of the product used by the person (string)

I would like to create a couple of resources while mapping it to RDF: "Person" and "Product". Additionally, I would like to add statements like "person -- usesProduct -- product".

So I'm using the following mapping:

<#int_test> a d2rq:Database .

<#PersonTriples> a rr:TriplesMap ;

  rml:logicalSource [
    rml:source <#int_test> ;
    rr:sqlVersion rr:SQL2008 ;
    rr:tableName "surveys" ] ;

  rr:subjectMap [
    rr:termType rr:BlankNode ;
    rr:class ex:Person ] ;

  rr:predicateObjectMap [
    rr:predicate foaf:name ;
    rr:objectMap [
      rr:template "{name}" ;
      rr:termType rr:Literal ] ] ;

  rr:predicateObjectMap [
    rr:predicate ex:usesProduct ;
    rr:objectMap [
      rr:parentTriplesMap <#ProductTriples> ] ] .

<#ProductTriples> a rr:TriplesMap ;

  rml:logicalSource [
    rml:source <#int_test> ;
    rr:sqlVersion rr:SQL2008 ;
    rr:tableName "surveys" ] ;

  rr:subjectMap [
    rr:termType rr:BlankNode ;
    rr:class ex:Product ] ;

  rr:predicateObjectMap [
    rr:predicate ex:productName ;
    rr:objectMap [
      rr:template "{product}" ;
      rr:termType rr:Literal ] ] .

There are no data sources (columns) to produce conventional URIs neither for ex:Person, nor for ex:Product resources, as you can see. So I'm using blank nodes for them.

When I'm running the mapping:

$ java -jar rmlmapper-4.0.0-r48-jar-with-dependencies.jar -m mapping.rml.ttl

it runs for some time (w/o output) and then dies with:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:3332)
	at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
	at java.lang.StringBuilder.append(StringBuilder.java:136)
	at be.ugent.rml.Utils.toNQuads(Utils.java:339)
	at be.ugent.rml.cli.Main.writeOutput(Main.java:203)
	at be.ugent.rml.cli.Main.main(Main.java:138)

If I comment out rr:predicateObjectMap statement with rr:parentTriplesMap above, there's no problems and I get the RDF output (but naturally, without "usesProduct" statements).

Could it be because I'm using blank nodes?

If so, how would you produce "normal" URIs for these resources? I could use a template with some UUID generator, perhaps. But I could not figure out how to do that.

(This report applies to the rmlmapper 9a64f3e (latest commit), but was reproducible in earlier versions too).

Feature requests

I was wondering if you have any ETA on the output formats support (turtle, trig) as it would be a very useful feature. At the moment I have the output myself to another data format.

I also saw conditions in the future releases list. Does this mean that conditions don't work with the rmlmapper-java at the moment?

Maven build failure

Hi,

I would like to use your library in my project. Since I did not find your library to be available in the public Maven repository, I have followed two approaches:

  1. Use jitpack.io to include the rmlmapper in my Gradle build
  2. Use the local Maven repository

Unfortunately, both approaches fail due to the same Maven build error of your library:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 37.891 s
[INFO] Finished at: 2018-12-19T15:13:18Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project rmlmapper: Could not resolve dependencies for project be.ugent.rml:rmlmapper:jar:4.1.0: Could not find artifact com.github.jsonld-java.jsonld-java:jsonld-java:bundle:0.11.1 in jitpack.io (https://jitpack.io) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

For a complete log, you can have a look at:

In your most recent release v4.3.0, the issue occurs with version 0.12.0 of the com.github.jsonld-java.jsonld-java bundle instead of version 0.11.1 as stated above. But this seems to be the equivalent problem.

As I said, the exact issue occurs as well if I locally clone your repository and build the project with mvn install.

I tracked down the issue to occur since commit 020094b, where the hdt support has been added. In this commit, the Maven pom.xml has been adjusted to include a dependency to the third-party hdt library.
The previous commit efbd731 can be built succesfully as the corresponding Jitpack log also indicates.

Can you please have a look at this build failure. How do you currently build the project without having the same error? Thanks.

Mapping

Hi, I am trying to create a mapping file for Catalogs.xml .
This is Catalogs.xml content:

<catalog>
<product description="Cardigan Sweater" product_image="cardigan.jpg">
 <catalog_item gender="Men's">
            <item_number>QWZ5671</item_number>
            <price>39.95</price>
            <size description="Medium">
                <color_swatch image="red_cardigan.jpg">Red</color_swatch>
                <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>
            </size>
            <size description="Large">
                <color_swatch image="red_cardigan.jpg">Red</color_swatch>
                <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>
            </size>
        </catalog_item>
        <catalog_item gender="Women's">
            <item_number>RRX9856</item_number>
            <price>42.50</price>
            <size description="Small">
                <color_swatch image="red_cardigan.jpg">Red</color_swatch>
                <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>
                <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>
            </size>
            <size description="Medium">
                <color_swatch image="red_cardigan.jpg">Red</color_swatch>
                <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>
                <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>
                <color_swatch image="black_cardigan.jpg">Black</color_swatch>
            </size>
            <size description="Large">
                <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>
                <color_swatch image="black_cardigan.jpg">Black</color_swatch>
            </size>
            <size description="Extra Large">
                <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>
                <color_swatch image="black_cardigan.jpg">Black</color_swatch>
            </size>
        </catalog_item>
    </product>
    <product description="Turkish Jeans" product_image="cardigan.jpg">
        <catalog_item gender="Men's">
            <item_number>FDE456</item_number>
            <price>22</price>
            <size description="Small">
                <color_swatch image="red_cardigan.jpg">Blue</color_swatch>
                <color_swatch image="burgundy_cardigan.jpg">Black</color_swatch>
            </size>
            <size description="Extra Small">
                <color_swatch image="red_cardigan.jpg">White</color_swatch>
                <color_swatch image="burgundy_cardigan.jpg">Transparent</color_swatch>
            </size>
        </catalog_item>
        <catalog_item gender="Women's">
            <item_number>LKO478</item_number>
            <price>35</price>
            <size description="Small">
                <color_swatch image="red_cardigan.jpg">Red</color_swatch>
                <color_swatch image="navy_cardigan.jpg">Blue</color_swatch>
                <color_swatch image="burgundy_cardigan.jpg">Orange</color_swatch>
            </size>
            <size description="Large">
                <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>
                <color_swatch image="black_cardigan.jpg">Black</color_swatch>
            </size>
            <size description="Extra Large">
                <color_swatch image="burgundy_cardigan.jpg">Pink</color_swatch>
                <color_swatch image="black_cardigan.jpg">Yellow</color_swatch>
            </size>
        </catalog_item>
    </product>
</catalog>

This is current catalogs_mapping.ttl content:

@Prefix rr: http://www.w3.org/ns/r2rml#.
@Prefix rml: http://semweb.mmlab.be/ns/rml#.
@Prefix ex: http://example.com/ns#.
@Prefix ql: http://semweb.mmlab.be/ns/ql#.
@Prefix transit: http://vocab.org/transit/terms/.
@Prefix xsd: http://www.w3.org/2001/XMLSchema#.
@Prefix rdfs: http://www.w3.org/2000/01/rdf-schema#.
@Prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#.

rr:ProductMapping
rml:logicalSource [
rml:source "Catalogs.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "/catalog/product"
];

rr:subjectMap [
    rr:template "http://ex.com/{@description}";
    rr:class ex:product
];

rr:predicateObjectMap [
    rr:predicate ex:catalog_item;
        rr:objectMap [
            rr:parentTriplesMap rr:CatalogItemMapping
        ]
 ].

rr:CatalogItemMapping
rml:logicalSource [
rml:source "Catalogs.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "/catalog/product/catalog_item"
];

rr:subjectMap [
    rr:template "http://ex.com/{@gender}";
    rr:class ex:gender
];

rr:predicateObjectMap [
    rr:predicate ex:item_number;
        rr:objectMap [
            rml:reference "item_number"
        ]
 ];

 rr:predicateObjectMap [
         rr:predicate ex:price;
             rr:objectMap [
                 rml:reference "price"
             ]
      ];

 rr:predicateObjectMap [
    rr:predicate ex:Sizes;
        rr:objectMap [
            rr:parentTriplesMap rr:SizesMapping
                ]
            ].

rr:SizesMapping
rml:logicalSource [
rml:source "Catalogs.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "/catalog/product/catalog_item/size"
];

rr:subjectMap [
    rr:template "http://ex.com/{@description}";
    rr:class ex:size_description
];

rr:predicateObjectMap [
    rr:predicate ex:color_swatch;
        rr:objectMap [
            rml:reference "color_swatch"
        ]
 ].

And this is the result of convertion:

<http://ex.com/Cardigan%20Sweater> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#product> null
<http://ex.com/Cardigan%20Sweater> <http://example.com/ns#catalog_item> <http://ex.com/Men%27s> null
<http://ex.com/Cardigan%20Sweater> <http://example.com/ns#catalog_item> <http://ex.com/Women%27s> null
<http://ex.com/Turkish%20Jeans> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#product> null
<http://ex.com/Turkish%20Jeans> <http://example.com/ns#catalog_item> <http://ex.com/Men%27s> null
<http://ex.com/Turkish%20Jeans> <http://example.com/ns#catalog_item> <http://ex.com/Women%27s> null
<http://ex.com/Men%27s> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#gender> null
<http://ex.com/Men%27s> <http://example.com/ns#item_number> "QWZ5671" null
<http://ex.com/Men%27s> <http://example.com/ns#price> "39.95" null
<http://ex.com/Men%27s> <http://example.com/ns#Sizes> <http://ex.com/Medium> null
<http://ex.com/Men%27s> <http://example.com/ns#Sizes> <http://ex.com/Large> null
<http://ex.com/Men%27s> <http://example.com/ns#Sizes> <http://ex.com/Small> null
<http://ex.com/Men%27s> <http://example.com/ns#Sizes> <http://ex.com/Extra%20Large> null
<http://ex.com/Men%27s> <http://example.com/ns#Sizes> <http://ex.com/Extra%20Small> null
<http://ex.com/Women%27s> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#gender> null
<http://ex.com/Women%27s> <http://example.com/ns#item_number> "RRX9856" null
<http://ex.com/Women%27s> <http://example.com/ns#price> "42.50" null
<http://ex.com/Women%27s> <http://example.com/ns#Sizes> <http://ex.com/Medium> null
<http://ex.com/Women%27s> <http://example.com/ns#Sizes> <http://ex.com/Large> null
<http://ex.com/Women%27s> <http://example.com/ns#Sizes> <http://ex.com/Small> null
<http://ex.com/Women%27s> <http://example.com/ns#Sizes> <http://ex.com/Extra%20Large> null
<http://ex.com/Women%27s> <http://example.com/ns#Sizes> <http://ex.com/Extra%20Small> null
<http://ex.com/Men%27s> <http://example.com/ns#item_number> "FDE456" null
<http://ex.com/Men%27s> <http://example.com/ns#price> "22" null
<http://ex.com/Women%27s> <http://example.com/ns#item_number> "LKO478" null
<http://ex.com/Women%27s> <http://example.com/ns#price> "35" null
<http://ex.com/Medium> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#size_description> null
<http://ex.com/Medium> <http://example.com/ns#color_swatch> "Red" null
<http://ex.com/Medium> <http://example.com/ns#color_swatch> "Burgundy" null
<http://ex.com/Large> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#size_description> null
<http://ex.com/Large> <http://example.com/ns#color_swatch> "Red" null
<http://ex.com/Large> <http://example.com/ns#color_swatch> "Burgundy" null
<http://ex.com/Small> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#size_description> null
<http://ex.com/Small> <http://example.com/ns#color_swatch> "Red" null
<http://ex.com/Small> <http://example.com/ns#color_swatch> "Navy" null
<http://ex.com/Small> <http://example.com/ns#color_swatch> "Burgundy" null
<http://ex.com/Medium> <http://example.com/ns#color_swatch> "Navy" null
<http://ex.com/Medium> <http://example.com/ns#color_swatch> "Black" null
<http://ex.com/Large> <http://example.com/ns#color_swatch> "Navy" null
<http://ex.com/Large> <http://example.com/ns#color_swatch> "Black" null
<http://ex.com/Extra%20Large> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#size_description> null
<http://ex.com/Extra%20Large> <http://example.com/ns#color_swatch> "Burgundy" null
<http://ex.com/Extra%20Large> <http://example.com/ns#color_swatch> "Black" null
<http://ex.com/Small> <http://example.com/ns#color_swatch> "Blue" null
<http://ex.com/Small> <http://example.com/ns#color_swatch> "Black" null
<http://ex.com/Extra%20Small> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/ns#size_description> null
<http://ex.com/Extra%20Small> <http://example.com/ns#color_swatch> "White" null
<http://ex.com/Extra%20Small> <http://example.com/ns#color_swatch> "Transparent" null
<http://ex.com/Small> <http://example.com/ns#color_swatch> "Orange" null
<http://ex.com/Extra%20Large> <http://example.com/ns#color_swatch> "Pink" null
<http://ex.com/Extra%20Large> <http://example.com/ns#color_swatch> "Yellow" null

As you can see from the result, it is not obvious that which Men's and Woman's subjects belong to which product. In order to solve this problem I wanted to add the name of product to the object of catalog_item predicate (e.g Men's_Cardigan_Sweater). But since, my iterator is "/catalog/product/catalog_item" in CatalogItemMapping, I cannot get the "description" of the product.

So my question is, is there a way to reach to the out of iterator?
Or is there a better mapping file for this specific xml?

Log lines should be printed to stderr, not to stdout

Without an --outputfile, the CLI prints the resulting serialized facts to stdout. Since the logs are also printed to stdout, you can't directly use the resulting output without filtering out logging information.

Log lines should be printed to stderr instead.

Problem in basic code execution as external library

When I try to execute the code you provide in the readme I got the following error:

SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
null
java.io.FileNotFoundException: null
	at be.ugent.rml.Utils.getFile(Utils.java:138)
	at be.ugent.rml.Utils.getFile(Utils.java:89)
	at be.ugent.rml.functions.FunctionLoader.<init>(FunctionLoader.java:57)
	at be.ugent.rml.functions.FunctionLoader.<init>(FunctionLoader.java:47)
	at be.ugent.rml.Initializer.<init>(Initializer.java:28)
	at be.ugent.rml.Executor.<init>(Executor.java:47)
	at be.ugent.rml.Executor.<init>(Executor.java:39)
	at Main.main(Test.java:30)

As for the mappings I have tested them with the standalone jar and they run correctly. I have imported the same jar as well as the Jena Libraries.

Generating classes for empty blank nodes

Our mapping requires the use of a lot of blank nodes, and each of those blank nodes is classed in some way. For example:

ex:WorkMonographMap a rr:TriplesMap;
  rml:logicalSource [
    rml:source "/exampleData.xml";
    rml:referenceFormulation ql:XPath;
    rml:iterator "/RDF/Description"
  ].

  ex:WorkMonographMap rr:subjectMap [
    rml:reference "@about";
    rr:class bf:Work
  ].

    ex:WorkMonographMap rr:predicateObjectMap [
    rr:predicate bf:title;
    rr:objectMap [
      rr:parentTriplesMap ex:VariantTitleMap
    ]
  ].

ex:VariantTitleMap a rr:TriplesMap;
  rml:logicalSource [
    rml:source "/exampleData.xml";
    rml:referenceFormulation ql:XPath;
    rml:iterator "/RDF/Description"
  ].

  ex:VariantTitleMap rr:subjectMap [
    rr:termType rr:BlankNode;
    rr:class bf:VariantTitle
  ].

  ex:VariantTitleMap rr:predicateObjectMap [
    rr:predicate bf:mainTitle;
    rr:objectMap [
      rml:reference "P10086"
    ]
  ].

This works out great most of the time, but if we use this mapping on a record that (in this example) doesn't have a variant title, then we end up with a blank node like this:

<record>
  bf:title _:5 .

_:5 a bf:VariantTitle .

that only contain the class for an otherwise empty blank node. Is there any way to prevent these unnecessary blank nodes from generating?

Tests stuck on database startup complete

When trying to compile version 0.2.0of the rmlmapper, the test keeps hanging on [main] INFO ch.vorburger.mariadb4j.DB - Database startup complete. not allowing me to build the rmlmapper into a jar. I skipped the tests for now but I guess i'me not supposed to do that.

question regarding functions: transform strings for IRI creation

Hi! I would like to transform all string values of a TSV column into an IRI. The problem is the string values contain several not allowed characters such as spaces, commas, (round) brackets, etc. I would like to transform them as follows:

  • remove all commas
  • replace "(" by "-"
  • remove all ")"
  • use PascalCase (or camelCase) over string

example string input: "an example, string (remark)"
output IRI: <http://mydomain.org/data#AnExampleString-remark>

I experimented a little bit with a single function as described in the FNO spec. I copied the functions.ttl and GrelFunctions.jar from this repo into the repo where the RML-mapper jar is (dynamic loading). On execution, the RML-mapper returns an error:

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.rangeCheck(ArrayList.java:653)
        at java.util.ArrayList.get(ArrayList.java:429)
        at be.ugent.rml.functions.DynamicMultipleRecordsFunctionExecutor.execute(DynamicMultipleRecordsFunctionExecutor.java:66)
        at be.ugent.rml.functions.AbstractSingleRecordFunctionExecutor.execute(AbstractSingleRecordFunctionExecutor.java:16)
        at be.ugent.rml.termgenerator.LiteralGenerator.generate(LiteralGenerator.java:54)
        at be.ugent.rml.Executor.generatePredicateObjectGraphs(Executor.java:192)
        at be.ugent.rml.Executor.executeWithFunction(Executor.java:150)
        at be.ugent.rml.Executor.execute(Executor.java:77)
        at be.ugent.rml.cli.Main.main(Main.java:223)
        at be.ugent.rml.cli.Main.main(Main.java:30)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.