How to use the rdflib.literal function in rdflib

To help you get started, we’ve selected a few rdflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jolocom / smartwallet-app / src / js / lib / agents / graph.js View on Github external
baseNode(uri, writer, title, description, nodeType, centerNode) {
    if (!writer || !nodeType || !uri) {
      throw new Error('baseNode: not enough arguments')
    }

    if (title) {
      writer.addTriple($rdf.sym(uri), PRED.title, $rdf.literal(title))
    }
    if (description) {
      writer.addTriple(
        $rdf.sym(uri),
        PRED.description,
        $rdf.literal(description)
      )
    }
    writer.addTriple($rdf.sym(uri), PRED.storage, $rdf.sym(centerNode.storage))
    writer.addTriple($rdf.sym(uri), PRED.maker, $rdf.sym(centerNode.uri))

    // TODO
    if (nodeType === 'image') {
      writer.addTriple($rdf.sym(uri), PRED.type, PRED.Image)
    } else {
      writer.addTriple($rdf.sym(uri), PRED.type, PRED.Document)
    }
    return writer
  }
github TopQuadrant / shacl / js / src / rdflib-graph.js View on Github external
var $rdf = require("rdflib");
var rdfquery = require("./rdfquery");
var T = rdfquery.T;

var errorHandler = require("debug")("rdflib-graph::error");


// Monkey Patching rdflib, Literals, BlankNodes and NamedNodes
var exLiteral = $rdf.literal("a", "de");
Object.defineProperty(Object.getPrototypeOf(exLiteral), "lex", { get: function () { return this.value } });
Object.getPrototypeOf(exLiteral).isBlankNode = function () { return false };
Object.getPrototypeOf(exLiteral).isLiteral = function () { return true };
Object.getPrototypeOf(exLiteral).isURI = function () { return false };

var exBlankNode = $rdf.blankNode();
Object.getPrototypeOf(exBlankNode).isBlankNode = function () { return true };
Object.getPrototypeOf(exBlankNode).isLiteral = function () { return false };
Object.getPrototypeOf(exBlankNode).isURI = function () { return false };

var exNamedNode = $rdf.namedNode("urn:x-dummy");
Object.getPrototypeOf(exNamedNode).isBlankNode = function () { return false };
Object.getPrototypeOf(exNamedNode).isLiteral = function () { return false };
Object.getPrototypeOf(exNamedNode).isURI = function () { return true };
github jolocom / smartwallet-app / src / js / lib / agents / chat.js View on Github external
setSubject(uri, oldSubject, newSubject) {
    const oldTriple = $rdf.st('', PRED.title, $rdf.literal(oldSubject))

    const newTriple = $rdf.st('', PRED.title, $rdf.literal(newSubject))

    return this.http.patch(uri, [oldTriple], [newTriple])
  }
github solid / node-solid-server / lib / models / account-manager.js View on Github external
addCertKeyToGraph (certificate, graph) {
    let webId = rdf.namedNode(certificate.webId)
    let key = rdf.namedNode(certificate.keyUri)
    let timeCreated = rdf.literal(certificate.date.toISOString(), ns.xsd('dateTime'))
    let modulus = rdf.literal(certificate.modulus, ns.xsd('hexBinary'))
    let exponent = rdf.literal(certificate.exponent, ns.xsd('int'))
    let title = rdf.literal('Created by solid-server')
    let label = rdf.literal(certificate.commonName)

    graph.add(webId, ns.cert('key'), key)
    graph.add(key, ns.rdf('type'), ns.cert('RSAPublicKey'))
    graph.add(key, ns.dct('title'), title)
    graph.add(key, ns.rdfs('label'), label)
    graph.add(key, ns.dct('created'), timeCreated)
    graph.add(key, ns.cert('modulus'), modulus)
    graph.add(key, ns.cert('exponent'), exponent)

    return graph
  }
