Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleRecommended Usage
linenumberstrue
PREFIX esc: <http://myurl.org/>
. . .

"Initializing" a Repository with Additional Bindings

The inadvertent binding of namespaces to system-generated prefixes can be prevented by preemptively binding the namespaces that are likely to be used to standard prefixes.  This can be accomplished by creating a dummy node in the repository, adding desired namepace prefixes and RDF triples via a SPARQL update query, and then deleting the dummy node and the resulting tombstone to remove traces of this operation from the repository.  Even after all traces of the initialization node have been removed, the namespace bindings will persist in the repository and be available as RDF triples are added in the future.

...

Code Block
languagebash
titleSample Namespace Initialization Script
linenumberstrue
#!/bin/bash
 
REST="http://localhost:8080/fcrepo/rest"
USER="fedoraAdmin"
PASSWORD="secret3"
 
QUERY="
    PREFIX pcdm: <http://pcdm.org/models#> 
    PREFIX bibo: <http://purl.org/ontology/bibo/>
    INSERT DATA { 
        <> a pcdm:Object ;
            bibo:shortTitle 'Fedora4 Site Initialization Page' .
        }"
 
curl -u $USER:$PASSWORD -X PUT "$REST/initialize/"
curl -u $USER:$PASSWORD -X PATCH -H "Content-Type: application/sparql-update" \
    --data "$QUERY" "$REST/initialize"
curl -u $USER:$PASSWORD -X DELETE "$REST/initialize"
curl -u $USER:$PASSWORD -X DELETE "$REST/initialize/fcr:tombstone"