John;  In terms of passing a string argument, the best way to do this is to use one of the wizards to set the type in the spl:Argument's to be what you want it to be in the end.  If that's a string, then use xsd:string.  If it's a URI, then set to rdf:Property, owl:Ontology, owl:Class, myns:Thing_1, etc and it will be cast the value, if it is a properly formatted URI.

In that respect, make sure you use the Scripts > Create SPARQLMotion function/web service...  This wizard does three things:
  1) creates a new script
  2) names the script so it can be called as a Web service
  3) creates the arguments using the spl:Argument template wizard

In terms of the Web service call, everything starts out as a string.  And you do have to be careful about getting the proper HTTP encoding.  The exceptions you sent indicate that perhaps the URI that was passed was not well-formatted.  One hint is that most entities (browsers, etc.) will take slashes but not hashes, so use %23 for '#'.

Finally, I attached a script that has an example of passing a value that is cast to a property and used to query our favorite kennedys model.  Test it with the URL:
  http://localhost:8083/tbl/sparqlmotion?id=http://support.tq.com/exampleServicePassArgument%23GetKennedyPropValues&property=http://topbraid.org/examples/kennedys%23name

Hopefully that can give you solid ground to start from.


-- Scott

On 3/11/2013 7:31 PM, John Perdoni wrote:
Scott

I am now getting the following error, I shall delete the script and start again, I agree with you that nothing is wrong on the surface, but any advice on how you set the value type of an sp:arg when passing in a string via http would be helpfull, I have a nagging feeling this is the root of the problem.

java.lang.reflect.InvocationTargetException
    at org.topbraidcomposer.sparqlmotion.actions.AbstractExecuteSPARQLMotionAction$1.run(AbstractExecuteSPARQLMotionAction.java:148)
    at org.topbraidcomposer.core.util.ThreadUtil$1$1.run(ThreadUtil.java:64)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException
    at java.net.URI.create(Unknown Source)
    at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.merge(ExecutionEngineImpl.java:256)
    at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.executeModule(ExecutionEngineImpl.java:149)
    at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.execute(ExecutionEngineImpl.java:120)
    at org.topbraidcomposer.sparqlmotion.views.console.SPARQLMotionConsole.execute(SPARQLMotionConsole.java:79)
    at org.topbraidcomposer.sparqlmotion.actions.AbstractExecuteSPARQLMotionAction$1.run(AbstractExecuteSPARQLMotionAction.java:137)
    ... 2 more
Caused by: java.net.URISyntaxException: Expected scheme-specific part at index 14: publishedBook:
    at java.net.URI$Parser.fail(Unknown Source)
    at java.net.URI$Parser.failExpecting(Unknown Source)
    at java.net.URI$Parser.parse(Unknown Source)
    at java.net.URI.<init>(Unknown Source)
    ... 8 more
Root exception:
java.lang.IllegalArgumentException
    at java.net.URI.create(Unknown Source)
    at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.merge(ExecutionEngineImpl.java:256)
    at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.executeModule(ExecutionEngineImpl.java:149)
    at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.execute(ExecutionEngineImpl.java:120)
    at org.topbraidcomposer.sparqlmotion.views.console.SPARQLMotionConsole.execute(SPARQLMotionConsole.java:79)
    at org.topbraidcomposer.sparqlmotion.actions.AbstractExecuteSPARQLMotionAction$1.run(AbstractExecuteSPARQLMotionAction.java:137)
    at org.topbraidcomposer.core.util.ThreadUtil$1$1.run(ThreadUtil.java:64)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.net.URISyntaxException: Expected scheme-specific part at index 14: publishedBook:
    at java.net.URI$Parser.fail(Unknown Source)
    at java.net.URI$Parser.failExpecting(Unknown Source)
    at java.net.URI$Parser.parse(Unknown Source)
    at java.net.URI.<init>(Unknown Source)
    ... 8 more


On Monday, 11 March 2013 21:40:25 UTC, John Perdoni wrote:
Hi yet again

I apologise if I am wasting your time if this turns out to be lack of knowledge ie a sparql problem.

If via the sparql view in TBC I use the following the Delete works fine

