Re: [topbraid-users] does anyone have a good example of the SWP ui:functionCall for a js function that maintains a value

2015-03-15 Thread Holger Knublauch

Hi Jack,

what you are looking for is some kind of global variable mechanism. The 
SWP variable scoping mechanism doesn't have this built-in, and I have 
not run into a use case for them yet, but I can see that this should be 
easier. So I have added a couple of helper modules in the attached file:


- SWP element 
- SPIN function var:globalVarName(name)

As shown in the following example




}





These elements are internally using a dedicated ui:tempGraph. Just 
import the file and you should be able to make progress.


I hope this helps and I will turn those two modules into a standard 
feature in the ui: namespace from TopBraid 5.0 onwards.


Thanks for your patience
Holger


On 3/16/2015 4:25, Jack Hodges wrote:
I found an example in the SWP manual that made me think about what 
ui:tempGraph is doing. It seemed to me that I could just create a node 
in the current graph and set/get values from it using ui:update and 
spl:object without using tempGraph (not that I had gotten it to work 
anyway). So I augmented my SWP ui:prototype as follows (the associated 
SPARQL query is working fine and so was this fragment at least in that 
it was building results). The eddl:tempPosition subject is an instance 
with a property eddl:boxPosition (a float). The SPIN functions work.





{= ui:newline() 
}\tiny\begin{figure}[htb]


  {= ui:newline() }\begin{tikzpicture}[every 
node/.style={auto,font=\scriptsize,text width=4cm,inner sep=5pt}]


  {= ui:newline() }\draw (0,6) node(0) [draw] {{= 
eddl:replaceUnderscoreCharacter(?cname) }};


  {= ui:newline() }{= spin:nl() } \\


  {= ui:newline() }\draw (12,{= *spl:object(eddl:tempPosition, 
eddl:boxPosition)* })node({= ?index + 1 }) [draw] {{= 
eddl:bcRangeString(?range) }};


  {= ui:newline() }\draw[->] (0.south) |-  node [near end] {\tiny 
${= eddl:replaceUnderscoreCharacter(?alabel) }$}   ({= ?index + 1 }.west);


  {= ui:newline() }*

*  BIND ({= eddl:bcydist(?range)} AS ?rnum) . *

*  }*

*  }" />*

  {= ui:newline() }{= ui:newline() }\end{tikzpicture}

  {= ui:newline() }\caption{{= 
eddl:replaceUnderscoreCharacter(?caption) }}


  {= ui:newline() }\label{{= ?label }}

  {= ui:newline() }\end{figure}




SWP is complaining about the INSERT, but the example I found in the 
manual (section 5.6) suggests that I should not be getting an error 
(albeit, in the example, the surrounding code is different 
(ui:precondition)).



As before, the idea here is to iterate through a list and calculate 
the y position of a box based on the content of the box and the y 
position of the previous box.



Jack


On Friday, March 13, 2015 at 3:31:12 PM UTC-7, Jack Hodges wrote:

I tried several things, including embedding the INSERT into an SWP
function (setLocalVariable) and the SELECT into a normal SPIN
function (getLocalVariable). But they didn't work. I also tried it
with the spl:objectInGraph followed with a call to my SWP function
but that didn't work.

Then I thought "what if I could do something like a 'let:curry-={=
0.4 - eddl:bcydist(?range) }' " That is a substraction assignment
operator. This doesn't produce any errors but it also doesn't do
anything. It would be great if the local assignment would support
more assignment operators than just simple assignment.

Is it safe to assume that the scope of let is the ui:group it is
defined in?

Once again, stuck. The simplest of all possible functionalities:


  perform a calculation on a variable in ?entries based on a
simple calculation (do determine a relative position)
  do something graphical with that value like draw a bubble at a
location
  persist that location for the next iteration


Surely someone has tried using SWP to draw graphical entities
where relative (and exact) positioning is needed...

On Friday, March 13, 2015 at 11:53:58 AM UTC-7, Jack Hodges wrote:

Is these (both the INSERT and the SELECT something that would
be embedded inside my SWP forEach? Even if it is its going to
be messy and ugly. Can I take the ui:update block and the
other code and put them into SPIN functions or magic
properties to unclutter the SWP? So far it isn't working...

Its just sad that there isn't a clean (this is hardly what I'd
call clean) mechanism to persist a variable value in the same
context you mentioned for ui:tempGraph. That is, within the
scope of the SWP construction.

Jack

On Thursday, March 12, 2015 at 4:16:22 PM UTC-7, Holger
Knublauch wrote:

I don't think SPINX would be helping you, even with a
stand-alone file - each invocation of such a SPIN function
would get its own JavaScript engine, and all intermediate
values will be lost.

Your computation below looks like easily done in

Re: [topbraid-users] [SPIN API] Base URI of sp:text query

2015-03-15 Thread Holger Knublauch

Hi Martynas,

since the "base URI" of an RDF document is not represented in RDF 
triples, the ARQ2SPIN parser cannot consistently rely on them. It would 
need to intercept loading, or post-process the resulting RDF triples to 
expand relative URIs.


So, the short answer is "no". To produce short URIs, you should rely on 
namespace prefixes instead.


Regards,
Holger


On 3/13/2015 21:27, Martynas Jusevicius wrote:

Hey all,

I have a query string in sp:text that includes relative URIs, for example:

  <> ?p ?o

When I parse the query resource with ARQ2SPIN, what comes out instead is:

 
?p ?o


Is there a way to control the base URI against which the relative ones 
are resolved?


Thanks,

Martynas
--
You received this message because you are subscribed to the Google 
Group "TopBraid Suite Users", the topics of which include Enterprise 
Vocabulary Network (EVN), Reference Data Manager (RDM), TopBraid 
Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL Web 
Pages and SPIN.

