|
Phil; There
are a couple of things preventing you from creating the union of all
domains. First, your ApplyConstruct is getting all domain matches,
which explains the duplicate results. Second, the Union syntax is a
bit more complex, in that an rdf:list is needed to represent the union. So attached is a solution that will do what you want. Dean and worked on this a bit this afternoon and agree that some parts are not as pretty as we'd like, but it does the job. It works by constructing a text list using ConcatenateText that is then converted to an rdf:list. This will make sure that the union is created for all domains defined for a property. I put some properties, testDomain1, testDomain2, testDomain3 in the file, so you can test the script. Of course, you'll need to run a FilterByConstruct, or manipulate however you plan to create triples, to remove the existing domain definitions. -- Scott On 5/14/10 8:45 AM, [email protected] wrote: -- 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 |
# Saved by TopBraid on Fri May 14 15:49:41 CDT 2010 # baseURI: http://todel.org/unnamed1 # imports: http://topbraid.org/sparqlmotionlib # imports: http://rdfs.org/sioc/ns @prefix : <http://todel.org/unnamed1#> . @prefix afn: <http://jena.hpl.hp.com/ARQ/function#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @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 sioc: <http://rdfs.org/sioc/ns#> . @prefix sm: <http://topbraid.org/sparqlmotion#> . @prefix smf: <http://topbraid.org/sparqlmotionfunctions#> . @prefix sml: <http://topbraid.org/sparqlmotionlib#> . @prefix sp: <http://spinrdf.org/sp#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . sioc:Item_1 rdf:type sioc:Item ; rdfs:label "Item_1"^^xsd:string . sioc:Item_2 rdf:type sioc:Item ; rdfs:label "Item_2"^^xsd:string ; sioc:follows sioc:Item_1 ; owl:differentFrom sioc:Item_1 . sioc:f rdf:type sioc:Item ; rdfs:label "f"^^xsd:string . sioc:forum1 rdf:type sioc:Usergroup ; rdfs:label "forum1"^^xsd:string . sioc:forum2 rdf:type sioc:Usergroup ; rdfs:label "forum2"^^xsd:string . sioc:forum3 rdf:type sioc:Usergroup ; rdfs:label "forum3"^^xsd:string . <http://todel.org/unnamed1> rdf:type owl:Ontology ; owl:imports <http://rdfs.org/sioc/ns> , <http://topbraid.org/sparqlmotionlib> ; owl:versionInfo "Created with TopBraid Composer"^^xsd:string . :ApplyConstruct_1 rdf:type sml:ApplyConstruct ; rdfs:label "Apply construct_1"^^xsd:string ; sm:nodeX 373 ; sm:nodeY 577 ; sml:constructQuery [ rdf:type sp:Construct ; sp:templates ([ sp:object _:b1 ; sp:predicate rdfs:domain ; sp:subject [ sp:varName "prop"^^xsd:string ] ] [ sp:object owl:Class ; sp:predicate rdf:type ; sp:subject _:b1 ] [ sp:object [ sp:varName "domainList"^^xsd:string ] ; sp:predicate owl:unionOf ; sp:subject _:b1 ]) ; sp:where () ] . :ConcatenateText_1 rdf:type sml:ConcatenateText ; rdfs:label "Concatenate text_1"^^xsd:string ; sm:next :ConvertTextToRDFList_1 ; sm:nodeX 582 ; sm:nodeY 319 ; sm:outputVariable "text"^^xsd:string ; sml:selectQuery [ rdf:type sp:Select ; sp:resultVariables (_:b2) ; sp:where ([ sp:object _:b3 ; sp:predicate rdfs:domain ; sp:subject [ sp:varName "prop"^^xsd:string ] ] [ rdf:type sp:Let ; sp:expression [ rdf:type afn:namespace ; sp:arg1 _:b3 ] ; sp:variable [ sp:varName "ns"^^xsd:string ] ] [ rdf:type sp:Let ; sp:expression [ rdf:type afn:localname ; sp:arg1 _:b3 ] ; sp:variable [ sp:varName "name"^^xsd:string ] ] [ rdf:type sp:Let ; sp:expression [ rdf:type smf:buildString ; sp:arg1 "{?ns}{?name}" ] ; sp:variable _:b2 ]) ] ; sml:separator ","^^xsd:string . :ConvertTextToRDFList_1 rdf:type sml:ConvertTextToRDFList ; rdfs:label "Convert text to RDFList_1"^^xsd:string ; sm:next :ApplyConstruct_1 ; sm:nodeX 342 ; sm:nodeY 312 ; sm:outputVariable "domainList"^^xsd:string . :ImportCurrentRDF_1 rdf:type sml:ImportCurrentRDF ; rdfs:label "Import current RDF_1"^^xsd:string ; sm:next :IterateOverSelect_1 ; sm:nodeX 616 ; sm:nodeY 15 . :IterateOverSelect_1 rdf:type sml:IterateOverSelect ; rdfs:label "Iterate over select_1"^^xsd:string ; sm:body :ConcatenateText_1 ; sm:nodeX 434 ; sm:nodeY 161 ; sml:selectQuery [ rdf:type sp:Select ; sp:resultVariables (_:b4) ; sp:where ([ sp:object owl:DatatypeProperty ; sp:predicate rdf:type ; sp:subject _:b4 ] [ rdf:type sp:Let ; sp:expression [ rdf:type smf:countResults ; sp:arg1 "SELECT ?domain WHERE { ?prop rdfs:domain ?domain.}" ] ; sp:variable _:b5 ] [ rdf:type sp:Filter ; sp:expression [ rdf:type sp:gt ; sp:arg1 _:b5 ; sp:arg2 1 ] ]) ] . :testDomain1 rdf:type owl:DatatypeProperty ; rdfs:domain sioc:Item ; rdfs:label "test domain1"^^xsd:string . :testDomain2 rdf:type owl:DatatypeProperty ; rdfs:domain sioc:Role , sioc:Item ; rdfs:label "test domain 2"^^xsd:string . :testDomain3 rdf:type owl:DatatypeProperty ; rdfs:domain foaf:Document , foaf:Agent , sioc:Container ; rdfs:label "test domain 3"^^xsd:string ; owl:unionOf [ rdf:rest [ rdf:rest () ] ] ; owl:unionOf [ rdf:rest [ rdf:rest () ] ] . foaf:person1 rdf:type foaf:Agent ; rdfs:label "person1"^^xsd:string ; sioc:follows sioc:forum1 , sioc:forum2 . foaf:person2 rdf:type foaf:Agent ; rdfs:label "person2"^^xsd:string ; sioc:follows sioc:forum2 , sioc:forum3 . foaf:person3 rdf:type foaf:Agent ; rdfs:label "person3"^^xsd:string ; sioc:follows sioc:forum1 , sioc:forum3 ; :testDomain3 sioc:Forum . _:b5 sp:varName "count"^^xsd:string . _:b4 sp:varName "prop"^^xsd:string . _:b3 sp:varName "domain"^^xsd:string . _:b2 sp:varName "domainStr"^^xsd:string .
