Hi Martynas,

this is indeed not working correctly (in the current SPIN API release 1.3.0). The role of this method is to return a parsable query string with the given variables of the template call pre-bound. The problem is that the current code is expecting to apply variable substitutions while printing the query string from the RDF tree. However, if no RDF tree exists, it simply returns the sp:text unchanged.

I believe I can provide a partial fix, but thinking more about this method I am wondering whether it should be deprecated altogether or at least have some severe warnings around it. Background: SPIN constraints and inferencing algorithms do not use this mechanism (of hard-wiring the variables in the query string) because it is comparably slow (to create the new strings each time - they are hard to cache) and because there are cases where the approach doesn't work in general. Consider you have a bound(?x) statement in the WHERE clause, but then ?x is pre-bound: it would create a non-parsable string. The approach that SPIN API uses in most other places is to keep the query strings (or Query objects) and the initial bindings in separate structures, and then let the Jena engine do the substitution at run-time - not only the query String but on the Query and algebra objects.

So before we can make a decision on the future of this TemplateCall.getQueryString method: could you clarify what your use case is and whether you could also soft-bind the substitutions? If you could refactor your surrounding code then I could probably just deprecate this method for good.

Thanks
Holger


On 3/17/2013 5:56, [email protected] wrote:
Hey Holger,

I have a spin:Template with an argument (in gp: namespace):

:DescribeInstancesTemplate a spin:Template ;
    spin:constraint [ a       spl:Argument ;
        spl:predicate :type ;
        spl:valueType rdfs:Resource
    ] ;
    spin:body [ a       sp:Describe, sp:Query ;
      sp:resultNodes (_:instanceVar) ;
      sp:text """DESCRIBE ?instance WHERE {
    {
        SELECT ?instance
        WHERE {
            ?instance a ?type .
        }
    } .
}"""^^xsd:string ;
      sp:where ([ a       sp:SubQuery ;
# full RDF representation follows here

_:instanceVar  sp:varName "instance"^^xsd:string .

When called it like this

    spin:constraint [ a gp:DescribeInstancesTemplate ;
        gp:type owl:Ontology
    ] ;

I get the query I want (using the TemplateCall.getQueryString() method):

DESCRIBE ?instance
WHERE
  { { SELECT  ?instance
      WHERE
{ ?instance <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Ontology> }
    }
  }

However, if I change the template's query to use spin:text only:

:DescribeInstancesTemplate a spin:Template ;
    spin:constraint [ a       spl:Argument ;
        spl:predicate :type ;
        spl:valueType rdfs:Resource
    ] ;
    spin:body [ a       sp:Describe, sp:Query ;
      sp:text """DESCRIBE ?instance WHERE {
    {
        SELECT ?instance
        WHERE {
            ?instance a ?type .
        }
    } .
}"""^^xsd:string ] .

the ?type argument is not set:

DESCRIBE ?instance
WHERE
  { { SELECT  ?instance
      WHERE
{ ?instance <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type }
    }
  }

Is that the expected behaviour or am I missing something? spin:text syntax is a really nice simplification, but I would expect Template and TemplateCall to work the same way.

Martynas
graphity.org
--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), TopBraid Composer, TopBraid Live,
TopBraid Ensemble, SPARQLMotion, SPARQL Web Pages 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
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.



--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary 
Network (EVN), TopBraid Composer, TopBraid Live,
TopBraid Ensemble, SPARQLMotion, SPARQL Web Pages 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
--- You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to