zazuko / xrm

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

support carml extensions #15

Closed mchlrch closed 4 years ago

mchlrch commented 5 years ago

carml has some useful proprietary features that we would like to expose in the DSL:

Additionally to the existing standard RML output, this adds another RML output flavor.

mchlrch commented 5 years ago

OUTDATED I think this could be implemented by decorating the source-type (extension carml) and referenceables (multiReference).

DSL:

source-types {
    xml referenceFormulation "ql:XPath" extension carml;
}

logical-source mySource {
    type xml
    source "stream-A"
    referenceables {
        Id "@Id"
        SynonymDefinitions multiReference "tokenize(Sprachzonen/Sprachzone[attribute::Sprache='DE']/Synonym[attribute::Nr='1']/Definition[./Typ='ab']/Text, '\s*;\s*')" 
    }
}

RML output :

rml:source [
    a carml:Stream ;
    carml:streamName "stream-A" ;
]
...
rr:predicateObjectMap [
    rr:predicate schema:alternateName;
    rr:objectMap [
      carml:multiReference "tokenize(Sprachzonen/Sprachzone[attribute::Sprache='DE']/Synonym[attribute::Nr='1']/Definition[./Typ='ab']/Text, '\s*;\s*')";
      rr:language "de" ;
    ]
 ] ;

Covering the input stream extension as well as the MultiTermMap extensions.

mchlrch commented 4 years ago

For using carml:Stream, the RML output becomes:

<#EmployeeMapping>
    rml:logicalSource [
        rml:source [
            a carml:Stream ;
            carml:streamName "stream-A" ;
        ]
        ...

The switch for this could be declaringoutput carml, after implementing #48

mchlrch commented 4 years ago

For using carml:multiReference, the RML has to be for example:

<#EmployeeMapping>
    ... 
    rr:predicateObjectMap [
        rr:predicate employee:team ;
        rr:objectMap [
            carml:multiReference "teams" ;
        ];
    ]
.

The switch for this could be either a flag on the Referenceable or on the ReferenceValuedTerm.

I thought initially about flaging the Referenceable (see older comment above), but now I think that having this on the ReferenceValuedTerm is A) more descriptive because visible in the mapping and B) easier to implement because availability/validity is dependent on choosing output carml #48.

map EmployeeMapping from EMPLOYEE {
    subject template "http://airport.example.com/{0}" with id;

    properties
        employee:team multi-reference from teams;       
}
mchlrch commented 4 years ago

Support for carml:Stream and carml:multiReference LGTM

Sample DSL:

output carml

map EmployeeMapping from EMPLOYEE {
    subject template "http://foo.example.com/{0}" with id;

    types
        employee:Employee

    properties
        employee:team multi-reference from teams; 
}

results in generated CARML flavored RML:

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 carml: <http://carml.taxonic.com/carml/>
PREFIX employee: <http://example.com/employee>

<#EmployeeMapping>
    rml:logicalSource [
        rml:source [
            a carml:Stream ;
            carml:streamName "employee-stream" ;
        ] ;
        rml:referenceFormulation ql:XPath
    ];

    rr:subjectMap [
        rr:template "http://foo.example.com/{id}" ;
        rr:class employee:Employee ;
    ];

    rr:predicateObjectMap [
        rr:predicate employee:team ;
        rr:objectMap [
            carml:multiReference "teams" ;
        ];
    ]
.
mchlrch commented 3 years ago

105