zazuko / xrm

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

Support carml XML namespace extensions #34

Closed ktk closed 4 years ago

ktk commented 4 years ago

That's pretty vital in carml, in my experience one does not get any results without properly adding it to the mapping.

https://github.com/carml/carml#xml-namespace-extension

mchlrch commented 4 years ago

If multiple namespaces have to be registered, then each one requires its own carml:declaresNamespace statement.

@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 ex: <http://www.example.com/> .

<#SubjectMapping> a rr:TriplesMap ;
  rml:logicalSource [
    rml:source [
      a carml:Stream ;
      carml:declaresNamespace [
        carml:namespacePrefix "exa" ;
        carml:namespaceName "http://www.example.com/audios/1.0/" ;
      ] ;
      carml:declaresNamespace [
        carml:namespacePrefix "exb" ;
        carml:namespaceName "http://www.example.com/books/1.0/" ;
      ] ;

    ] ;
    rml:referenceFormulation ql:XPath ;
    rml:iterator "/ex:bookstore/*" ;
  ]
.
mchlrch commented 4 years ago

Those XML namespaces belong to the source side of things. I suggest we implement this in the grammar similar to how the CSVW dialect is implemented.

source-group SomeSourceGroup {
    xml-namespace-extension SomeXmlNsExtension

    logical-source foo {
        type xml

        ...
    }

}

xml-namespace-extension SomeXmlNsExtension {
    prefix "exa" "http://www.example.com/audios/1.0/"
    prefix "exb" "http://www.example.com/books/1.0/"
}

xml-namespace-extension can be declared on the LogicalSource or on the SourceGroup

nnamtug commented 4 years ago

Assumption: only generate 'carml:declaresNamespace' for prefixes used in the current mapping

If this is not the case, revert commit https://github.com/zazuko/rdf-mapping-dsl/commit/53f8796fa4bc71bc6482c38e201bd3e2ee4555f5

nnamtug commented 4 years ago

also tweaked code-completion and validation for LogicalSource and SourceGroup

Not adding all possible examples for this validation into editor-test due to excessive testing in ValidationRuleTest.xtend.

Project editor-test now has examples for code completion.

mchlrch commented 4 years ago

Assumption: only generate 'carml:declaresNamespace' for prefixes used in the current mapping

If this is not the case, revert commit 53f8796

This is not the case. All prefixes contained in the xml-namespace-extension of the source need to be added with a carml:declaresNamespace. These are namespaces used in the XML document that gets transformed, which are independent of the vocabulary namespaces of the target RDF data.

mchlrch commented 4 years ago

Works as expected. Good to merge