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:group let:cname="{{= afn:localname(?resource) }}" let:curry="{= 
xsd:integer(5) }" let:resourceU="{= ssf:maybeConvertToURI(?resource) }">

    <ui:group letrs:entries="{#

            SELECT DISTINCT ?clabel ?alabel ?rlabel ?range

            WHERE {

                ?resource rdfs:subClassOf ?rest .

                ?resource rdfs:label ?clabel .

                ?rest owl:onProperty ?att .

                ?att rdfs:label ?alabel .

                ?att rdfs:range ?range .

                {

                    ?range rdfs:subClassOf rdfs:Resource .

                    ?range owl:equivalentClass ?eclass .

                }

                UNION

                {

                    ?range rdfs:label ?rlabel .

                } .

            }

   ORDER BY (?alabel) }" ui:id="IndexList">{= 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() }<ui:forEach ui:indexVar="index" ui:resultSet="{= ?entries 
}">{= spin:nl() } \\

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

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

  {= ui:newline() }*<ui:update ui:updateQuery="{!*

*                    INSERT {*

*                        eddl:tempPosition eddl:bpxPosition (?prev - 0.4 * 
?rnum) .*

*                    }*

*                    WHERE {*

*                        BIND (eddl:tempPosition eddl:boxPosition ?foo) AS 
?prev) .*

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

*                    }*

*                }" />*

  {= ui:newline() }</ui:forEach>{= ui:newline() }\end{tikzpicture}

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

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

  {= ui:newline() }\end{figure}</ui:group>

</ui:group>


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:
>
> <ui:forEach ui:indexVar="index" ui:resultSet="{= ?entries }">
>   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
> </ui:forEach>
>
> 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 window at all. I 
>>> suspect that the 'position.js' file cannot be found. I have put it in 
>>> different folders and tried a full URL to it with the same [lack of] 
>>> results. The documentation goes part way through a full example but leaves 
>>> out just enough for me to fail to get it working. Clearly this is the 
>>> rudimentary of functions so there must be something very simple that is 
>>> wrong. I didn't see anything about the name of the javascript function in 
>>> the documentation. Is that maybe related to this problem? Comments?
>>>
>>>  Jack
>>>
>>>  
>>> On Tuesday, March 10, 2015 at 3:22:50 PM UTC-7, Holger Knublauch wrote: 
>>>>
>>>>  ui:functionCall is only producing JavaScript source code that would be 
>>>> executed client-side. If you want server-side execution of JavaScript 
>>>> logic, you could use SPINx
>>>>
>>>>     http://spinrdf.org/spinx.html
>>>>
>>>> HTH
>>>> Holger
>>>>
>>>>
>>>> On 3/11/15 7:11 AM, Jack Hodges wrote:
>>>>  
>>>> and performs some calculation? I am trying to calculate a display 
>>>> position for part of a graphic inside a ui:foreach. The position is based 
>>>> on the position of the previous item in the iteration. It is easy enough 
>>>> to 
>>>> write a js function that will maintain the variables and their values, and 
>>>> calculate the new position, but is using ui:functionCall and appropriate 
>>>> way to talk with the function? Thanks, 
>>>>
>>>>  Jack
>>>>  -- 
>>>> 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 topbrai...@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-user...@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 topbrai...@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-user...@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.

Reply via email to