On Thursday 16 September 2010 02:13:21 Holger Knublauch wrote: > Hi Olaf, > > many thanks for this detailed bug report. You are 100% right, and I have > added the following line to the clone method > > cl.initialBindings = initialBindings; > > I believe you have the latest source code so that you can (for now) add > this line yourself, but I am overdue to package all this into a proper > next release of the API. Now that we are getting closer to the 3.4 release > of our general platform, doing a SPIN API release makes a lot of sense.
Sounds good. Thanks! Olaf > Thanks and sorry for the inconvenience, > Holger > > On Sep 16, 2010, at 7:25 AM, Olaf Hartig wrote: > > Hello, > > > > The method 'clone' of class 'StringPrintContext' in the SPIN API does not > > copy the 'initialBindings' member. This causes problems when a query > > template contains placeholders in a FILTER expression. A more detailed > > description follows: > > > > Let's say I have a query template that contains a FILTER expression: > > > > ... > > FILTER (?dep >= ?earliestDep } > > ... > > > > for which the corresponding SPIN description (in Turtle / N3 notation) is > > something like: > > > > ex:myTemplate > > > > rdf:type spin:Template ; > > spin:body [ > > > > # ... > > sp:where ( > > > > # ... > > [ rdf:type sp:Filter ; > > > > sp:expression [ rdf:type sp:ge ; > > > > sp:arg1 _:dep ; > > sp:arg2 _:earliestDep ] ] > > > > # ... > > ) > > > > ] . > > > > _:earliestDep sp:varName "earliestDep"^^xsd:string . > > > > Let's say the variable ?earliestDep is a placeholder. Hence, my template > > definition contains something like: > > > > ex:myTemplate spin:constraint [ > > > > rdf:type spl:Argument ; > > spl:predicate ex:earliestDep ; > > spl:valueType xsd:double ] . > > > > Now I instantiate this template. A SPIN description for this > > instantiation could be: > > > > _:myTemplateInstance > > > > rdf:type ex:myTemplate ; > > ex:earliestDep 4.5 . > > > > For this instantiation I expect the resulting SPARQL query to contain > > this FILTER expression: > > > > ... > > FILTER (?dep >= 4.5 } > > ... > > > > But this does not happen. The placeholder is not replaced by the literal > > 4.5 as I would expect. I tracked this problem down: The SPIN API > > initializes a 'StringPrintContext' with the an initial binding that > > correctly maps the earliestDep placeholder to the literal. Then, it > > prints the body of the template to this 'StringPrintContext'. Several > > print methods are being called (recursively) and until -at a certain > > point- the expression in the FILTER clause has to be printed and the > > method 'printExpressionString' in class 'SPINExpressions' is called. > > Here, the Resource that represents the expression is casted to a > > 'FunctionCall', the current print context is cloned, and the > > 'FunctionCall' is printed to the _cloned_ print context. Since the > > 'clone' method of the 'StringPrintContext' does not copy the > > 'initialBindings', none of the arguments of the 'FunctionCall' can be > > subsituted using the initial bindings. > > > > For this reason I propose to copy the 'initialBindings' when a clone of > > 'StringPrintContext' is created. > > > > Greetings, > > Olaf > > > > ---------------------- > > Olaf Hartig (http://olafhartig.de) > > > > Database and Information Systems Research Group > > Department of Computer Science > > Humboldt-Universität zu Berlin -- You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include TopBraid Composer, TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/topbraid-users?hl=en
