-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is possible to generate BlankNodes from data references? #271
Comments
You can just construct bnodes: PREFIX ex: <http://example/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
CONSTRUCT {
[] ex:p ?A
} WHERE {
SERVICE <x-sparql-anything:> {
fx:properties fx:location "./data.csv" ; fx:csv.headers true .
[] xyz:c2 ?A
}
} or, if you want to control the bnode identifier for some reason: PREFIX ex: <http://example/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
CONSTRUCT {
?bnode ex:p ?A
} WHERE {
SERVICE <x-sparql-anything:> {
fx:properties fx:location "./data.csv" ; fx:csv.headers true .
[] xyz:c1 ?b0 ; xyz:c2 ?A
}
BIND ( BNODE ( ?b0 ) as ?bnode )
} |
I've arrived at this point, yes, but you can not take the identifier of the BN from the input source, right? |
You can take it from there, as you see in the second query. I am not sure I get the use case here. |
you could do this: curl --silent 'http://localhost:3000/sparql.anything' \
--header "Accept: text/csv" \
--data-urlencode 'query=
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT *
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:location "/app/input.csv" ;
fx:csv.headers true .
?s ?p ?o
BIND(iri(?s) AS ?s_iri)
}
}
' yielding:
|
oh, i know what you want now. |
it appears that apache jena does not let you synthesize a bnode identifier manually. curl --silent 'http://localhost:3000/sparql.anything' \
--header "Accept: application/n-quads" \
--data-urlencode 'query=
PREFIX : <http://example.com/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
CONSTRUCT
{
?new_s_iri :p ?new_c2 .
?new_s_str :p ?new_c2 .
}
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:location "/app/input.csv" ;
fx:csv.headers true .
?s xyz:c1 ?c1 ;
xyz:c2 ?c2
BIND(iri(concat("_:", ?c1)) AS ?new_s_iri)
BIND(concat("_:", ?c1) AS ?new_s_str)
BIND(iri(concat(str(:), ?c2)) AS ?new_c2)
}
}
' yields:
|
@justin2004 yeah, exactly! I was able to obtain the same results, but I don't think that any of the results are valid RDF, right? For letting you know, this is coming from this R2RML test-cases: https://www.w3.org/2001/sw/rdb2rdf/test-cases/#R2RMLTC0002b. It is not that I specifically want to have this feature in the engine but it is more for comparing both solutions. One of the main benefits of having this feature is that identifiers do not have to be maintained in memory during the execution. |
I don't think it is possible to control the blank nodes that are generated by the serializer, but this is probably a question for However, while playing with this use case I found an interesting issue when one wants to generate multiple triples with the same bnode on different construct template projections. At the moment, a new bnode is generated for every projection, even if we use the |
I thought I just wasn't understanding how to use bnode() with an argument but since you might have also expected different behavior I opened an issue: |
Considering they are bnodes, the comparison can be done via graph isomorphism (there are some useful utils for this in Jena). |
The behavior should be similar to the one in RML:
Input
Output:
The text was updated successfully, but these errors were encountered: