Module:MySPARQL: Difference between revisions

From MaRDI portal
Created page with "local sparql = require('SPARQL') -- Load the SPARQL binding local p = {} function p.showFirstValue(frame) local sparqlQuery = frame.args[1] local queryResults = sparql.runQuery(sparqlQuery) -- Use the runQuery method -- Replace "work" with the first SELECT variable in your SPARQL query return queryResults['results']['bindings'][1]['work']['value'] end return p"
 
No edit summary
Line 8: Line 8:


   -- Replace "work" with the first SELECT variable in your SPARQL query
   -- Replace "work" with the first SELECT variable in your SPARQL query
   return queryResults['results']['bindings'][1]['work']['value']
   return queryResults['results']['bindings'][0]['work']['value']
end
end


return p
return p

Revision as of 08:43, 26 November 2023

Documentation for this module may be created at Module:MySPARQL/doc

local sparql = require('SPARQL') -- Load the SPARQL binding

local p = {}

function p.showFirstValue(frame)
  local sparqlQuery = frame.args[1]
  local queryResults = sparql.runQuery(sparqlQuery) -- Use the runQuery method

  -- Replace "work" with the first SELECT variable in your SPARQL query
  return queryResults['results']['bindings'][0]['work']['value']
end

return p