On this page:
nsname
make-nsname
nsname->url
nsname->string
nsname-make-nsname
url->namespace+  name
url->nsname

3.2 Namespaced Names🔗ℹ

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

struct

(struct nsname (namespace name))

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

Examples:
> (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?)
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 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?
Returns a new URI concatenating the name’s namespace IRI and local name values.

Example:
> (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?
Returns a new string concatenating the name’s namespace IRI and local name values.

Example:
> (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?)
Returns a new nsname? concatenating the namespace IRI from from and name.

Examples:
> (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?
If the value of url has a fragment part, return url minus the fragment as the namespace and the fragment value as the name. If the value of url has a path with a final segment, return url minus the final path segment as the namespace and the path’s final segment value as the name. If neither of these conditions are met the URI is not a valid namespaced-name and the value #f is returned.

Examples:
> (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?
Returns a new nsname from the components returned by calling url->namespace+name with the value url.

Examples:
> (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