github solid / node-solid-server / lib / models / account-manager.js View on Github external
addCertKeyToGraph (certificate, graph) {
    let webId = rdf.namedNode(certificate.webId)
    let key = rdf.namedNode(certificate.keyUri)
    let timeCreated = rdf.literal(certificate.date.toISOString(), ns.xsd('dateTime'))
    let modulus = rdf.literal(certificate.modulus, ns.xsd('hexBinary'))
    let exponent = rdf.literal(certificate.exponent, ns.xsd('int'))
    let title = rdf.literal('Created by solid-server')
    let label = rdf.literal(certificate.commonName)

    graph.add(webId, ns.cert('key'), key)
    graph.add(key, ns.rdf('type'), ns.cert('RSAPublicKey'))
    graph.add(key, ns.dct('title'), title)
    graph.add(key, ns.rdfs('label'), label)
    graph.add(key, ns.dct('created'), timeCreated)
    graph.add(key, ns.cert('modulus'), modulus)
    graph.add(key, ns.cert('exponent'), exponent)

    return graph
  }
github solid / node-solid-server / lib / models / account-manager.js View on Github external
addCertKeyToGraph (certificate, graph) {
    let webId = rdf.namedNode(certificate.webId)
    let key = rdf.namedNode(certificate.keyUri)
    let timeCreated = rdf.literal(certificate.date.toISOString(), ns.xsd('dateTime'))
    let modulus = rdf.literal(certificate.modulus, ns.xsd('hexBinary'))
    let exponent = rdf.literal(certificate.exponent, ns.xsd('int'))
    let title = rdf.literal('Created by solid-server')
    let label = rdf.literal(certificate.commonName)

    graph.add(webId, ns.cert('key'), key)
    graph.add(key, ns.rdf('type'), ns.cert('RSAPublicKey'))
    graph.add(key, ns.dct('title'), title)
    graph.add(key, ns.rdfs('label'), label)
    graph.add(key, ns.dct('created'), timeCreated)
    graph.add(key, ns.cert('modulus'), modulus)
    graph.add(key, ns.cert('exponent'), exponent)

    return graph
  }
github solid / solid-ui / src / widgets / peoplePicker.js View on Github external
const updatePromises = [this.group.doc(), groupIndex].map(namedGraph => {
      const oldNameStatements = kb.match(
        this.group,
        ns.vcard('fn'),
        null,
        namedGraph
      )
      const newNameStatement = rdf.st(
        this.group,
        ns.vcard('fn'),
        rdf.literal(name)
      )
      return patch(namedGraph.value, {
        toDel: oldNameStatements,
        toIns: [newNameStatement]
      }).then(_solidResponse => {
        kb.removeStatements(oldNameStatements)
        newNameStatement.why = namedGraph
        kb.add(newNameStatement)
      })
    })
    return Promise.all(updatePromises)
github solid / node-solid-server / lib / models / account-manager.js View on Github external
addCertKeyToGraph (certificate, graph) {
    let webId = rdf.namedNode(certificate.webId)
    let key = rdf.namedNode(certificate.keyUri)
    let timeCreated = rdf.literal(certificate.date.toISOString(), ns.xsd('dateTime'))
    let modulus = rdf.literal(certificate.modulus, ns.xsd('hexBinary'))
    let exponent = rdf.literal(certificate.exponent, ns.xsd('int'))
    let title = rdf.literal('Created by solid-server')
    let label = rdf.literal(certificate.commonName)

    graph.add(webId, ns.cert('key'), key)
    graph.add(key, ns.rdf('type'), ns.cert('RSAPublicKey'))
    graph.add(key, ns.dct('title'), title)
    graph.add(key, ns.rdfs('label'), label)
    graph.add(key, ns.dct('created'), timeCreated)
    graph.add(key, ns.cert('modulus'), modulus)
    graph.add(key, ns.cert('exponent'), exponent)

    return graph
  }