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 and the user selects a node.
A popup appears asking for the name of the new node.
The node is added as a child of the selected node (it's rdfs:label and
skos:prefLabel contain what was entered into the popup).

The above is working fine, but now I need to add functionality to
parse out the pub name from the selected node's URI.
Here's a sample URI ... 
http://www.owl-ontologies.com/TestPub_Hierarchy1#Documentr-1-1
- TestPub is what I need to grab.

My SPARQLMotion script captures the sml:selectedResource and issues a
select query via a "Bind by select" module.
Here's the query ... it calls out to a custom spin function
(getHierarchy) ...
SELECT ?customFunctionName WHERE {LET (?namespace := afn:namespace(?
selectedResource)) .LET (?customFunctionName := :getHierarchy(?
namespace)) .}

The getHierarchy function expects 1 argument (spin:Constraint Argument
sp:arg1 : xsd:string) which I thought was the ?namespace of the ?
selectedResource in the above.

OK, now we're inside my :getHierarchy(?namespace) spin function.
The spin:body contains the following query:
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 contains "NewNode" not
"TestPubNewNode".

Side Note:  This successfully runs in debug mode ...
                  When prompted "Please enter value for the selected
resource", I enter 
http://www.owl-ontologies.com/TestPub_Hierarchy1#Documentr-1-1.
                  Next I'm prompted for arg1 (node name) which I
enter ... TestPub is successfully "extracted" from the URI string.

Not sure what I'm missing ... hope the above is clear.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to