Versions Compared

Key

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

Namespaces

A Fedora repository includes a number of pre-defined namespace bindings (essentially, a mapping that connects a particular prefix to a URI, allowing for a more convenient and human-readable rendering of RDF).  Predefined namespaces include DC, FOAF, Fedora, and LDP, among others.  As additional namespaces are used in the course of depositing materials into the repository, each new namespace will automatically be bound to its own prefix the first time it is used.  Once a URI is bound to a particular namespace prefix, it cannot be changed, except in certain cases through the use of a special tool for this purpose. A full list of the bound namespaces for a given Fedora repository at any given moment can be seen in the HTTP REST interface, as a list of pre-populated "PREFIX ..." bindings in the SPARQL update query text-box.

System-Generated Prefixes

As noted above, as new namespaces are used for the first time, those namespaces will be bound permanently to particular prefixes.  Currently, if the first use of a particular namespace should occur in RDF that is POSTed or PUT to the repository, regardless of any specific prefix binding supplied in the submitted graph, Fedora will instead bind the new namespace to a system-generated namespace in the form "ns00x".  While this behavior is not incorrect, it is inconvenient, and not necessarily user friendly for human interaction with the repository.  In order to avoid this behavior, the following best practices are recommended: (1) define a custom CND file which defines namespace prefixes; (2) use SPARQL update as the initial method of submitting a new namespace binding to the repository; and (23) "initializing" the repository with namespace bindings for the namespaces that are likely to be used, to prevent inadvertent POSTing or PUTting of new namespaces and the consequent exposure of opaque system-generated prefixes.

Defining a custom CND file

In order to define a custom CND file, you must first customize the repository.json file. This is the configuration that is used with the -Dfcrepo.modeshape.configuration setting. In that file, the "node-types" block should be defined as: "node-types" : ["fedora-node-types.cnd", "file:/etc/fcrepo/namespaces.cnd"].

Code Block
languagejs
titlerepository.json
{
    "name" : "fedora",
    "jndiName" : "",
    "workspaces" : { ... },
    "storage" : {
        "persistence": { ... },
        "binaryStorage" : { ... }
    },
    "security" : {
        "anonymous" : { ... },
        "providers" : [ ... ]
    },
    "node-types" : ["fedora-node-types.cnd", "file:/etc/fcrepo/namespaces.cnd"]
}

 

The namespaces.cnd file can be used to register namespaces like so:

Code Block
titleCND File
<acl = 'http://www.w3.org/ns/auth/acl#'>
<cc = 'http://creativecommons.org/ns#'>
<dcterms = 'http://purl.org/dc/terms/'>
<exif = 'http://www.w3.org/2003/12/exif/ns#'>
<geo = 'http://www.w3.org/2003/01/geo/wgs84_pos#'>
<gn = 'http://www.geonames.org/ontology#'>
<iana = 'http://www.iana.org/assignments/relation/'>
<ore = 'http://www.openarchives.org/ore/terms/'>
<owl = 'http://www.w3.org/2002/07/owl#'>
<prov = 'http://www.w3.org/ns/prov#'>
<rel = 'http://id.loc.gov/vocabulary/relators/'>
<schema = 'http://schema.org/'>
<skos = 'http://www.w3.org/2004/02/skos/core#'>

It is important to note that this should be done when the repository is first set up, before any content has been added.

Using SPARQL-Update to Bind Prefixes

To ensure that specific namespaces are used (i.e., treated as sacred) by Fedora 4 when doing a SPARQL update, ensure that the namespace prefix URI includes a terminating character. Otherwise system-generated JCR namespaces (e.g., ns001, ns002), and not the user-supplied namespaces, will get registered. Therefore, the following statement could lead to unexpected namespaces. F4 will register a system-generated namespace and you would not find "http://myurl.org" namespace in the system.

...