Skip to content
Josef Hardi edited this page Jan 17, 2018 · 3 revisions

RML or RDF Mapping language is a generic mapping language defined to express rules that map data in heterogeneous structures to the RDF data model. Please refer to RML.io for detailed information about the language specification.

To be used in schemaorg-pipeline, however, we need to apply two syntax rules:

  1. Set the rml:source to be always empty
  2. There can only be ONE root object and named it as <#Root>

The association between the data map and the source file is done by the pipeline framework, thus it is not required to specify the source location in the rml:source element. The named object <#Root> is just a shortcut to immediately read the parent object node before reading the children nodes in the data map.

Data Map Example

The example below shows an example of a data map using the RML notation used to generate schema.org markup data from XML documents in ClinicalTrials.gov website. See the comparison when using CAML.

@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix schema: <http://schema.org/>.
<#Root>
   rml:logicalSource [
      rml:source "";
      rml:iterator "/clinical_study"
   ];
   rr:subjectMap [
      rr:template "";
      rr:class schema:MedicalTrial
   ];
   rr:predicateObjectMap [
      rr:predicate schema:name;
      rr:objectMap [ rml:reference "/official_title" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:alternateName;
      rr:objectMap [ rml:reference "/brief_title" ];
      rr:objectMap [ rml:reference "/acronym" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:identifier;
      rr:objectMap [ rml:reference "/id_info/org_study_id" ];
      rr:objectMap [ rml:reference "/id_info/nct_id" ];
      rr:objectMap [ rml:reference "/id_info/secondary_id" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:status;
      rr:objectMap [ rml:reference "/overall_status" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:description;
      rr:objectMap [ rml:reference "/detailed_description/textblock" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:disambiguatingDescription;
      rr:objectMap [ rml:reference "/brief_summary/textblock" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:studySubject;
      rr:objectMap [ rml:reference "/condition" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:phase;
      rr:objectMap [ rml:reference "/phase" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:code;
      rr:objectMap [ rr:parentTriplesMap <#Code> ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:sponsor;
      rr:objectMap [ rr:parentTriplesMap <#LeadSponsor> ];
      rr:objectMap [ rr:parentTriplesMap <#Collaborator> ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:studyLocation;
      rr:objectMap [ rr:parentTriplesMap <#Facility> ];
   ].
<#Code>
   rml:logicalSource [
      rml:source "";
      rml:iterator "/clinical_study/condition_browse"
   ];
   rr:subjectMap [
      rr:template "";
      rr:class schema:MedicalCode
   ];
   rr:predicateObjectMap [
      rr:predicate schema:codeValue;
      rr:objectMap [ rml:reference "/mesh_term" ];
   ];
   rr:predicateObjectMap [
     rr:predicate schema:codingSystem;
     rr:objectMap [ rr:constant "MeSH" ]
   ].
<#LeadSponsor>
   rml:logicalSource [
      rml:source "";
      rml:iterator "/clinical_study/sponsors/lead_sponsor"
   ];
   rr:subjectMap [
      rr:template "";
      rr:class schema:Organization
   ];
   rr:predicateObjectMap [
      rr:predicate schema:name;
      rr:objectMap [ rml:reference "/agency" ];
   ];
   rr:predicateObjectMap [
      rr:predicate schema:additionalType;
      rr:objectMap [ rr:constant "Lead Sponsor" ];
   ].
<#Collaborator>
   rml:logicalSource [
      rml:source "";
      rml:iterator "/clinical_study/sponsors/collaborator"
   ];
   rr:subjectMap [
      rr:template "";
      rr:class schema:Organization
   ];
   rr:predicateObjectMap [
      rr:predicate schema:name;
      rr:objectMap [ rml:reference "/agency" ];
   ];
   rr:predicateObjectMap [
      rr:predicate schema:additionalType;
      rr:objectMap [ rr:constant "Collaborator" ];
   ].
<#Facility>
   rml:logicalSource [
      rml:source "";
      rml:iterator "/clinical_study/location/facility"
   ];
   rr:subjectMap [
      rr:template "";
      rr:class schema:AdministrativeArea
   ];
   rr:predicateObjectMap [
      rr:predicate schema:name;
      rr:objectMap [ rml:reference "/name" ];
   ];
   rr:predicateObjectMap [
      rr:predicate schema:additionalType;
      rr:objectMap [ rr:constant "Facility" ];
   ];
   rr:predicateObjectMap [
      rr:predicate schema:address;
      rr:objectMap [ rr:parentTriplesMap <#Address> ]
   ].
<#Address>
   rml:logicalSource [
      rml:source "";
      rml:iterator "/clinical_study/location/facility/address"
   ];
   rr:subjectMap [
      rr:template "";
      rr:class schema:PostalAddress
   ];
   rr:predicateObjectMap [
      rr:predicate schema:addressLocality;
      rr:objectMap [ rml:reference "/city" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:addressRegion;
      rr:objectMap [ rml:reference "/state" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:postalCode;
      rr:objectMap [ rml:reference "/zip" ]
   ];
   rr:predicateObjectMap [
      rr:predicate schema:addressCountry;
      rr:objectMap [ rml:reference "/country" ]
   ].

Please visit the playground (Try Example > Example RML: Annotate ClinicalTrials.gov XML document) to see the full-length map and a live demo of evaluating this mapping.

Clone this wiki locally