How to use the rdflib.sparqlUpdateParser 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 sparqlUpdate (filename, targetURI, text, callback) {
  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)

  debug('PATCH -- parsing patch ...')
  var patchObject
  try {
    // Must parse relative to document's base address but patch doc should get diff URI
    patchObject = $rdf.sparqlUpdateParser(text, patchKB, patchURI)
  } catch (e) {
    return callback(error(400, 'Patch format syntax error:\n' + e + '\n'))
  }
  debug('PATCH -- reading target file ...')

  waterfall([
    (cb) => {
      fs.stat(filename, (err) => {
        if (!err) return cb()

        fs.writeFile(filename, '', (err) => {
          if (err) {
            return cb(error(err, 'Error creating the patch target'))
          }
          cb()
        })
github solid / node-solid-server / lib / handlers / patch / sparql-update-patcher.js View on Github external
return new Promise((resolve, reject) => {
    const baseURI = patchURI.replace(/#.*/, '')
    try {
      resolve($rdf.sparqlUpdateParser(patchText, patchKB, baseURI))
    } catch (err) {
      reject(error(400, 'Patch format syntax error:\n' + err + '\n'))
    }
  })
}
github solid / node-solid-server / lib / handlers / patch / sparql-update-parser.js View on Github external
async function parsePatchDocument (targetURI, patchURI, patchText) {
  const baseURI = patchURI.replace(/#.*/, '')
  try {
    return $rdf.sparqlUpdateParser(patchText, $rdf.graph(), baseURI)
  } catch (err) {
    throw error(400, `Patch document syntax error: ${err}`)
  }
}