Allison, probably the best way to learn magic properties is by example.  In the Composer navigator, go to TopBraid/Examples/kennedysSPINMagic.ttl and open that.

In the Classes view find spin:MagicProperties.  A Magic property is a subclass of
spin:MagicProperties.  You can see the body of the definition for age (after running inferences), grandfather, and grandMother.  These are used in SPARQL as a property that instead calls the body of the query (hence a "magic" property).

An example, let's say you want to find a grandfather:
SELECT *
WHERE
{   ?person a kennedys:Person .
    ?person kspin:grandFather ?gf
}

Note you can use this magic property either way.  So to find all grandchildren of Joe Kennedy:
SELECT *
WHERE
{    ?gchild kspin:grandFather kennedys:JosephKennedy
}

I know, I haven't answered the question yet.  For multiple parameters of values, use a list structure (see, for example top:files in Help > TopBraid Composer > Reference > SPARQL Property Functions).  As an additional example, I've added an example in the attached file to define a magic property named MagicExample:FindNamesOfCollegeGrad (kinda a silly example, buyt it gets the idea across)

You can use it this way for example:

SELECT *
WHERE
{  ?person a kennedys:Person .
   ?person kennedys:almaMater ?college .
   (?person ?college) MagicExample:FindParentsOfCollegeGrad (?first ?middle ?last)
}

You can bind/not bind any of the input parameters or output values.  For example to find all John's try this.

SELECT *
WHERE
{   ?person a kennedys:Person .
   ?person kennedys:almaMater ?college .
   (?person ?college) MagicExample:FindParentsOfCollegeGrad ("John" ?middle ?last)
}

Given that
as an interesting example to explore, let us know if that answers the question or if you have follows.

 
-- Scott

On 5/8/2013 11:51 AM, Alison Callahan wrote:
Hi Holger, 

I have looked at Magic Properties, and thought they were relevant to my question, but I couldn't find any examples of how to create a magic property that returns multiple values. On the page you linked to, it says "Magic properties can also take multiple arguments and result values using a (rather obscure) list syntax - these cases are technically supported but complex to represent in the SPIN RDF syntax". 

Could you provide more detail or a link that describes this list syntax for creating a magic property that returns multiple values?

Thanks!

Alison


On Mon, Apr 29, 2013 at 7:00 PM, Holger Knublauch <[email protected]> wrote:
Hi Allison,

yes take a look at Magic Properties

http://spinrdf.org/spin.html#spin-magic

These may not only return multiple "rows" but also multiple variables per row.

Please take a look at the online material and get back to us if you have specific follow-up questions.

HTH
Holger



On 4/30/2013 1:01, Alison Callahan wrote:
Hello all,

I would like to be able to define the body of a SPIN function that returns two variables, e.g.

SELECT ?x ?y
WHERE {
    ?example test:x ?x .
    ?example text:y ?y .
}

My question is: if such a function is possible, how are the results bound when the function is called? In my experience with SPIN I have written functions that return one variable, and thus the result is bound to a single variable when the function is called. For example, if I have a SPIN function called "functionA" where the spin:body is:

SELECT ?a
WHERE {
    ?example test:a ?a .
}

I would call this function and bind the result as

BIND(:functionA(?aVariable) AS ?returnedA) .

Is it possible to write a similar function that returns two (or more) variables?

Any help is appreciated!

Alison
--
-- 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.



--
-- 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.
 
 
# baseURI: http://support.tq.com/magicproperty/MagicExample
# imports: http://topbraid.org/examples/kennedysSPINMagic

@prefix MagicExample:  <http://support.tq.com/magicproperty/MagicExample#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sp:      <http://spinrdf.org/sp#> .
@prefix spin:    <http://spinrdf.org/spin#> .
@prefix spl:     <http://spinrdf.org/spl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .

<http://support.tq.com/magicproperty/MagicExample>
      rdf:type owl:Ontology ;
      owl:imports <http://topbraid.org/examples/kennedysSPINMagic> ;
      owl:versionInfo "Created with TopBraid Composer"^^xsd:string .

MagicExample:FindNamesOfCollegeGrad
      rdf:type spin:MagicProperty ;
      rdfs:label "Find parents of college grad"^^xsd:string ;
      rdfs:subClassOf spin:MagicProperties ;
      spin:body
              [ rdf:type sp:Select ;
                sp:resultVariables ([ sp:varName "fname"^^xsd:string
                          ] [ sp:varName "mn"^^xsd:string
                          ] [ sp:varName "lname"^^xsd:string
                          ]) ;
                sp:where ([ sp:object spin:_arg2 ;
                            sp:predicate 
<http://topbraid.org/examples/kennedys#almaMater> ;
                            sp:subject spin:_arg1
                          ] [ sp:object
                                    [ sp:varName "fname"^^xsd:string
                                    ] ;
                            sp:predicate 
<http://topbraid.org/examples/kennedys#firstName> ;
                            sp:subject spin:_arg1
                          ] [ sp:object
                                    [ sp:varName "lname"^^xsd:string
                                    ] ;
                            sp:predicate 
<http://topbraid.org/examples/kennedys#lastName> ;
                            sp:subject spin:_arg1
                          ] [ rdf:type sp:Optional ;
                            sp:elements ([ sp:object
                                                [ sp:varName "mn"^^xsd:string
                                                ] ;
                                        sp:predicate 
<http://topbraid.org/examples/kennedys#middleName> ;
                                        sp:subject spin:_arg1
                                      ])
                          ])
              ] ;
      spin:constraint
              [ rdf:type spl:Argument ;
                rdfs:comment "URI of the person."^^xsd:string ;
                spl:predicate sp:arg1 ;
                spl:valueType <http://topbraid.org/examples/kennedys#Person>
              ] ;
      spin:constraint
              [ rdf:type spl:Argument ;
                rdfs:comment "URI of the college."^^xsd:string ;
                spl:predicate sp:arg2 ;
                spl:valueType <http://topbraid.org/examples/kennedys#College>
              ] .

Reply via email to