rdf-query.md

March 28, 2021 · View on GitHub

solidAPI.rdf

minimal class to query, edit and write rdf files content in N3 store using solid-namespace to access namedNode, literal

Kind: global class

solidAPI.rdf.cache : Object.<string, N3.N3Store>

cache of N3.store : cache[url] is the store of url example :

  • to add a quadsArray to the store : cache[url].addQuads(quadsArray)
  • all N3 store functions can be used

Kind: instance property of solidAPI.rdf

solidAPI.rdf.setPrefix(prefix, url)

Kind: instance method of solidAPI.rdf

ParamType
prefixstring
urlstring

solidAPI.rdf.getPrefix(prefix) ⇒ string

Kind: instance method of solidAPI.rdf
Returns: string - url

ParamType
prefixstring

solidAPI.rdf.query(source, s, p, o, g) ⇒ Array.<N3.Quad>

loads a Turtle file, parses it, returns an array of quads expects URL of a source file, if empty, uses previously loaded file expects Turtle strings for subject, predicate, object, & optional graph supports this non-standard syntax for Turtle strings -

  • {somePrefix:someTerm} somePrefix is then replaced using URLs from solid-namespace the special prefix thisDoc {thisDoc:me} uses current doc as namespace
  • N3 quad subject, predicate, object and optional graph

Kind: instance method of solidAPI.rdf

ParamTypeDescription
sourcestringurl to the turtle file
snull | string | objectsubject
pnull | string | objectpredicate
onull | string | objectobject
gnull | string | objectgraph

solidAPI.rdf.queryTurtle(url, turtle, s, p, o, g) ⇒ Array.<N3.Quad>

Kind: instance method of solidAPI.rdf

ParamTypeDescription
urlstringof cache[url]
turtlestring
snull | string | objectsubject
pnull | string | objectpredicate
onull | string | objectobject
gnull | string | objectgraph

solidAPI.rdf.parseUrl(url) ⇒ cache.url.<N3.store>

fetch url, parse and create cache[url]=N3.store

Kind: instance method of solidAPI.rdf
Returns: cache.url.<N3.store> - store=cache[url]

ParamType
urlstring

solidAPI.rdf.parse(url, turtle, [options]) ⇒ cache.url.<N3.store>

parse RDF and create cache[url]=N3.store

Kind: instance method of solidAPI.rdf
Returns: cache.url.<N3.store> - store=cache[url]

ParamTypeDescription
urlstring
turtlestring
[options]objectfor N3.parser

Properties

NameTypeDescription
documentoptions.baseIRIurl
allowedoptions.formatRDF format

solidAPI.rdf.addQuad(url, s, p, o, g)

add quad to cache[url] store with special solid syntax

Kind: instance method of solidAPI.rdf

ParamTypeDescription
urlstringof cache[url]
snull | string | objectsubject
pnull | string | objectpredicate
onull | string | objectobject
gnull | string | objectgraph

solidAPI.rdf.removeMatches(url, s, p, o, g)

remove matching quads from cache[url] store using special solid syntax

Kind: instance method of solidAPI.rdf

ParamTypeDescription
urlstringof cache[url]
snull | string | objectsubject
pnull | string | objectpredicate
onull | string | objectobject
gnull | string | objectgraph

solidAPI.rdf.write(url, [options]) ⇒ document.<string>

Write RDF content from cache[url] store with N3.writer using relative notation to baseIRI

Kind: instance method of solidAPI.rdf
Returns: document.<string> - RDF document

ParamTypeDescription
urlstring: to access cache[url]
[options]object

Properties

NameTypeDescription
N3.witeroptions.format.<string>allowed rdf contentType default 'text/turtle'
N3.writeroptions.prefixes.<object>prefixes
oneoptions.prefix.<string>of termType used to build automatic prefixes default 'predicate'
documentoptions.baseIRI.<string>baseIRI to use relative notation with 'text/turtle'

solidAPI.rdf.writeQuads(quadsArray, options) ⇒ document.<string>

Write RDF content from regular array of quads

Kind: instance method of solidAPI.rdf
Returns: document.<string> - RDF document

ParamTypeDescription
quadsArrayarray
optionsobjectfor N3.Writer

Properties

Type
options.format
options.prefixes

solidAPI.rdf._getPrefixes(url, options) ⇒ object

get the list of NamedNode prefixes using solidNames for an url or cache[url] store example : list of NamedNode predicates

Kind: instance method of solidAPI.rdf
Returns: object - prefixes

ParamType
urlstring
optionsobject

Properties

NameTypeDescription
'subject''predicate''object'
excludesoptions.baseIRIbaseIRI from prefixes to allow make relative in write

solidAPI.rdf._getTermList(type, quadsArray)

List of 'namedNode' values for a type of termType

Kind: instance method of solidAPI.rdf

ParamType
type"subject" | "predicate" | "object"
quadsArrayarray

solidAPI.rdf._makeRelativeUrl(turtle, url) ⇒ string

Make turtle content relative to an url resource

  • make absolute paths relative to document

Kind: instance method of solidAPI.rdf
Returns: string - turtle

ParamTypeDescription
turtlestring
urlstringresource url