3.2 Namespaced Names
A namespaced-name comprises a name and corresponding namespace, commonly noted as a tuple (namespace, local-name).
struct
namespace : namespace? name : local-name?
> (require net/url-string)
> (let ((ex-name (nsname (string->namespace "http://example.org/schema/nspace/") (string->local-name "Name")))) (displayln (nsname-namespace ex-name)) (displayln (nsname-name ex-name)))
#(struct:namespace #(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) → name?
namespace : (or/c string? namespace-url? namespace?) name : (or/c local-name-string? local-name?)
> (require net/url-string)
> (let ((ex-name (make-nsname "http://example.org/schema/nspace/" "Name"))) (displayln (nsname-namespace ex-name)) (displayln (nsname-name ex-name)))
#(struct:namespace #(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
(nsname->url nsname) → url-absolute?
nsname : nsname?
> (nsname->url (url->nsname (string->url "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 (url->nsname (string->url "http://example.org/schema/nspace#name"))) "http://example.org/schema/nspace#name"
procedure
(nsname-make-nsname from name) → nsname?
from : nsname? name : (or/c local-name-string? local-name?)
> (require net/url-string)
> (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
(url->namespace+name url)
→ (or/c (cons/c url-absolute? string?) #f) url : url-absolute?
> (url->namespace+name (string->url "http://example.org/schema/nspace#name"))
(cons
(url
"http"
#f
"example.org"
#f
#t
(list (path/param "schema" '()) (path/param "nspace" '()))
'()
"")
"name")
> (url->namespace+name (string->url "http://example.org/schema/nspace#")) #f
> (url->namespace+name (string->url "http://example.org/schema/nspace/name"))
(cons
(url
"http"
#f
"example.org"
#f
#t
(list
(path/param "schema" '())
(path/param "nspace" '())
(path/param "" '()))
'()
#f)
"name")
> (url->namespace+name (string->url "http://example.org/schema/nspace/name/")) #f
> (url->namespace+name (string->url "http://example.org/")) #f
> (url->namespace+name (string->url "http://example.org")) #f
procedure
(url->nsname url) → nsname?
url : url-absolute?
> (url->nsname (string->url "http://example.org/schema/nspace#name"))
(nsname
(namespace
(url
"http"
#f
"example.org"
#f
#t
(list (path/param "schema" '()) (path/param "nspace" '()))
'()
""))
(local-name "name"))
> (url->nsname (string->url "http://example.org/schema/nspace/name"))
(nsname
(namespace
(url
"http"
#f
"example.org"
#f
#t
(list
(path/param "schema" '())
(path/param "nspace" '())
(path/param "" '()))
'()
#f))
(local-name "name"))
> (url->namespace+name (string->url "http://example.org/schema/nspace#")) #f
> (url->namespace+name (string->url "http://example.org/schema/nspace/name/")) #f
> (url->namespace+name (string->url "http://example.org/")) #f
> (url->namespace+name (string->url "http://example.org")) #f