List Registered Namespaces

List Registered Namespaces #

Problem #

I do not know which namespaces are registered currently in the database. How can I investigate what are these namespaces that I can/have to use?

Solution #

The following code fragment lists all the namespaces currently registered:

package main

import (
    "fmt"
	"github.com/cayleygraph/quad/voc"

    // Add some predefined vocabularies
	_ "github.com/cayleygraph/quad/voc/schema"
	_ "github.com/cayleygraph/quad/voc/xsd"
	_ "github.com/cayleygraph/quad/voc/rdf"
	_ "github.com/cayleygraph/quad/voc/rdfs"
)

func main() {
    fmt.Println("Registered namespaces:");
    for _, v := range voc.List() {
        fmt.Printf("  %s => %s\n", v.Prefix, v.Full);
    }
}

Run this code on Repl.it

    cd namespaces
    go run list_namespaces.go`

The results:

Registered namespaces:
  schema: => http://schema.org/
  xsd: => http://www.w3.org/2001/XMLSchema#
  rdf: => http://www.w3.org/1999/02/22-rdf-syntax-ns#
  rdfs: => http://www.w3.org/2000/01/rdf-schema#