On this page:
nsname
make-nsname
resource->nsname
nsname-make-nsname
nsname->resource
nsname->string

4 Module nsname🔗ℹ

 (require rdf/core/nsname) package: rdf-core

A namespaced name comprises a name and corresponding namespace, commonly noted as a tuple (namespace, local-name).

NSName Module Overview

struct

(struct nsname (namespace name))

  namespace : resource?
  name : local-name?
The namespace and local-name pair.

Examples:
> (require rdf/core/name
           rdf/core/nsname
           rdf/core/resource)
> (let ((ex-name (nsname (string->resource "http://example.org/schema/nspace/")
                         (string->local-name "Name"))))
    (displayln (nsname-namespace ex-name))
    (displayln (nsname-name ex-name)))

#(struct:url http #f example.org #f #t (#(struct:path/param schema ()) #(struct:path/param nspace ()) #(struct:path/param  ())) () #f)

#(struct:local-name Name)

constructor

(make-nsname namespace name)  nsname?

  namespace : (or/c string? resource?)
  name : (or/c local-name-string? local-name?)
Returns a new nsname from the namespace and the value of name. This is a wrapper around the nsname constructor and takes a relaxed set of types for ease of use.

Examples:
> (require rdf/core/nsname)
> (let ((ex-name (make-nsname "http://example.org/schema/nspace/" "Name")))
    (displayln (nsname-namespace ex-name))
    (displayln (nsname-name ex-name)))

#(struct:url http #f example.org #f #t (#(struct:path/param schema ()) #(struct:path/param nspace ()) #(struct:path/param  ())) () #f)

#(struct:local-name Name)

procedure

(resource->nsname resource)  (or/c nsname? #f)

  resource : resource-absolute?
Returns a new nsname from the components returned by calling resource->namespace+name with the value resource.

Examples:
> (resource->nsname (string->resource "http://example.org/schema/nspace#name"))

(nsname

 (url

  "http"

  #f

  "example.org"

  #f

  #t

  (list (path/param "schema" '()) (path/param "nspace" '()))

  '()

  "")

 (local-name "name"))

> (resource->nsname (string->resource "http://example.org/schema/nspace/name"))

(nsname

 (url

  "http"

  #f

  "example.org"

  #f

  #t

  (list

   (path/param "schema" '())

   (path/param "nspace" '())

   (path/param "" '()))

  '()

  #f)

 (local-name "name"))

> (resource->namespace+name (string->resource "http://example.org/schema/nspace#"))

(url

 "http"

 #f

 "example.org"

 #f

 #t

 (list (path/param "schema" '()) (path/param "nspace" '()))

 '()

 "")

#f

> (resource->namespace+name (string->resource "http://example.org/schema/nspace/name/"))

(url

 "http"

 #f

 "example.org"

 #f

 #t

 (list

  (path/param "schema" '())

  (path/param "nspace" '())

  (path/param "name" '())

  (path/param "" '()))

 '()

 #f)

#f

> (resource->namespace+name (string->resource "http://example.org/"))

(url "http" #f "example.org" #f #t (list (path/param "" '())) '() #f)

#f

> (resource->namespace+name (string->resource "http://example.org"))

(url "http" #f "example.org" #f #t '() '() #f)

#f

procedure

(nsname-make-nsname from name)  nsname?

  from : nsname?
  name : (or/c local-name-string? local-name?)
Returns a new nsname? concatenating the namespace IRI from from and name.

Examples:
> (require rdf/core/nsname)
> (let* ((ex-name (make-nsname "http://example.org/schema/nspace/" "Name"))
         (new-name (nsname-make-nsname ex-name "New")))
    (displayln (format "~a => ~a"
                       (local-name->string (nsname-name ex-name))
                       (local-name->string (nsname-name new-name)))))

Name => New

procedure

(nsname->resource nsname)  resource?

  nsname : nsname?
Returns a new URI concatenating the name’s namespace IRI and local name values.

Example:
> (nsname->resource
   (resource->nsname
    (string->resource "http://example.org/schema/nspace#name")))

(url

 "http"

 #f

 "example.org"

 #f

 #t

 (list (path/param "schema" '()) (path/param "nspace" '()))

 '()

 "name")

procedure

(nsname->string nsname)  string?

  nsname : nsname?
Returns a new string concatenating the name’s namespace IRI and local name values.

Example:
> (nsname->string
   (resource->nsname
    (string->resource "http://example.org/schema/nspace#name")))

"http://example.org/schema/nspace#name"