To post to this group, send email to topbraid-users@googlegroups.com
---
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 topbraid-users+unsubscr...@googlegroups.com 
.

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), 
Reference Data Manager (RDM), TopBraid Composer, TopBraid Live, TopBraid Insight, 
SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
--- 
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 topbraid-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [topbraid-users] does anyone have a good example of the SWP ui:functionCall for a js function that maintains a value

2015-03-15 Thread Jack Hodges
I found an example in the SWP manual that made me think about what 
ui:tempGraph is doing. It seemed to me that I could just create a node in 
the current graph and set/get values from it using ui:update and spl:object 
without using tempGraph (not that I had gotten it to work anyway). So I 
augmented my SWP ui:prototype as follows (the associated SPARQL query is 
working fine and so was this fragment at least in that it was building 
results). The eddl:tempPosition subject is an instance with a property 
eddl:boxPosition (a float). The SPIN functions work.



{= ui:newline() 
}\tiny\begin{figure}[htb]

  {= ui:newline() }\begin{tikzpicture}[every 
node/.style={auto,font=\scriptsize,text width=4cm,inner sep=5pt}]

  {= ui:newline() }\draw (0,6) node(0) [draw] {{= 
eddl:replaceUnderscoreCharacter(?cname) }};

  {= ui:newline() }{= spin:nl() } \\

  {= ui:newline() }\draw (12,{= *spl:object(eddl:tempPosition, 
eddl:boxPosition)* })node({= ?index + 1 }) [draw] {{= 
eddl:bcRangeString(?range) }};

  {= ui:newline() }\draw[->] (0.south) |-  node [near end] {\tiny ${= 
eddl:replaceUnderscoreCharacter(?alabel) }$}   ({= ?index + 1 }.west);

  {= ui:newline() }**

  {= ui:newline() }{= ui:newline() }\end{tikzpicture}

  {= ui:newline() }\caption{{= eddl:replaceUnderscoreCharacter(?caption) }}

  {= ui:newline() }\label{{= ?label }}

  {= ui:newline() }\end{figure}




SWP is complaining about the INSERT, but the example I found in the manual 
(section 5.6) suggests that I should not be getting an error (albeit, in 
the example, the surrounding code is different (ui:precondition)).


As before, the idea here is to iterate through a list and calculate the y 
position of a box based on the content of the box and the y position of the 
previous box.


Jack

On Friday, March 13, 2015 at 3:31:12 PM UTC-7, Jack Hodges wrote:
>
> I tried several things, including embedding the INSERT into an SWP 
> function (setLocalVariable) and the SELECT into a normal SPIN function 
> (getLocalVariable). But they didn't work. I also tried it with the 
> spl:objectInGraph followed with a call to my SWP function but that didn't 
> work.
>
> Then I thought "what if I could do something like a 'let:curry-={= 0.4 - 
> eddl:bcydist(?range) }' " That is a substraction assignment operator. This 
> doesn't produce any errors but it also doesn't do anything. It would be 
> great if the local assignment would support more assignment operators than 
> just simple assignment.
>
> Is it safe to assume that the scope of let is the ui:group it is defined 
> in?
>
> Once again, stuck. The simplest of all possible functionalities:
>
> 
>   perform a calculation on a variable in ?entries based on a simple 
> calculation (do determine a relative position)
>   do something graphical with that value like draw a bubble at a location
>   persist that location for the next iteration
> 
>
> Surely someone has tried using SWP to draw graphical entities where 
> relative (and exact) positioning is needed...
>
> On Friday, March 13, 2015 at 11:53:58 AM UTC-7, Jack Hodges wrote:
>>
>> Is these (both the INSERT and the SELECT something that would be embedded 
>> inside my SWP forEach? Even if it is its going to be messy and ugly. Can I 
>> take the ui:update block and the other code and put them into SPIN 
>> functions or magic properties to unclutter the SWP? So far it isn't 
>> working...
>>
>> Its just sad that there isn't a clean (this is hardly what I'd call 
>> clean) mechanism to persist a variable value in the same context you 
>> mentioned for ui:tempGraph. That is, within the scope of the SWP 
>> construction.
>>
>> Jack
>>
>> On Thursday, March 12, 2015 at 4:16:22 PM UTC-7, Holger Knublauch wrote:
>>>
>>>  I don't think SPINX would be helping you, even with a stand-alone file 
>>> - each invocation of such a SPIN function would get its own JavaScript 
>>> engine, and all intermediate values will be lost.
>>>
>>> Your computation below looks like easily done in SPARQL. All you need to 
>>> do is remember the intermediate values in a graph such as ui:tempGraph.
>>>
>>> Holger
>>>
>>>
>>> On 3/13/15 8:24 AM, Jack Hodges wrote:
>>>  
>>> This seems like a good idea but it isn't working out so nicely. If I use 
>>> the spix.javaScriptCode proerty on the following javascript fragment: 
>>>
>>>  var prev = 6; var curr = 0; if(arg1 == 0) curr = 5; else curr = prev - 
>>> 0.4 * arg2; prev = curr; return curr;
>>>
>>>  the code executes (in a SPARQL window) but doesn't persist the value 
>>> of 'prev', which was the original need.
>>>
>>>  If I use the spinx:javaScriptFile on the following (named 
>>> 'position.js' in the folder  where the SPIN file is located):
>>>
>>>  function yBoxStart(index, count) {
>>>  var prev = 6;
>>> var curr = 0;
>>>
>>>  if (index == 0) {
>>>  curr = 5;
>>>  } else {
>>>  curr = prev - 0.4 * count;
>>>  }
>>>
>>>  prev = curr;
>>>
>>>  return curr;
>>>  }
>>>
>>>  Then it doesn't produce any results in the SPARQL wi