GithubHelp home page GithubHelp logo

Comments (6)

RubenVerborgh avatar RubenVerborgh commented on May 28, 2024

Do you have the steps to reproduce?

from sparql.js.

alexander-schulze avatar alexander-schulze commented on May 28, 2024

I ran the following steps:

  • created a blank new node.js project (node 12.20.0, npm 7.7.6, V8: 7.8.279.23-node.45)
  • ran npm init, initial package.json:
{
  "name": "sparqljs-test",
  "version": "1.0.0",
  "description": "SPARQLJS Test",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/innotrade/sparqljs-test.git"
  },
  "keywords": [
    "SPARQL",
    "JS"
  ],
  "author": "Alexander Schulze",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/innotrade/sparqljs-test/issues"
  },
  "homepage": "https://github.com/innotrade/sparqljs-test#readme",
  "dependencies": {
    "sparqljs": "^3.4.1"
  }
}

/Users/alexanderschulze/.nvm/versions/node/v12.20.0/bin/node ./index.js
Process exited with code 1
Uncaught TypeError: Cannot read property 'termType' of undefined

The parser works fine, I can see the resulting SPARQL AST object.
The generator.stringify(parsedQuery); raises the above exception.

var generator = new SparqlGenerator({
  /* prefixes, baseIRI, factory, sparqlStar */
});
parsedQuery.variables = ["?mickey"];
var generatedQuery = generator.stringify(parsedQuery);

Thanks in advance for your support!

from sparql.js.

alexander-schulze avatar alexander-schulze commented on May 28, 2024

My launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "pwa-node",
      "request": "launch",
      "name": "Launch Program",
      "runtimeVersion": "12.20.0",
      "skipFiles": ["<node_internals>/**"],
      "program": "${workspaceFolder}/index.js"
    }
  ]
}

from sparql.js.

alexander-schulze avatar alexander-schulze commented on May 28, 2024

Missed to say thanks for the quick response. Just granted you access to @innotrade/sparqljs-test.

from sparql.js.

alexander-schulze avatar alexander-schulze commented on May 28, 2024

Debugged it and found it, the parsedQuery.variables = ['?mickey']; is causing the error.
I will play more with it and give you feedback. Would be interested in a cooperation on that one.

from sparql.js.

AlexeyMz avatar AlexeyMz commented on May 28, 2024

@alexander-schulze SPARQL.js uses RDF/JS spec to represent RDF terms including variables, so you need to use RDF term factory to create variable in this case:

import { DataFactory } from 'rdf-data-factory';
var generator = new SparqlGenerator({
  /* prefixes, baseIRI, factory, sparqlStar */
});
var dataFactory = new DataFactory();
parsedQuery.variables = [dataFactory.variable("mickey")];
var generatedQuery = generator.stringify(parsedQuery);

from sparql.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.