It seems that somewhere the function is not getting defined in the right places.  Attached is a minimal file that calls the function in a spin:rule.

<...
when you 'add existing' (and owl:Thing is higlighted) ther is only a partial set of choices...>

Where exactly is this happening?
-- Scott

Bohms, H.M. (Michel) wrote:
 
Dear Scot,

All red boxes resolved.

But when executing: no error, but when I try to look at an individual for its derived value (totalCost of say House1):
Operation Failed, Reason: Could not execute query; attempt to get a CONSTRUCT model from a slect query.



Ps
Small other issue: when you 'add existing' (and owl:Thing is higlighted) ther is only a partial set of choices on the right side; only after you select manually owl:Thing you can scroll (ie initially the scroll bar is missing..).
 
 
 
 
 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Scott Henninger
Sent: 17 March 2009 14:48
To: TopBraid Composer Users
Subject: [tbc-users] Re: own functions in spin:rules


Michel;  The red box indicates syntax errors, which are shown in the status bar at the bottom of Composer.  The first syntax error is to encapsulate the AS statement with parentheses:
   SELECT (SUM(?cost) AS ?totalCost)

The second is to use the variable name ?arg1 - i.e. the "?" is missing.

When a function is created, it exists in your ontology as a URI.
Therefore you need to use a qname or full URI to name the function,
i.e.:
  :sumFunction() or <http://myStuff.org/funct#sumFunction>()

Give that a try.
-- Scott

On Mar 17, 8:11 am, Michel Bohms <[email protected]> wrote:
  
 Replying myself after reading the manual :)

I now first defined a subclass of sp:Functions called sumFunction.
Then I defined a spin:constraint for it: Argument sp:arg1 : House

Finally I defined a body for it (delete at House...):

SELECT SUM(?cost) AS ?totalCost
WHERE {
    arg1 :hasPart_transitive ?Part .
    ?Part :cost ?cost .
    OPTIONAL {
        ?Part :hasPart_directly ?anotherPart .
    } .
    FILTER (!bound(?anotherPart)) .

}

still 2 problems:

1. the box for the body stays red
2. at House: the box for the spin:rule:

CONSTRUCT {?this :totalCost ?totalCost } WHERE { LET (?totalCost := 
sumFunction (?this)).}

is still red (despite the function is now known...).

Feel I am getting closer....thx for getting it to work!

Michel

On 17 mrt, 13:28, Michel Bohms <[email protected]> wrote:

    
Hi Holger,
      
In earlier mails we discussed the determination of totalCost (of 
some
'whole') via a helper function.
      
When I do as spin:rule:
      
CONSTRUCT {?this :totalCost ?totalCost } WHERE { LET (?totalCost := 
sumFunction (?this)).
      
}
      
it seems the box stays red although I defined:
      
a spin:body
      
SELECT SUM(?cost) AS ?totalCost
WHERE {
    ?this :hasPart_transitive ?Part .
    ?Part :cost ?cost .
    OPTIONAL {
        ?part :hasPart_directly ?anotherPart .
    } .
    FILTER (!bound(?anotherPart)) .
      
}
      
clearly I am missing the "sumFuction" definition itself but how do I 
do that ? (assuming SUM is now implemented in the latest beta).
      
(to refresh your memory: the idea was to calculate the cost of the 
whole by counting all the leaf part's cost via querying over the all 
transitive parts and then filter out the atomic leafs)
      
thx a lot, Michel
      

This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/disclaimer/email.html




  

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TopBraid Composer Users" group.
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-composer-users?hl=en
-~----------~----~----~----~------~----~------~--~---

# Saved by TopBraid on Tue Mar 17 09:40:57 CDT 2009
# baseURI: null

@prefix composite:  <http://www.topbraid.org/2007/05/composite.owl#> .
@prefix inference:  <http://www.topbraid.org/2007/06/inference.owl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix forms:   <http://www.topbraid.org/2007/01/forms.owl#> .
@prefix visual:  <http://topbraid.org/visual#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .

[]    a       inference:Configuration ;
      composite:child
              [ a       <http://spinrdf.org/spin#TopSPIN> ;
                composite:index "0"^^xsd:int
              ] .
# Saved by TopBraid on Tue Mar 17 09:40:57 CDT 2009
# baseURI: http://SupportQuestions.com/spinFuncEx
# imports: http://spinrdf.org/spinx

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

<http://SupportQuestions.com/spinFuncEx>
      a       owl:Ontology ;
      owl:imports <http://spinrdf.org/spinx> ;
      owl:versionInfo "Created with TopBraid Composer"^^xsd:string .

:House
      a       owl:Class ;
      rdfs:subClassOf owl:Thing ;
      spin:rule
              [ a       sp:Construct ;
                sp:templates ([ sp:object _:b1 ;
                            sp:predicate :totalCost ;
                            sp:subject spin:_this
                          ]) ;
                sp:where ([ a       sp:Let ;
                            sp:expression
                                    [ a       :sumFunction ;
                                      sp:arg1 spin:_this
                                    ] ;
                            sp:variable _:b1
                          ])
              ] .

:House_1
      a       :House .

:sumFunction
      a       spin:Function ;
      rdfs:subClassOf spin:Functions ;
      spin:body
              [ a       sp:Select ;
                sp:resultVariables ([ a       sp:Sum ;
                            sp:as   [ sp:varName "totalCost"^^xsd:string
                                    ] ;
                            sp:expression _:b2
                          ]) ;
                sp:where ([ sp:object _:b3 ;
                            sp:predicate :hasPart_transitive ;
                            sp:subject spin:_arg1
                          ] [ sp:object _:b2 ;
                            sp:predicate :cost ;
                            sp:subject _:b3
                          ] [ a       sp:Optional ;
                            sp:elements ([ sp:object _:b4 ;
                                        sp:predicate :hasPart_directly ;
                                        sp:subject _:b3
                                      ])
                          ] [ a       sp:Filter ;
                            sp:expression
                                    [ a       sp:not ;
                                      sp:arg1 [ a       sp:bound ;
                                                sp:arg1 _:b4
                                              ]
                                    ]
                          ])
              ] .

:totalCost
      a       rdf:Property .

_:b1  sp:varName "totalCost"^^xsd:string .

_:b4  sp:varName "anotherPart"^^xsd:string .

_:b2  sp:varName "cost"^^xsd:string .

_:b3  sp:varName "Part"^^xsd:string .

Reply via email to