zazuko / xrm

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

Subject id from reference (rr:subjectMap/rml:reference) #153

Closed mchlrch closed 2 months ago

mchlrch commented 2 months ago

Current version (1.5.0) only supports creating the subject id based on a template.

Because processors always perform percent-encoding when IRIs are generated from string templates, this becomes cumbersome in cases where the subject id already exists pre-fabricated in the source.

Quoting from the spec https://www.w3.org/TR/r2rml/#from-template :

Note: R2RML always performs percent-encoding when IRIs are generated from string templates.
If IRIs need to be generated without percent-encoding, then rr:column should be used instead of rr:template,
with an [R2RML view](https://www.w3.org/TR/r2rml/#dfn-r2rml-view) that performs the string concatenation.

... the equivalent to R2RML views in RML are path-expressions (eg. XPath or JSONPath).

Sample XML input:

<?xml version="1.0" encoding="utf-8"?>
<akomaNtoso xmlns="http://docs.oasis-open.org/legaldocml/ns/akn/3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://docs.oasis-open.org/legaldocml/ns/akn/3.0 https://docs.oasis-open.org/legaldocml/akn-core/v1.0/os/part2-specs/schemas/akomantoso30.xsd">
  <act name="Grunderlass" contains="originalVersion"> 
    <meta>
      <identification source="#source">
        <FRBRWork>
          <FRBRthis value="/akn/CH-ZH/act/2024-02-29/2024-17/main"/> 
          <FRBRuri value="/akn/CH-ZH/act/2024-02-29/2024-17"/>
          <FRBRdate date="2024-02-29" name="Beschlussdatum"/> 
          <FRBRauthor href="#Kantonsrat" as="#author"/> 
          <FRBRcountry value="#CH-ZH" showAs="CH-ZH"/>
          <FRBRsubtype value="#Gesetz" showAs="Gesetz"/> 
          <FRBRnumber value="2024-17"/> 
        </FRBRWork>
      </identification>
    </meta>     
  </act>    
</akomaNtoso>

Feature request:

# sources.xrm
logical-source Example3Xml {
    type xml
    source "stdin"
    xml-namespace-extension akomaNtoso
    iterator "/akn:akomaNtoso/akn:act/akn:meta/akn:identification/akn:FRBRWork"

    referenceables
        legalResourceIri "concat('http://zrh.ch', akn:FRBRuri/@value)"
-       jurisdiction "tokenize(akn:FRBRuri/@value, '/')[3]"
-       doctype "tokenize(akn:FRBRuri/@value, '/')[4]"
-       docdate "tokenize(akn:FRBRuri/@value, '/')[5]"
-       docnumber "tokenize(akn:FRBRuri/@value, '/')[6]"
}

xml-namespace-extension akomaNtoso {
    prefix "akn" "http://docs.oasis-open.org/legaldocml/ns/akn/3.0"
}

# mapping3.xrm
 output carml

- template workIri "http://zrh.ch/akn/{0}/{1}/{2}/{3}"

 map example3 from Example3Xml {
-       subject template workIri with jurisdiction doctype docdate docnumber;
+       subject from legalResourceIri as IRI;

        types
                eli.LegalResource

# src-gen/mapping3.carml.ttl        
        rr:subjectMap [
-               rr:template "http://zrh.ch/akn/{tokenize(akn:FRBRuri/@value, '/')[3]}/{tokenize(akn:FRBRuri/@value, '/')[4]}/{tokenize(akn:FRBRuri/@value, '/')[5]}/{tokenize(akn:FRBRuri/@value, '/')[6]}";
+               rml:reference "concat('http://zrh.ch', akn:FRBRuri/@value)";
                rr:class eli:LegalResource
        ];
mchlrch commented 2 months ago

Resolved in xrm version 1.6.0

 subject from legalResourceIri;
 subject from legalResourceIri as IRI;

Both of the above are fine. Explicitly stating the TermType IRI is possible but not necessary.