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
namespace : resource? name : local-name?
> (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?)
> (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?
> (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?)
> (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?
> (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?
> (nsname->string (resource->nsname (string->resource "http://example.org/schema/nspace#name"))) "http://example.org/schema/nspace#name"