I have a SPARQLMotion script/web service which takes user input and adds a new node to a hierarchy tree. The tree is presented in the left pane -- the user selects a node. A popup appears requesting the name of the new node. The node is added as a child of the selected node (its rdfs:label and skos:prefLabel contain the text entered into the popup).
The above is working, but now I need to grab the pub name from the selected node's URI. Sample URI ... http://www.ontology-testing.com/TestPub_Hierarchy1#Documentr-1-1 .... need to grab “TestPub”. My SPARQLMotion script starts by capturing the sml:selectedResource (SelectedResource sml:selectedResource module) That's followed by a "Bind by select" module with the below query (which calls out to the custom spin function :getHierarchy) SELECT ?customFunctionName WHERE {LET (?namespace := afn:namespace(? selectedResource)) .LET (?customFunctionName := :getHierarchy(? namespace)) .} The getHierarchy function takes 1 argument (spin:Constraint Argument sp:arg1 xsd:string) -- I'm passing in the ?namespace of the ? selectedResource (at least I thought I was) The spin:body of the :getHierarchy function contains: SELECT ?customFunctionName WHERE { LET (?namespace := smf:buildString("{?arg1}")) . LET (?startPos := smf:lastIndexOf(?namespace, "/")) . LET (?endPos := smf:indexOf(?namespace, "_")) . LET (?hierarchyName := afn:substr(?namespace, (?startPos + 1), ? endPos)) . LET (?customFunctionName := smf:buildString("{?hierarchyName} NewNode")) . } ?customFunctionName is returned but only contains "NewNode" not "TestPubNewNode". Side Note: This successfully runs in debug mode ... I’m first prompted to "Please enter value for the selected resource" -- I enter http://www.ontology-testing.com/TestPub_Hierarchy1#Documentr-1-1. Next prompted for arg1 (node name) which I enter. The script executes and I can see via the SPARQLMotionResults and Console windows that "TestPub" was successfully extracted --- "TestPubNewNode". Not sure what's wrong. I appreciate your help. Barb On Jul 16, 11:40 pm, Holger Knublauch <[email protected]> wrote: > In which context? The Java API, SPARQL, SPARQLMotion? > > SPARQLMotion has a mechanism to get the current selected resource, > using sml:SelectedResourceArgument, if you mean that. Outside of > SPARQLMotion, there is no SPARQL function for that, but the variable ? > this is bound to the currently selected resource in the SPARQL view. > > Please clarify. > > Holger > > On Jul 16, 2009, at 8:34 PM, Barb wrote: > > > > > > > How can I get the URI for a selected resource? > > > Barb- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
