You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
One mapping file for multiple input source files #161
I have thousands of XML files which have same structure, i.e. one RML file is enough to process all of them. To use RML, I need to hard-code XML file names in the RML mapping file. I am wondering whether it is possible to generalize the mapping file to let it work for multiple XML files in a configurable way. Currently, I wrote a wrapper script that copies these XML files to a temp name, which is hard-coded in the RML file as rml:source. But it is quite ugly and not scalable.
Any suggestions would be much appreciated. Thanks.
RML mapping rules are RDF so you can edit the RDF edit programmatically as well.
If you read the RDF with RDF libraries such as RDFLib in Python, RDF/JS in Node, etc. you can programmatically generate RML mapping rules and pass them to the RMLMapper.
If you have any questions, feel free to reach out!
Thanks for your quick reply! Yes, the way you suggested would work as well. For my use case, it would mean that I need to generate a lot of temp RML files that contain just different XML file names.
Wouldn't it be a nice feature in the RMLMapper to let the user pass a XML file name as a variable? I see the YARRRML supports external variable already, but it does not work for source file name unfortunately.
RMLMapper-java supports multiple mapping files/strings as its CLI, which it concatenates. Another option could be to keep the source description out of the mapping file, and add that triple when invoking the CLI, something like
RMLMapper-java supports multiple mapping files/strings as its CLI, which it concatenates. Another option could be to keep the source description out of the mapping file, and add that triple when invoking the CLI, something like
It would be better to make the logical source in your original mapping file the named node http://mapping.ex.com/myLogicalSource instead of a blank node. Otherwise there's no way the engine can link the two mapping files together. See below.
Activity
[-]One mapping file for multiple files[/-][+]One mapping file for multiple input source files[/+]DylanVanAssche commentedon May 11, 2022
Hi @tjroamer !
RML mapping rules are RDF so you can edit the RDF edit programmatically as well.
If you read the RDF with RDF libraries such as RDFLib in Python, RDF/JS in Node, etc. you can programmatically generate RML mapping rules and pass them to the RMLMapper.
If you have any questions, feel free to reach out!
tjroamer commentedon May 11, 2022
Thanks for your quick reply! Yes, the way you suggested would work as well. For my use case, it would mean that I need to generate a lot of temp RML files that contain just different XML file names.
Wouldn't it be a nice feature in the RMLMapper to let the user pass a XML file name as a variable? I see the YARRRML supports external variable already, but it does not work for source file name unfortunately.
bjdmeest commentedon May 11, 2022
RMLMapper-java supports multiple mapping files/strings as its CLI, which it concatenates. Another option could be to keep the source description out of the mapping file, and add that triple when invoking the CLI, something like
tjroamer commentedon May 11, 2022
@bjdmeest that's really cool! This is what I needed. Many thanks for your help!
uxapj commentedon Nov 24, 2023
I have tried this at length and I constantly get:
Exception in thread "main" java.lang.Error: The Logical Source does not have a source.
Of course I do not use http://mapping.ex.com/myLogicalSource as my RML looks as such:
@Prefix : http://example.org/rules/ .
@Prefix rml: http://semweb.mmlab.be/ns/rml# .
@Prefix rr: http://www.w3.org/ns/r2rml# .
:TriplesMap a rr:TriplesMap;
rml:logicalSource [
rml:referenceFormulation ql:JSONPath;
rml:iterator "$"
].
But no matter what I do this does not seem to work, are you sure this is still supported?
bjdmeest commentedon Nov 24, 2023
It would be better to make the logical source in your original mapping file the named node
http://mapping.ex.com/myLogicalSourceinstead of a blank node. Otherwise there's no way the engine can link the two mapping files together. See below.uxapj commentedon Nov 27, 2023
Ah you are so right, thank you so much for your help! Now this works as expected!!