...
Below is a sample YAML namespace configuration file, custom_namespaces.yml. The example contains a single custom namespace for the sake of clarity; you may list as many as you like.
Code Block |
---|
awesome: http://example.com/awesome/ |
Fedora can activate the file by using the -Dfcrepo.namespace.registry
system parameter, either on the command line or by adding it to the list of other params that provide paths to other configuration files:
Code Block |
---|
mvn jetty:run -Dfcrepo.namespace.registry=/my/fedora/path/custom_namespaces.yml |
Once Fedora is running, checking the available namespaces should return the list of custom namespaces and not the system generated namespaces:
NB: the custom file will override all default namespace prefixes. In other words, the custom file becomes the definitive registry. Any namespaces that are not prefixed will be returned as full URIs in the response. Notice the "awesome" prefix definition at the bottom of the list.
Code Block |
---|
premis: http: |
Code Block |
curl -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/ # Status 200 # @prefix premis: <http://www.loc.gov/premis/rdf/v1#> . # @prefix v1# test: <infoinfo:fedora/test/> . # @prefix memento: <httphttp://mementoweb.org/ns#> . # @prefix ns# rdfs: <httphttp://www.w3.org/2000/01/rdf-schema#> . # @prefix schema# webac: <httphttp://fedora.info/definitions/v4/webac#> . # @prefix webac# acl: <httphttp://www.w3.org/ns/auth/acl#> . # @prefix acl# vcard: <httphttp://www.w3.org/2006/vcard/ns#> . # @prefix ns# xsi: <httphttp://www.w3.org/2001/XMLSchema-instance> . # @prefix awesome: <http://example.com/awesome/> . # @prefix instance xmlns: <httphttp://www.w3.org/2000/xmlns/> . # @prefix rdf: <httphttp://www.w3.org/1999/02/22-rdf-syntax-ns#> . # @prefix ns# fedora: <httphttp://fedora.info/definitions/v4/repository#> . # @prefix repository# xml: <httphttp://www.w3.org/XML/1998/namespace> . # @prefix namespace ebucore: <httphttp://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> . # @prefix ebucore# ldp: <httphttp://www.w3.org/ns/ldp#> . # @prefix ldp# dcterms: <httphttp://purl.org/dc/terms/> . # @prefix iana: <httphttp://www.iana.org/assignments/relation/> . # @prefix xs: <httphttp://www.w3.org/2001/XMLSchema> . # @prefix XMLSchema fedoraconfig: <httphttp://fedora.info/definitions/v4/config#> . # @prefix config# foaf: <httphttp://xmlns.com/foaf/0.1/> . # @prefix dc: <httphttp://purl.org/dc/elements/1.1/> . ... |
...
awesome: http://example.com/awesome/ |
Fedora can activate the file by using the -Dfcrepo.namespace.registry
system parameter, either on the command line or by adding it to the list of other params that provide paths to other configuration files:
Code Block |
---|
mvn jetty:run -Dfcrepo.namespace.registry=/my/fedora/path/custom_namespaces.yml |
...
In order to demonstrate how this feature works, try starting Fedora without defining a custom namespace registry:
Code Block |
---|
mvn jetty:run |
Once Fedora is running, run the following curl command
Code Block |
---|
curl -i -u fedoraAdmin:fedoraAdmin -X PUT |
Code Block |
curl -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/ # Status 200 # @prefix premistest -H "Content-Type: text/turtle" --data " @prefix awesome: <http://wwwexample.loc.govcom/premisawesome/rdf/v1#>> . # @prefix test: <info:fedora/test/> . # @prefix memento: <http://mementoweb.org/ns#> . # @prefix rdfs<> justokay:test \"blah\"." |
When you retrieve this resource,
Code Block |
---|
curl -i -u fedoraAdmin:fedoraAdmin -X http://localhost:8080/rest/test |
notice the new predicate is expressed as the full URI.
Code Block | ||
---|---|---|
| ||
@prefix rdf: <http://www.w3.org/20001999/0102/22-rdf-syntax-schema#>ns#> . # @prefix webacfedora: <http://fedora.info/definitions/v4/webac#>repository#> . # @prefix aclldp: <http://www.w3.org/ns/auth/acl#> . # @prefix vcard:ldp#> . <http://localhost:8080/rest/test> ... <http://wwwexample.w3.orgcom/awesome/test> "blah" ; ... |
Also notice there are built in prefixes for common namespaces. Now restart Fedora with the custom namespaces yml enabled:
Code Block |
---|
mvn jetty:run -Dfcrepo.namespace.registry=/my/fedora/path/custom_namespaces.yml |
Retrieve the item and see how your custom namespace prefix is being used.
Code Block |
---|
curl -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/test @prefix awesome2006/vcard/ns#> . # @prefix xsi: <http://www.w3.org/2001/XMLSchema-instance> . # @prefix xmlns: <http://wwwexample.w3.orgcom/2000awesome/xmlns/> . # @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . # @prefix fedora: <http://fedora.info/definitions/v4/repository#> . # @prefix xmlldp: <http://www.w3.org/XMLns/1998/namespace>ldp#> . # @prefix ebucore: <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> . # @prefix ldp: <http://www.w3.org/ns/ldp#> . # @prefix dcterms: <http://purl.org/dc/terms/> . # @prefix iana <http://localhost:8080/rest/test> ... awesome:test "blah" ; ... |
Suppose, you later decide that the "awesome" namespace was mislabelled. Instead you really wanted the namespace to be "justokay". Edit the file /my/fedora/path/custom_namespaces.yml to change "awesome" to "justokay", save the file and wait a few seconds, then check the namespace output again:
Code Block |
---|
curl -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/test @prefix justokay: <http://wwwexample.iana.org/assignments/relationcom/awesome/> . # @prefix xsrdf: <http://www.w3.org/2001/XMLSchema>1999/02/22-rdf-syntax-ns#> . # @prefix fedoraconfigfedora: <http://fedora.info/definitions/v4/config#>repository#> . # @prefix foafldp: <http://xmlnswww.w3.comorg/foaf/0.1/>ns/ldp#> . # @prefix dc: <http://purl.org/dc/elements/1.1/> .localhost:8080/rest/test> ... justokay:test "blah" ; ... |