currently I try to execute CONSTRUCT and SELECT queries via the rdfstore-js library. However, if I execute the queries, the result array is empty, although there should be values.
First I load a graph into the store.
In the second step, I add some triples to the loaded graph in the following way:
`store.graph((err, g) => {
for (let feat in featVector) {
let subject = store.rdf.createNamedNode(store.rdf.resolve("wiki:HearRate"))
let predicate = store.rdf.createNamedNode(store.rdf.resolve("property:HasValue"))
let literal = store.rdf.createLiteral("45", undefined, store.rdf.resolve("xsd:double"))
let statement = store.rdf.createTriple(subject, predicate, literal)
g.add(statement)
}
//Here I make SELECT Queries to the graph
for (let query in stateRules) {
store.execute(stateRules[query], (err, res) => {
if (err == null) {
res.forEach((triple) => {
states.push(triple.state.value)
})
}
})
}
})`
Regarding the literal expression:
let literal = store.rdf.createLiteral("45", undefined, store.rdf.resolve("xsd:double"))
I also tried these two alternatives, since I was not sure which one of them works:
let literal = store.rdf.createLiteral("45")
and let literal = store.rdf.createLiteral("45"^^xsd:double)
If I put away the FILTER expression and the HasValue statement, then it works. Therefore, I think something goes wrong as I add new triple statements to the graph with the appropriate values. My questions is now, how to make it right?
For instance, I could not find an example that shows how to add double value literals to the graph. Second, what do I have to change in the FILTER expression so that it works? Any hints and solutions regarding this issue are appreciated.
Hi,
currently I try to execute CONSTRUCT and SELECT queries via the rdfstore-js library. However, if I execute the queries, the result array is empty, although there should be values.
First I load a graph into the store. In the second step, I add some triples to the loaded graph in the following way: `store.graph((err, g) => { for (let feat in featVector) { let subject = store.rdf.createNamedNode(store.rdf.resolve("wiki:HearRate")) let predicate = store.rdf.createNamedNode(store.rdf.resolve("property:HasValue")) let literal = store.rdf.createLiteral("45", undefined, store.rdf.resolve("xsd:double")) let statement = store.rdf.createTriple(subject, predicate, literal) g.add(statement) }
//Here I make SELECT Queries to the graph for (let query in stateRules) { store.execute(stateRules[query], (err, res) => { if (err == null) { res.forEach((triple) => { states.push(triple.state.value) }) } }) } })`
Regarding the literal expression:
let literal = store.rdf.createLiteral("45", undefined, store.rdf.resolve("xsd:double"))
I also tried these two alternatives, since I was not sure which one of them works:
let literal = store.rdf.createLiteral("45")
andlet literal = store.rdf.createLiteral("45"^^xsd:double)
My select queries look like the following:
If I put away the FILTER expression and the HasValue statement, then it works. Therefore, I think something goes wrong as I add new triple statements to the graph with the appropriate values. My questions is now, how to make it right? For instance, I could not find an example that shows how to add double value literals to the graph. Second, what do I have to change in the FILTER expression so that it works? Any hints and solutions regarding this issue are appreciated.
Best, Nicole