5.1 Prefixes
A prefix is the string mapped to a namespace in a namespace map. This prefix can be used in place of the complete namespace URI.
Namespace Module – Prefixes
predicate
(prefix-string? v) → boolean?
v : any/c
Returns #t if v is a string and the string conforms to the SPARQL production PNAME_NS.
predicate
(prefix-name-string? v) → boolean?
v : any/c
Returns #t if v is a string and the string conforms to the SPARQL production PN_PREFIX.
struct
(struct prefix ())
This structure provides a safe and efficient way to wrap either a string that conforms to the predicate
prefix-string? or the empty value. This ensures that the name cannot be mutated, and the predicate
prefix-name? is more efficient than parsing the string.
constructor
(string->prefix str) → prefix?
str : (or/c prefix-string? prefix-name-string?)
constructor
(empty-prefix) → prefix?
Returns an empty prefix name.
predicate
(prefix-empty? v) → boolean?
v : any/c
Examples:
> (require rdf/core/nsmap) > (prefix-empty? (string->prefix "rdf:")) #f
> (prefix-empty? (string->prefix ":")) #t
> (prefix-empty? (empty-prefix)) #t
procedure
(prefix->string nsprefix) → string?
nsprefix : prefix?
Examples:
> (require rdf/core/nsmap) > (prefix->string (string->prefix "rdf:")) "rdf:"
> (prefix->string (string->prefix ":")) ":"
> (prefix->string (empty-prefix)) ":"
procedure
(prefix+name->nsname prefix name map) → nsname?
prefix : namespace-prefix? name : local-name-string? map : nsmap?
Examples:
> (require rdf/core/nsmap)
> (let ((namespace-map (make-common-nsmap))) (resource->string (nsname->resource (prefix+name->nsname (string->prefix "dcterms:") (string->local-name "description") namespace-map)))) "http://purl.org/dc/terms/description"
procedure
(prefix+name->resource prefix name map) → url-absolute?
prefix : namespace-prefix? name : local-name-string? map : nsmap?
Examples:
> (require rdf/core/nsmap)
> (let ((namespace-map (make-common-nsmap))) (resource->string (prefix+name->resource (string->prefix "dcterms:") (string->local-name "description") namespace-map))) "http://purl.org/dc/terms/description"