DELETE {
    GRAPH <http://example.com/library/publishedBook> {
        ?currentBookUri ?rdfPropertyToUpdateUri ?o .
    } .
}
WHERE {
    GRAPH <http://example.com/library/publishedBook> {
        BIND (spif:buildURI("<http:/example.com/library/publishedBook#IEE_Code_of_Practice_3rd_Edition>") AS ?currentBookUri) .
        BIND (spif:buildURI("<http://example.com/library/coreModel#lhRhPageLayoutMirrored>") AS ?rdfPropertyToUpdateUri) .
        ?currentBookUri ?rdfPropertyToUpdateUri ?o .
 } .
}

However if I use the following in a performUpdate module of a sm script it does not but no error  or warning is apparent

DELETE {
    GRAPH <http://example.com/library/publishedBook> {
        ?currentBookUri ?rdfPropertyToUpdateUri ?o .
    } .
}
WHERE {
    GRAPH <http://example.com/library/publishedBook> {
        BIND (spif:buildURI("<{?currentBook}>") AS ?currentBookUri) .
        BIND (spif:buildURI("<{?rdfPropertyToUpdate}>") AS ?rdfPropertyToUpdateUri) .
       ?currentBookUri ?rdfPropertyToUpdateUri ?o
    } .
}

I have tried debugging and here is the screenshot of the input var

--
-- 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/exampleServicePassArgument
# imports: http://topbraid.org/sparqlmotionfunctions
# imports: http://topbraid.org/sparqlmotionlib-tbc

@prefix ex:      <http://support.tq.com/exampleServicePassArgument#> .
@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 sm:      <http://topbraid.org/sparqlmotion#> .
@prefix sml:     <http://topbraid.org/sparqlmotionlib#> .
@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/exampleServicePassArgument>
      rdf:type owl:Ontology ;
      owl:imports <http://topbraid.org/sparqlmotionlib-tbc> , 
<http://topbraid.org/sparqlmotionfunctions> ;
      owl:versionInfo "Created with TopBraid Composer"^^xsd:string .

ex:GetKennedyPropValues
      rdf:type sm:Function ;
      rdfs:comment "An example script that queries the kennedys model for all 
property values for a property passed in as an argument.

To test, call with

http://localhost:8083/tbl/sparqlmotion?id=http://support.tq.com/exampleServicePassArgument%23GetKennedyPropValues&property=http://topbraid.org/examples/kennedys%23name"^^xsd:string
 ;
      rdfs:subClassOf sm:Functions ;
      spin:constraint
              [ rdf:type spl:Argument ;
                rdfs:comment "The property that will be queried - i.e. {?s 
?property ?o}.  Must be a URI."^^xsd:string ;
                spl:predicate <http://spinrdf.org/arg#property> ;
                spl:valueType rdf:Property ;
                sm:next 
<http://support.tq.com/exampleServicePassArgument#Import-kennedys.ttl_1> ;
                sm:nodeX 45 ;
                sm:nodeY 23
              ] ;
      sm:returnModule ex:GetKennedyPropValues_Return .

ex:GetKennedyPropValues_Return
      rdf:type sml:ReturnSPARQLResults ;
      sm:nodeX 54 ;
      sm:nodeY 246 ;
      sml:selectQuery
              [ rdf:type sp:Select ;
                sp:where ([ sp:object
                                    [ sp:varName "o"^^xsd:string
                                    ] ;
                            sp:predicate
                                    [ sp:varName "property"^^xsd:string
                                    ] ;
                            sp:subject
                                    [ sp:varName "s"^^xsd:string
                                    ]
                          ])
              ] ;
      sml:serialization sm:JSON .

<http://support.tq.com/exampleServicePassArgument#Import-kennedys.ttl_1>
      rdf:type sml:ImportRDFFromWorkspace ;
      rdfs:label "Import kennedys.ttl"^^xsd:string ;
      sm:next ex:GetKennedyPropValues_Return ;
      sm:nodeX 92 ;
      sm:nodeY 144 ;
      sml:baseURI "http://topbraid.org/examples/kennedys"^^xsd:string .

Reply via email to