|
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:
-- -- 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> ] .
