You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by "justin2004 (via GitHub)" <gi...@apache.org> on 2026/04/16 18:49:19 UTC

[I] sparql construct: unbound variables in blank node notation [jena]

justin2004 opened a new issue, #3866:
URL: https://github.com/apache/jena/issues/3866

   ### Version
   
   6.0.0
   
   ### Question
   
   > If any such instantiation produces a triple containing an unbound variable or an illegal RDF construct, such as a literal in subject or predicate position, then that triple is not included in the output RDF graph.
   
   https://www.w3.org/TR/sparql11-query/#construct
   
   Executing this:
   ```sparql
   prefix u: <uri:>
   construct {
     u:thingA u:a [ u:time ?then ] .
     u:thingB u:time ?then .
     [ u:timeB ?then ]
   }
   where {
     bind(now() as ?now)
   }
   ```
   
   With an empty `a.ttl`...
   ```turtle
   $ /path/apache-jena-6.0.0/bin/sparql --data=a.ttl --query=./a.rq
   PREFIX u: <uri:>
   
   u:thingA  u:a   []  .
   ```
   
   Based on reading the SPARQL 1.1 doc I don't expect any triples to be produced.
   Applying the rule from the inside out...
   - `?then` is not bound
     - therefore don't produce `[ u:time ?then ] `
       - if `[ u:time ?then ] ` isn't produced
         - then `u:thingA u:a [ u:time ?then ] ` shouldn't be produced


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] sparql construct: unbound variables in blank node notation [jena]

Posted by "justin2004 (via GitHub)" <gi...@apache.org>.
justin2004 commented on issue #3866:
URL: https://github.com/apache/jena/issues/3866#issuecomment-4262777528

   @namedgraph 
   
   ```
   $ cat a.rq
   prefix u: <uri:>
   construct {
     u:thingA u:a _:b0 .
     _:b0 u:time ?then .
   }
   where {
     bind(now() as ?now)
   }
   $ /path/apache-jena-6.0.0/bin/sparql --data=a.ttl --query=./a.rq
   PREFIX u: <uri:>
   
   u:thingA  u:a   []  .
   ```
   
   Maybe you're right.
   
   Though it would be **really** nice to have a convenient way to build structure around a variable but don't output any of it if the variable is unbound.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] sparql construct: unbound variables in blank node notation [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #3866:
URL: https://github.com/apache/jena/issues/3866#issuecomment-5084998407

   This seems to have been answered : `u:thingA u:a [ u:time ?then ]` is a two triple template. It allocates a blank node and then used that for a second triple, which fails. That leaves the first triple.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] sparql construct: unbound variables in blank node notation [jena]

Posted by "namedgraph (via GitHub)" <gi...@apache.org>.
namedgraph commented on issue #3866:
URL: https://github.com/apache/jena/issues/3866#issuecomment-4262663969

   I think it would be clearer if you rewrote the template as separate triples with explicit bnode labels.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] sparql construct: unbound variables in blank node notation [jena]

Posted by "namedgraph (via GitHub)" <gi...@apache.org>.
namedgraph commented on issue #3866:
URL: https://github.com/apache/jena/issues/3866#issuecomment-4263182270

   > Though it would be **really** nice to have a convenient way to build structure around a variable but don't output any of it if the variable is unbound.
   
   What if you make the bnodes variables as well?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] sparql construct: unbound variables in blank node notation [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs closed issue #3866: sparql construct: unbound variables in blank node notation
URL: https://github.com/apache/jena/issues/3866


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] sparql construct: unbound variables in blank node notation [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #3866:
URL: https://github.com/apache/jena/issues/3866#issuecomment-4263060331

   It is what the spec says - for better or worse.
   
   In SHACL Rules, there are wellformed-ness conditions, one of which is a variable in the head must be defined in the body, and one which requires every variable in the body to be bound. The body pattern is not full SPARQL.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] sparql construct: unbound variables in blank node notation [jena]

Posted by "justin2004 (via GitHub)" <gi...@apache.org>.
justin2004 commented on issue #3866:
URL: https://github.com/apache/jena/issues/3866#issuecomment-4263251791

   > What if you make the bnodes variables as well?
   
   @namedgraph 
   
   ```
   prefix u: <uri:>
   construct {
   u:a u:b ?b .
   ?b u:time ?then .
   }
   where {
     bind(now() as ?now)
     bind(if(bound(?then),bnode(), 1/0 )   as ?b)
   }
   ```
   
   it works but it is more verbose and i have to specify lots of intermediate structure.
   
   the `[ ]` notation in the construct head is _so_ close to doing the ideal thing for terse conditional structure.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org