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 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 textboxtext-box.

...

System-

...

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.

Code Block
titleProblematic Usage
linenumberstrue
PREFIX esc: <http://myurl.org>
INSERT {
<>
esc:package "ppp";
}
WHERE { }

 

Therefore, the URI prefix in line 1 should have a terminating character, e.g., a slash or a hash. 

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

 

 

 

 

 

 

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, you can define a custom CND file which defines namespace prefixes.  Previously, it was possible to control the prefixes used by using SPARQL update or RDF with namespace prefixes, but this functionality does not currently work (see

Jira
serverDuraSpace JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverIdc815ca92-fd23-34c2-8fe3-956808caf8c5
keyFCREPO-2376
).

Defining a custom CND file

Warning

The following steps should only be done when the repository is first set up, before any content has been added.

Namespace registry corruption can occur if new namespaces are defined in the CND for a repository that already has content that uses those namespaces with different associated prefixes.

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#'>

...