zazuko / xrm

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

Use Prefixes in IRI Templates #141

Open BenjaminHofstetter opened 2 years ago

BenjaminHofstetter commented 2 years ago

It would be useful if we can use prefixes in IRI templates.

At the moment i do it like this.

subject template "https://data.mobi.ch/par/partner/{0}" with PARTNERNUMMER;

i can imagine something like this ... .. or something better

vocabulary pardata {
    prefix "pardata" "https://data.mobi.ch/par/"
}

map Partner from MobiDBSource {
   subject template "{0}{1}" with pardata PARTNERNUMMER;
  // or 
   subject template "{prefix}{1}" prefix pardata with PARTNERNUMMER;

Problem: The IRI templates have a 'hard coded' prefix and i have to take care of it every time i uses it. If i can use the prefix defined in vocabulary it's 'centralised', had IDE completion support and it can support refactoring.

mchlrch commented 2 years ago

Thank you for your feature request.

IRI templates can also be declared on the top-level, outside of a map. Doing so eliminates some (but not all) of the duplication and facilitates IRI template refactorings.

Here's an example:

template airportIri "http://airport.example.com/{0}"
template airlineIri "http://airline.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 airlineIri with id;

    properties
        ex.airportServed template airportIri with airportId;
}

One can also consider using relative IRIs in the mapping and leaving resolution against a base IRI to the mapping processor (e.g. R2RML processor )

ktk commented 2 years ago

I use that a lot, in the previous release XRM did not autocomplete to those, I think you did explain me once why but I can't remember. What is the reason that autocomplete is not working on templates?

mchlrch commented 2 years ago

I use that a lot, in the previous release XRM did not autocomplete to those, I think you did explain me once why but I can't remember. What is the reason that autocomplete is not working on templates?

Yes that's correct. Up to now proposals for templates in code assist only included templates that were declared in the same file.

This changes with XRM version 1.2.0. Now all the templates from all files in the project are included in code assist proposals.