Custom RML Rules

An advantage of building RML mapping rules is that you can add custom RML rules to an existing Processor subclass. For example, you may want to a bf:heldBy predicate to your bf:Item entities that points to your institution's IRI.

Referring back to the State of Colorado Publication's library, we create a new RML predicateObjectMap to the existing BIBFRAME Item tripleMap with the following:

@prefix rml:    <> .
@prefix rr:   <>.
@prefix bf: <> .

bc:MODS2BIBFRAME_Item  rr:predicateObjectMap [
    rr:predicate bf:heldBy ;
    rr:objectMap [
        rr:constant <> ;
] .

Saving this rule in a temporary file, we will create a new XMLProcessor instance with the new RML rule and rerun the MODS-to-BIBFRAME conversion.

>>> mods_processor = processor.XMLProcessor(
        base_url = '',
        namespaces={"mods": "",
                    "xlink": ""})

Checking the resulting turtle serialization of the output RDF graph, we can see that '' subject now has a new triple with the predicate being bf:heldBy and the object being the Colorado State Library Publication IRI.

<> a bf:Item ;
    bf:generationProcess [ a bf:GenerationProcess ;
            bf:generationDate "2017-11-10T14:36:50.510775" ;
            rdf:value "Generated by BIBCAT version 1.18.1 from"^^xsd:string ] ;
    bf:heldBy <> ;
    bf:itemOf <> .


This finishes the introduction to RML mapping with bibcat, now we will look at a second core functionality, that of linking to other sources of Linked Data with our existing BIBFRAME RDF.

Original contented Copyrighted © 2017 by Jeremy Nelson and KnowledgeLinks under Creative Commons License, Source code repository licensed under the Apache 2 and available on Github.