Rupert,

 

Assuming, you are using spinmapl:buildURI2 function, query that corresponds to 
the function is

 

SELECT ((IRI(?uri)) AS ?result)

WHERE {

    BIND (spl:object(?source, ?arg1) AS ?value1) .

    BIND (spl:object(?source, ?arg2) AS ?value2) .

    BIND (spif:buildURI(?template, ?value1, ?value2) AS ?uri) .

}

 

You can see it in the mapping dialog.

 

If you don’t like the behavior of any of the pre-built functions, you can 
create your own mapping functions, for example my:buildURI2. Simply create a 
clone of spinmapl:buildURI2, give it a different name and then replace the 
query with:

 

SELECT ((IRI(?uri)) AS ?result)

WHERE {

    BIND (spl:object(?source, ?arg1) AS ?value1) .

    BIND (spl:object(?source, ?arg2) AS ?value2) .

    BIND (COALESCE(?value2, "") AS ?value3)

    BIND (spif:buildURI(?template, ?value1, ?value3) AS ?uri) .

}

 

What I would do, to get the query for your new function right, is experiment 
with it in the SPARQL view. Put the original query in the SPARQL view, then 
make a few changes so you can test it:

 

SELECT ((IRI(?uri)) AS ?result)

WHERE { ?source a my:SomeClass.

    BIND (spl:object(?source, my:property1) AS ?value1) .

    BIND (spl:object(?source, my:property2) AS ?value2) .

    BIND (spif:buildURI(?template, ?value1, ?value2) AS ?uri) .

}

 

Where my:SomeClass, my:property1 and my:property2 are some specific class and 
properties from your model.

 

Now, you can run the query. Make changes to it until you are satisfied with the 
result. Once you have what you need, remove {?source a my:SomeClass} triple and 
turn my:property1 and my:property2 back into arguments to use the query in your 
new function.

 

Irene

From: [email protected] [mailto:[email protected]] 
On Behalf Of Rupert Smith
Sent: Wednesday, October 01, 2014 12:44 PM
To: [email protected]
Subject: [topbraid-users] Spinmap: constructing URIs with optional components

 

Hi All,

 

I've just starting using Spinmap do import some test data, and I've run into a 
problem. I want the URI of the instances I'll be creating to be of the form:

 

http://example.org/{?1}-{?2} <http://example.org/%7b?1%7d-%7b?2%7d> 

 

With the caveat that ?2 is optional. Currently the URI is created properly when 
?2 is present, but if not nothing is created.

 

I have tried using the expression editor, but it's not clear to me how what you 
type in the box corresponds to an actual Sparql query in terms of binding my 
own variables, using OPTIONAL, BOUND, and IF. In any case I'm not having much 
luck.

 

Any insight much appreciated

-- 
-- 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 Insight, 
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/d/optout.

-- 
-- 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 Insight, 
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/d/optout.

Reply via email to