How to use the rdflib.SPARQLToQuery 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 solid / node-solid-server / lib / handlers / patch.js View on Github external
function sparql (filename, targetURI, text, callback) {
  debug('PATCH -- parsing query ...')
  var patchURI = targetURI // @@@ beware the triples from the patch ending up in the same place
  var patchKB = $rdf.graph()
  var targetKB = $rdf.graph()
  var targetContentType = mime.lookup(filename)
  var query = $rdf.SPARQLToQuery(text, false, patchKB, patchURI) // last param not used ATM

  fs.readFile(filename, {encoding: 'utf8'}, function (err, dataIn) {
    if (err) {
      return callback(error(404, 'Patch: Original file read error:' + err))
    }

    debug('PATCH -- File read OK ' + dataIn.length)
    debug('PATCH -- parsing target file ...')

    try {
      $rdf.parse(dataIn, targetKB, targetURI, targetContentType)
    } catch (e) {
      debug('Patch: Target ' + targetContentType + ' file syntax error:' + e)
      return callback(error(500, 'Patch: Target ' + targetContentType + ' file syntax error:' + e))
    }
    debug('PATCH -- Target parsed OK ')
github solid / node-solid-server / lib / handlers / patch / sparql-patcher.js View on Github external
function patch (filename, targetURI, text, callback) {
  debug('PATCH -- parsing query ...')
  var patchURI = targetURI // @@@ beware the triples from the patch ending up in the same place
  var patchKB = $rdf.graph()
  var targetKB = $rdf.graph()
  var targetContentType = mime.lookup(filename) || DEFAULT_CONTENT_TYPE
  var query = $rdf.SPARQLToQuery(text, false, patchKB, patchURI) // last param not used ATM

  fs.readFile(filename, {encoding: 'utf8'}, function (err, dataIn) {
    if (err) {
      return callback(error(404, 'Patch: Original file read error:' + err))
    }

    debug('PATCH -- File read OK ' + dataIn.length)
    debug('PATCH -- parsing target file ...')

    try {
      $rdf.parse(dataIn, targetKB, targetURI, targetContentType)
    } catch (e) {
      debug('Patch: Target ' + targetContentType + ' file syntax error:' + e)
      return callback(error(500, 'Patch: Target ' + targetContentType + ' file syntax error:' + e))
    }
    debug('PATCH -- Target parsed OK ')
github solid / node-solid-server / lib / handlers / patch / n3-patch-parser.js View on Github external
return new Promise((resolve, reject) => {
    const query = $rdf.SPARQLToQuery(sparql, false, store)
    store.query(query, resolve, null, () => reject(new Error('No results.')))
  })
}
github jeff-zucker / sparql-fiddle / sparql-fiddle.js View on Github external
return new Promise((resolve, reject)=>{
            try {
              let query = $rdf.SPARQLToQuery(fiddle.query,false,fiddle.store)
              resolve(query)
            }
            catch(err) { reject(err) }
        })
    }