Mia; To add parameters to a SPARQLMotion script, follow these steps:
1. Create a SPARQL function by creating a subclass of spin:Function.
The name of the class is the name of a function you can use as Web
services, SPARQL queries, SPARQLMotion modules, etc.
2. For the spin:constraint property, choose "Create from SPIN
Template" (the menu triangle next to the property name in the form).
Choose the Argument template and fill in a property name. You can use
any existing property, including ones you have named :a and :b. Add a
spin:constraint for each argument you want to create.
3. Using the sm:returnModule property, link your function to a
SPARQLMotion script by choosing "Add existing..." and choose the
terminal module of your SPARQLMotion script.
4. Edit the script and a module will appear for each argument you
created. Link them with a sm:next property to your script and they
will be available as a variable with the same localname. For example
if you use sp:arg1, then the value will be bound to ?arg1 in the
script, myns:a will be bound to ?a, :b is bound to ?b, etc.
In terms of the for loop example you provided, SPARQL doesn't use
loops per se, and there isn't a full analog in SPARQL or
SPARQLMotion. However you can use expressions to control what gets
returned in a result set. For example, if you have a property in the
model, let's call it myns:value, then your query can do something like
the following (assuming ?a and ?b are bound to values):
SELECT *
WHERE
{ ?s myns:value ?o .
FILTER (?o >= ?a && ?o <= ?b)
} ORDER BY ASC(?o)
ORDER BY will place the results in alpahnumeric order over values of
the property ?o. Also, if the intent is to get pieces of the result
set, you can use OFFSET and LIMIT to control which and how many
matches you get in the result set.
-- Scott
On Aug 10, 9:00 am, Mia <[email protected]> wrote:
> I'm trying to create a SPARQLMotion script to get some data from
> geoname.
>
> http://sws.geonames.org/{?id}/
>
> Is there any way to create 2 input arguments (a and b) and let the
> SPARQL script iterate through the range?
>
> for(int id=a;id<b;id++)
> gethttp://sws.geonames.org/[id]/
>
> Thanks,
--
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