Hi Andy,
My idea is replace any “&” by a internal valid variable, ensuring that this
variable does not exist in command. For instance,
…
group by ?x
having (count(1) >=&n)
\\\SPARQL).
...
will be replaced by
group by ?x
having (count(1) >=?OV_A8y7AbAA)
\\\SPARQL).
After I parse the command and I extract all variables used. If miss some
variable that I replace I assume that was done a bad replacement (in a string,
for instance) and this replacement is canceled.
> An alternative is to replace occurrence of a named variable, ?n
I start by this approach but seems very difficult and not clear what is
external variables and what is not.
It will be very useful for an answer to this question:
Which are the valid chars for a variable name? Is there any place where this is
defined?
Miguel
On 03 Sep 2014, at 11:38, Andy Seaborne <[email protected]> wrote:
> On 02/09/14 23:49, Miguel Bento Alves wrote:
>> Hi Andy,
>>
>> &n is illegal SPARQL, ok, but that does not means that can be used to
>> refer a outer variable? The symbol “&” can appear in a SPARQL command
>> (excepting in a String)?
>
> If yo udo it that way, then you must replace the &n before passing the string
> to the SPARQL parser otherwise it won't parse.
>
> An alternative is to replace occurrence of a named variable, ?n
>
> It depends on the details of "refer to an outer variable" means.
>
> If it is that the outer variable can have a number of values then it's either
> a join of the results of the query and a table of values from the rest of the
> rule matching or it's a repeated execution with different values of ?n.
>
> Straight substitution of ?n for a string value, passing to the parser and
> executing is close but can end up in different results depending on whether
> ?n is used nested inside the query, either unprojected from a subquery (it's
> a different variable) or in nested OPTIONALs (substitution can violates
> bottom-up execution semantics).
>
> It's easier to let the execution engine worry about this.
>
> You can use an initial binding for repeated execution. That avoids the
> nested different definition problems. Or add a VALUES clause to the query.
>
>>
>> and the symbol “$”?
>>
>> BTW, I almost finished the development of an engine to evaluate rules
>> that combines rules terms with sparql commands. To finish, I only
>> need to define the special char to make reference to outer variables
>> (for now, and to develop the engine, I'm using a non-valid char).
>>
>> Miguel
>>
>
> Andy