[ 
https://issues.apache.org/jira/browse/JENA-1893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17098281#comment-17098281
 ] 

Andy Seaborne commented on JENA-1893:
-------------------------------------

The two queries aren't the same - the wikidata one uses rdfs:label and the 
objects are strings. BTW strings start at character 1 in F&O so (str, 0,4) is 3 
characters long.

I don't know what taking the substring of a number helps with - it taks the 
first 3 high-end characters.  "100", "1000", "10000" all return "100". If it 
for UI display, then doing it client side and adding an indicator like "..." 
(not for 100) might be clearer.

Adding {{str}} makes it work {{(fn:substring(str(?pop) ,0,4) AS ?subpop)}}

This is not a bug - the query correctly leaves {{?subpop}} unset because there 
is an evaluation error in the expression.
 

> Variable not in scope for property function 
> --------------------------------------------
>
>                 Key: JENA-1893
>                 URL: https://issues.apache.org/jira/browse/JENA-1893
>             Project: Apache Jena
>          Issue Type: New Feature
>          Components: ARQ
>    Affects Versions: Jena 3.14.0
>         Environment: ubunutu 19.10
> java 13
>            Reporter: Marco Neumann
>            Priority: Trivial
>
> following query doesn't produce results for ?subpop
> PREFIX loticoowl: <http://www.lotico.com/ontology/>
> PREFIX fn:<http://www.w3.org/2005/xpath-functions#>
> SELECT ?pop (fn:substring(?pop ,0,4) AS ?subpop) WHERE{
>        ?x loticoowl:memberCount ?pop
> }
> http://query.lotico.com/#PREFIX%20loticoowl%3A%20%3Chttp%3A%2F%2Fwww.lotico.com%2Fontology%2F%3E%0APREFIX%20afn%3A%20%3Chttp%3A%2F%2Fjena.apache.org%2FARQ%2Ffunction%23%3E%0APREFIX%20fn%3A%3Chttp%3A%2F%2Fwww.w3.org%2F2005%2Fxpath-functions%23%3E%0A%0ASELECT%20%3Fpop%20%28fn%3Asubstring%28%3Fpop%20%2C0%2C4%29%20AS%20%3Fsubpop%29%20WHERE%7B%0A%20%20%20%20%20%20%20%3Fx%20loticoowl%3AmemberCount%20%3Fpop%0A%7D%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20
> a similar query on wikidata.org produces results as expected 
> https://query.wikidata.org/#PREFIX%20loticoowl%3A%20%3Chttp%3A%2F%2Fwww.lotico.com%2Fontology%2F%3E%0APREFIX%20afn%3A%20%3Chttp%3A%2F%2Fjena.apache.org%2FARQ%2Ffunction%23%3E%0APREFIX%20fn%3A%3Chttp%3A%2F%2Fwww.w3.org%2F2005%2Fxpath-functions%23%3E%0A%0ASELECT%20%3Fpop%20%28fn%3Asubstring%28%3Fpop%20%2C0%2C3%29%20AS%20%3Fsubpop%29%20WHERE%7B%0A%20%20%20%20%20%20%20%3Fx%20rdfs%3Alabel%20%3Fpop.%0A%20%20%20%20%20%20%20%3Fx%20wdt%3AP31%20wd%3AQ6256%0A%7D%20LIMIT%2010



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to