zazuko / xrm

A friendly language for mappings to RDF
MIT License
1 stars 0 forks source link

Template re-use, templates as top-level elements #2

Closed mchlrch closed 4 years ago

mchlrch commented 5 years ago

Avoid duplication of IRI templates when multiple mappings involve the same resource.

~~Modify the grammar to allow LinkedResourceTerm for subjectIriMapping as well. Current grammar: subjectIriMapping=TemplateValuedTerm This also needs a validation rule to detect circular dependencies between mappings~~

Introduce templates as top-level elements that can be referenced from within mappings for re-use. Using inline templates is still possible, pulling-out templates for re-use is optional.

Example for template definition and re-use:

output rml

template airportIri "http://airport.example.com/{0}"

map AirportMapping from airport {
    subject template airportIri with id;

    properties
        wgs84_pos:lat from latitude;
        wgs84_pos:long from longitude;
}

map AirportOwnership from airportowners {
    subject template airportIri with id;

    properties
        ex:owner from ownership;
}

map AirlineAtAirport from airlineairport {
    subject template "http://airline.example.com/{0}" with id;

    properties
        ex:airportServed template airportIri with airportId;
}

This obsoletes the LinkedResourceTerm, that can be removed from the grammar.

nnamtug commented 4 years ago

There is no validation for the template value - is this feature or bug? One could think about validating for URL (EDIT: ah, here it is #57 ). And now when reusing the template, maybe one would like to validate the number of parameters.

mchlrch commented 4 years ago

Tested and works well. Proposals only include templates from the same file, which makes sense. Scoping is not narrowed, so it is possible (if needed) to also reference templates declared in other files.