On 13/05/12 10:23, Martynas Jusevicius wrote:
Hey,

the following query
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
PREFIX sdmx-dimension:<http://purl.org/linked-data/sdmx/2009/dimension#>
PREFIX sdmx-measure:<http://purl.org/linked-data/sdmx/2009/measure#>
PREFIX qb:<http://purl.org/linked-data/cube#>
PREFIX year:<http://reference.data.gov.uk/id/year/>
PREFIX property:<http://worldbank.270a.info/property/>
PREFIX indicator:<http://worldbank.270a.info/classification/indicator/>
PREFIX country:<http://worldbank.270a.info/classification/country/>

PREFIX g-meta:<http://worldbank.270a.info/graph/meta>
PREFIX g-indicators:
<http://worldbank.270a.info/graph/world-development-indicators>

SELECT ?year (xsd:float(?gdpGrowth) AS ?gdpGrowth)
(xsd:float(?hhGrowth) AS ?hhGrowth)
WHERE {
     GRAPH g-indicators: {
         ?gdpObs property:indicator indicator:NY.GDP.MKTP.KD.ZG ;
             sdmx-dimension:refArea ?country ;
             sdmx-dimension:refPeriod ?period ;
             sdmx-measure:obsValue ?gdpGrowth .
         ?hhObs property:indicator indicator:NE.CON.PRVT.KD.ZG ;
             sdmx-dimension:refArea ?country ;
             sdmx-dimension:refPeriod ?period ;
             sdmx-measure:obsValue ?hhGrowth .
FILTER (?country = country:DK)
         BIND(SUBSTR(STR(?period), 38, 4) AS ?year)
         #FILTER (xsd:int(?year)>= 1990)
     }

     GRAPH g-meta: {
         ?country skos:prefLabel ?countryPrefLabel .
     }
}
ORDER BY DESC(?year)

looks fine and works fine in Dydra, but throws an exception in Jena
(where the SUBSTR() is):

com.hp.hpl.jena.query.QueryParseException: Encountered " "(" "( "" at
line 26, column 20.
Was expecting:
     "regex" ...

        
com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:87)
        com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse(ParserSPARQL11.java:40)
        com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:132)
        com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:69)
        com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)
        com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:28)
        org.graphity.browser.SPARQLResource.getQuery(SPARQLResource.java:87)

Is that a bug?

Works for me. It looks like you are running some old version -- the method names (and source line numbers) don't quite line up. I had to go back to 2.8.7 (2010-12-12) to find a possible version, may be older.

The query is illegal for a different reason.

"""
Variable used when already in-scope: ?gdpGrowth in (xsd:float(?gdpGrowth) AS ?gdpGrowth)
"""

You can't reassign to a variable that's already set (by the static scope rules in SPARQL). It needs to be a different name

(xsd:float(?gdpGrowth) AS ?gdpGrowthNum)

        Andy


Martynas
graphity.org

Reply via email to