Defines utilities and a set of namespaces for commonly used linked data constructs, metadata of which specifies RDF namespaces, prefixes and other details.
Defines utilities and a set of namespaces for commonly used linked data constructs, metadata of which specifies RDF namespaces, prefixes and other details.
{alias
ns-name
, ...}
Where
alias
is a symbol
ns-name
is a symbol naming an ns in the current lexical env
NOTE: Informs cljc-ns-aliases in cljs space.
{`alias` `ns-name`, ...} Where `alias` is a symbol `ns-name` is a symbol naming an ns in the current lexical env NOTE: Informs cljc-ns-aliases in cljs space.
A regex matching an IRI string which doesn't match the usual http//-ish scheme, such as urn:
.
A regex matching an IRI string which doesn't match the usual http//-ish scheme, such as `urn:`.
Returns keyword identifier for an instance of Resource.
kwi
.this
is an instance of RESOURCEkwi
conforms to :voc/kwi-specReturns keyword identifier for an instance of Resource. - Signature: [this] -> `kwi`. - Where: - `this` is an instance of RESOURCE - `kwi` conforms to :voc/kwi-spec
Returns a qname for instance of Resource.
qname
this
is an instance of Resource
qname
conforms to :voc/qname-spec
Returns a qname for instance of Resource. - Signature: [this] -> `qname` - Where - `this` is an instance of `Resource` - `qname` conforms to `:voc/qname-spec`
Returns URI string for instance of Resource.
uri-string
this
is a Resourceuri-string
conforms to :voc/uri-str-spec
Returns URI string for instance of Resource. - Signature: [this] -> `uri-string` - Where - `this` is a Resource - `uri-string` conforms to `:voc/uri-str-spec`
(clear-caches!)
Side-effects: resets all caches in voc/ to nil NOTE: call this when you may have imported new namespace metadata
Side-effects: resets all caches in voc/ to nil NOTE: call this when you may have imported new namespace metadata
(cljc-all-ns)
Returns (ns-name-or-obj
...)
Where
ns-name-or-obj
may either be a namespace (in clj)
or the name of a namespace (in cljs)Returns (`ns-name-or-obj` ...) Where - `ns-name-or-obj` may either be a namespace (in clj) or the name of a namespace (in cljs)
(cljc-find-ns ns')
Returns ns-name-or-obj
for ns'
, or nil.
Where
ns-name-or-obj
may either be a namespace (in clj)
or the name of a namespace (in cljs)_ns
is a symbol which may name a namespace.
NOTE: Implementations involving cljs must use cljs-put/get-ns-meta to declare
ns metadata.Returns `ns-name-or-obj` for `ns'`, or nil. Where - `ns-name-or-obj` may either be a namespace (in clj) or the name of a namespace (in cljs) - `_ns` is a symbol which may name a namespace. NOTE: Implementations involving cljs must use cljs-put/get-ns-meta to declare ns metadata.
(cljc-find-prefixes re-str s)
Returns #{prefix
...} for s
matching re-str
Where
prefix
is a prefix found in s
, for which some (meta ns) has a
:vann/preferredNamespacePrefix declarationre-str
is a regex strings
is a string, typically a SPARQL query body for which we want to
infer prefix declarations.Returns #{`prefix`...} for `s` matching `re-str` Where - `prefix` is a prefix found in `s`, for which some (meta ns) has a :vann/preferredNamespacePrefix declaration - `re-str` is a regex string - `s` is a string, typically a SPARQL query body for which we want to infer prefix declarations.
Deprecated. Use get-ns-meta
Deprecated. Use get-ns-meta
(cljc-ns-aliases)
Returns {alias
ns
, ...}
Where
alias
is a symbolns
is its associated ns in the current lexical environment.
NOTE: cljs will require explicit maintenance of alias-map
This is really only necessary if you're importing a package
as some symbol other than the preferred prefix.Returns {`alias` `ns`, ...} Where - `alias` is a symbol - `ns` is its associated ns in the current lexical environment. NOTE: cljs will require explicit maintenance of *alias-map* This is really only necessary if you're importing a package as some symbol other than the preferred prefix.
mimics behavior of ns-map
on cljs, but returns empty symbol->binding map
mimics behavior of `ns-map` on cljs, but returns empty symbol->binding map
Deprecated. Use put-ns-meta!
Deprecated. Use put-ns-meta!
Namespaces in cljs are not proper objects, and there is no metadata available at runtime. This atom stores 'pseudo-metadata' declared with cljc-put-ns-metadata and accessed with cljc-get-metadata. Clj just uses the metadata regime for its ns's
Namespaces in cljs are not proper objects, and there is no metadata available at runtime. This atom stores 'pseudo-metadata' declared with cljc-put-ns-metadata and accessed with cljc-get-metadata. Clj just uses the metadata regime for its ns's
(escape-slash s)
Replaces a slash in s
with a backslash-escaped slash
Replaces a slash in `s` with a backslash-escaped slash
deprecated alias for dynamic var exceptional-iri-str-re
deprecated alias for dynamic var *exceptional-iri-str-re*
(get-ns-meta)
(get-ns-meta ns')
Returns metadata
assigned to ns named ns'
Where
ns'
names a namespace or a 'dummy' namespace whose sole purpose is to hold metadata.metadata
:= {key
value
, ...}key
is a keyword containing vocabulary metadata, e.g. :vann/preferredNamespacePrefixReturns `metadata` assigned to ns named `ns'` Where - `ns'` names a namespace or a 'dummy' namespace whose sole purpose is to hold metadata. - `metadata` := {`key` `value`, ...} - `key` is a keyword containing vocabulary metadata, e.g. :vann/preferredNamespacePrefix
(keyword-for uri)
(keyword-for on-no-ns uri)
Returns a keyword equivalent of uri
, properly prefixed if Vann declarations exist in some ns in the current lexical environment.
on-no-ns
uri
is a string representing a URIon-no-ns
(optional) := fn [uri kw] -> kwi',
possibly with side-effects in response to the fact that no qname was found for
uri
(default returns kw
)on-no-ns
would log a warning or make an assertion.Returns a keyword equivalent of `uri`, properly prefixed if Vann declarations exist in some ns in the current lexical environment. - Side effects per `on-no-ns` - Where - `uri` is a string representing a URI - `on-no-ns` (optional) := fn [uri kw] -> kwi', possibly with side-effects in response to the fact that no qname was found for `uri` (default returns `kw`) - NOTE: typically `on-no-ns` would log a warning or make an assertion.
(namespace-re)
Returns a regex to recognize substrings matching a URI for an ns declared with LOD metadata.
Returns a regex to recognize substrings matching a URI for an ns declared with LOD metadata. - Note: Groups for namespace and value.
(namespace-to-ns)
returns {namespace
ns
...} for each ns
with :vann/preferredNamespaceUri
declaration
namespace
is the URI suitable for for an RDF prefix declarationns
is either a clojure ns (clj) or a symbol naming a clojure ns (cljs).returns {`namespace` `ns` ...} for each `ns` with :vann/preferredNamespaceUri declaration - Where - `namespace` is the URI suitable for for an RDF prefix declaration - `ns` is either a clojure ns (clj) or a symbol naming a clojure ns (cljs).
(ns-to-namespace ns')
Returns iri
for ns
ns'
is an instance of clojure.lang.Namespace (in clj) or a symbol-name for ns (cljs)iri
is an iri declared with :vann/preferredNamespaceUri in the metadata for
ns'
, or nilReturns `iri` for `ns` - Where - `ns'` is an instance of clojure.lang.Namespace (in clj) or a symbol-name for ns (cljs) - `iri` is an iri declared with :vann/preferredNamespaceUri in the metadata for `ns'`, or nil
(ns-to-prefix ns')
Returns the prefix associated with ns'
ns'
is a clojure namespace, which may have :vann/preferredNamespacePrefix
declaration in its metadata.Returns the prefix associated with `ns'` - Where - `ns'` is a clojure namespace, which may have :vann/preferredNamespacePrefix declaration in its metadata.
(on-duplicate-prefix prefixes prefix ns')
Throws an error if a prefix is bound to more than one namespace.
Reduces into prefix
argument
prefixes
:= {prefix
ns
, ...}prefix
:= is a string naming the vann:preferredNamespaceUri
for ns'
ns'
refers to a namespaceThrows an error if a prefix is bound to more than one namespace. Reduces into `prefix` argument - Where - `prefixes` := {`prefix` `ns`, ...} - `prefix` := is a string naming the `vann:preferredNamespaceUri` for `ns'` - `ns'` refers to a namespace
A regex matching a standard IRI string.
A regex matching a standard IRI string.
(prefix-re-str)
Returns a regex string that recognizes prefixes declared in ns metadata with :vann/preferredNamespacePrefix
keys.
Returns a regex string that recognizes prefixes declared in ns metadata with `:vann/preferredNamespacePrefix` keys. - NOTE: this is a string because the actual re-pattern will differ per clj/cljs.
(prefix-to-namespace-uri prefix)
returns namespace
URI associated with prefix
prefix
is a string declared for ns
with vann/preferredNamespacePrefixnamespace
is a string declared for some ns
with vann/preferredNamespaceUrireturns `namespace` URI associated with `prefix` - Where: - `prefix` is a string declared for `ns` with vann/preferredNamespacePrefix - `namespace` is a string declared for some `ns` with vann/preferredNamespaceUri
(prefix-to-ns)
Returns {prefix
ns
...}
prefix
is declared in metadata for some ns
with
:vann/preferredNamespacePrefixns
is an instance of clojure.lang.ns available within the lexical
context in which the call was made.Returns {`prefix` `ns` ...} - Where - `prefix` is declared in metadata for some `ns` with :vann/preferredNamespacePrefix - `ns` is an instance of clojure.lang.ns available within the lexical context in which the call was made.
(prefixed-ns prefix)
Returns nil or the ns whose prefix
was declared in metadata with :vann/preferredNamespacePrefix
.
prefix
is a string, typically parsed from a keyword.Returns nil or the ns whose `prefix` was declared in metadata with `:vann/preferredNamespacePrefix`. - Where - `prefix` is a string, typically parsed from a keyword.
(prefixes-for sparql-string)
(prefixes-for prefix-fn content-string)
Returns [prefix-string
...] for each prefix identified in content-string
.
content-string
is a string of SPARQL, typically without prefixes
prefix-string
:= PREFIX prefix
: namespace
prefix
is a prefix defined for namespace
in metadata of some ns with
:vann/preferredNamespacePrefix
namespace
is a namespace defined in the metadata for some ns with
:vann/preferredNamespaceUri
Returns [`prefix-string`...] for each prefix identified in `content-string`. - Where - `content-string` is a string of SPARQL, typically without prefixes - `prefix-string` := PREFIX `prefix`: `namespace` - `prefix` is a prefix defined for `namespace` in metadata of some ns with `:vann/preferredNamespacePrefix` - `namespace` is a namespace defined in the metadata for some ns with `:vann/preferredNamespaceUri`
(prepend-prefix-declarations content-string)
(prepend-prefix-declarations prefixes-for-fn content-string)
Returns content-string
, prepended with appropriate PREFIX decls.
content-string
is a string of SPARQL or Turtle/n3, typically without prefixes.
prefixes-for
:= fn [content-string] -> prefixes-string.
turtle-prefixes-for
Returns `content-string`, prepended with appropriate PREFIX decls. - Where - `content-string` is a string of SPARQL or Turtle/n3, typically without prefixes. - default is SPARQL - `prefixes-for` := fn [content-string] -> prefixes-string. - in practice this would only be needed for `turtle-prefixes-for`
(put-ns-meta! m)
(put-ns-meta! ns' m)
Side-effect: ensures that subsequent calls to (cljc-get-ns-meta ns'
return m
Where
ns'
is an ns(clj only) or the name of a namespace, possibly declared for the sole purpose of holding vocabulary metadata (e.g. rdf, foaf, etc)m
:= {key
value
, ...}, metadata (clj) or 'pseudo-metadata' (cljs)key
is a keyword containing vocabulary metadata, e.g.
::vann/preferredNamespacePrefix
NOTE: In cljs, ns's are not available at runtime, so the metadata is stored
in an atom called 'voc/cljs-ns-metadata'
See also declarations for ont-app.vocabulary.rdf, ont-app.vocabulary.foaf, etc.
for examples of namespaces declared solely to hold vocabulary metadata.Side-effect: ensures that subsequent calls to (cljc-get-ns-meta `ns'` return `m` Where - `ns'` is an ns(clj only) or the name of a namespace, possibly declared for the sole purpose of holding vocabulary metadata (e.g. rdf, foaf, etc) - `m` := {`key` `value`, ...}, metadata (clj) or 'pseudo-metadata' (cljs) - `key` is a keyword containing vocabulary metadata, e.g. `::vann/preferredNamespacePrefix` NOTE: In cljs, ns's are not available at runtime, so the metadata is stored in an atom called 'voc/cljs-ns-metadata' See also declarations for ont-app.vocabulary.rdf, ont-app.vocabulary.foaf, etc. for examples of namespaces declared solely to hold vocabulary metadata.
(qname-for kw)
Returns the 'qname' URI for kw
, or <...>'d full URI if no valid qname could be found.
kw
is a keyword, in a namespace with LOD declarations in its metadata.Returns the 'qname' URI for `kw`, or <...>'d full URI if no valid qname could be found. - Throws an error if the prefix is specified, but can't be mapped to metadata. - Where - `kw` is a keyword, in a namespace with LOD declarations in its metadata.
(qname-re)
Returns a regex s.t. 'my-ns:my-name' will parse to ['my-ns:my-name' 'my-ns' 'my-name']
Returns a regex s.t. 'my-ns:my-name' will parse to ['my-ns:my-name' 'my-ns' 'my-name']
(register-resource-type-context! child parent)
Side-effect: Establishes child
in the (hopefully singleton) set of most-specific resource type context in @resource-types.
child
names a resource type context on which methods may be dispatchedparent
names a resource type context on which methods may be dispatchedresource-types
is an atom tracking state for resource type inferenceSide-effect: Establishes `child` in the (hopefully singleton) set of most-specific resource type context in @resource-types. - Where - `child` names a resource type context on which methods may be dispatched - `parent` names a resource type context on which methods may be dispatched - @`resource-types` is an atom tracking state for resource type inference
Deprecated. Use resource-type multimethod instead.
Deprecated. Use resource-type multimethod instead.
(resource-class this)
resource-type
, informed by @resource-types
this
is something renderable as a URI, KWI, qname, or some other resource ID.resource-type
names a resource type on which as-uri-string
, as-kwi
, as-qname
or other methods might be dispatched.resource-types
:= m s.t. (keys m) = #{::context-fn
...}context-fn
:= fn [] -> resource-type-context
resource-type-dispatch
:= [this] -> [resource-type-context
(type this)]- Signature [this] -> `resource-type`, informed by @`resource-types` - Where - `this` is something renderable as a URI, KWI, qname, or some other resource ID. - `resource-type` names a resource type on which `as-uri-string`, `as-kwi`, `as-qname` or other methods might be dispatched. - @`resource-types` := m s.t. (keys m) = #{`::context-fn` ...} - `context-fn` := fn [] -> `resource-type-context` - NOTE: `resource-type-dispatch` := [this] -> [`resource-type-context` (type this)]
(resource-type-dispatch this)
Returns [type-context
(type this)]
this
is something which we may want to render as a URI or related construct.type-context
is a keyword naming a context to which dispatch methods are keyed
resource-types
) := fn [] -> :type-context
select-most-specific-descendant
::resource-type-context
)Returns [`type-context` (type this)] - Where - `this` is something which we may want to render as a URI or related construct. - `type-context` is a keyword naming a context to which dispatch methods are keyed - it is the value of (::context-fn @`resource-types`) := fn [] -> :`type-context` - defaults to (partial `select-most-specific-descendant` `::resource-type-context`)
Truthy when two different resource identifiers refer to the same resource
this
is a Resourcethat
is a ResourceTruthy when two different resource identifiers refer to the same resource - Signature: [this that] -> truthy - Where - `this` is a Resource - `that` is a Resource
(sparql-prefix-declaration prefix)
Returns PREFIX prefix
: <uri
>.
prefix
is a prefix in the metadatauri
is the uri string associated with prefix
in the metadataReturns PREFIX `prefix`: <`uri`>. - Where - `prefix` is a prefix in the metadata - `uri` is the uri string associated with `prefix` in the metadata
(sparql-prefixes-for sparql-string)
Gets SPARQL prefixes from sparql-string
Gets SPARQL prefixes from `sparql-string`
Signature [obj
& maybe tag-spec
] -> dstr
obj
is something to be taggedtag-spec
is a resource, or (@lstr/default-tags (type obj
))dstr
:~ #voc/dstr obj
^^tag
tag
:= (as-kwi tag-spec
)Signature [`obj` & maybe `tag-spec`] -> `dstr` - Where - `obj` is something to be tagged - `tag-spec` is a resource, or (@lstr/default-tags (type `obj`)) - `dstr` :~ #voc/dstr `obj`^^`tag` - `tag` := (as-kwi `tag-spec`)
(tag-dispatch obj)
(tag-dispatch _obj tag-spec)
Returns tag
for obj
with optional tag-spec
obj
is something to be taggedtag-spec
is a resource, or (@lstr/default-tags (type obj
))tag
:= (as-kwi tag-spec
)Returns `tag` for `obj` with optional `tag-spec` - Where - `obj` is something to be tagged - `tag-spec` is a resource, or (@lstr/default-tags (type `obj`)) - `tag` := (as-kwi `tag-spec`)
Describes vocabulary for this namespace. May be read into an IGraph downstream.
Describes vocabulary for this namespace. May be read into an IGraph downstream.
(turtle-prefix-declaration prefix)
Returns @prefix prefix
: <uri
>.
prefix
is a prefix in the metadatauri
is the uri string associated with prefix
in the metadataReturns @prefix `prefix`: <`uri`>. - Where - `prefix` is a prefix in the metadata - `uri` is the uri string associated with `prefix` in the metadata
(turtle-prefixes-for ttl-string)
Gets Turtle prefixes from ttl-string
Gets Turtle prefixes from `ttl-string`
Signature: [dstr
& maybe on-not-found-fn
?]
tag
)dstr
:~ #voc/dstr obj
^^tag
on-not-found-fn
:= fn [dstr] -> clojure value or error.
error-on-no-untag-found
.Signature: [`dstr` & maybe `on-not-found-fn`?] - returns: clojure value appropriate to (as-kwi `tag`) - Where - `dstr` :~ #voc/dstr `obj`^^`tag` - `on-not-found-fn` := fn [dstr] -> clojure value or error. - Default is `error-on-no-untag-found`.
(untag-dispatch dstr & _)
Returns (as-kwi tag
) for dstr
dstr
:~ #voc/dstr obj
^^tag
tag
:= (as-qname tag-spec
)Returns (as-kwi `tag`) for `dstr` - Where - `dstr` :~ #voc/dstr `obj`^^`tag` - `tag` := (as-qname `tag-spec`)
(uri-for kw)
(uri-for on-no-kwi-ns kw)
Returns iri
for kw
based on metadata attached to ns
Alias of iri-for
or `on-no-prefix (kw) if the keyword is not namespaced.
kw
is a keyword of the form prefix
:value
on-no-kwi-ns
:= fn [kw] -> uri, for cases where kw
is not namespaced
default is default-on-no-kwi-ns
iri
is of the form namespace``value
ns
is an instance of clojure.lang.nsprefix
is declared with :vann/preferredNamespacePrefix in metadata of ns
namespace
is typically of the form http://...., declared with
:vann/preferredNamespaceUri
in metadata of ns
Returns `iri` for `kw` based on metadata attached to `ns` Alias of `iri-for` or `on-no-prefix (kw) if the keyword is not namespaced. - Where - `kw` is a keyword of the form `prefix`:`value` - `on-no-kwi-ns` := fn [kw] -> uri, for cases where `kw` is not namespaced default is `default-on-no-kwi-ns` - `iri` is of the form `namespace``value` - `ns` is an instance of clojure.lang.ns - `prefix` is declared with :vann/preferredNamespacePrefix in metadata of `ns` - `namespace` is typically of the form http://...., declared with `:vann/preferredNamespaceUri` in metadata of `ns`
Deprecated. Use Resource protocol and as-uri-string
instead.
Deprecated. Use Resource protocol and `as-uri-string` instead.
(vann-annotated-objects)
Returns `[obj, ...]
obj
bears metadata s.t. (get-ns-meta obj) includes :vann/... annotations
Returns `[obj, ...] - Where: - `obj` bears metadata s.t. (get-ns-meta obj) includes :vann/... annotations - these may be either namespaces or vars
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close