RE: [xsl] Using XSLT for multi-agent simulation [was Creating a changeable globally scoped variable?]

Subject: RE: [xsl] Using XSLT for multi-agent simulation [was Creating a changeable globally scoped variable?]
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Sun, 21 Mar 2004 20:51:33 +0100
> -----Original Message-----
> From: Roger L. Costello [mailto:costello@xxxxxxxxx]
>
<snip />
> In order for the Agent Processing code to apply the Movement Rule
> to each agent it will need to modify the value of a global
> variable. Let's see why this is the case.
>
<snip />

Hi,

It seems to me that the 'current-cell' is not (or does not necessarily have
to be) a 'global' variable, or at least, a remote possibility could be to
gather all cells in a node-set variable at a higher level and pass it in as
parameter to the Agent-Processing Template(?)

Pseudo-code like:

<xsl:variable name="vcells" select="???" />
...
<xsl:call-template name="Agent-Processing">
  <xsl:with-param name="pcells" select="$vcells" />
</xsl:call-template>
...
<xsl:template name="Agent-Processing">
  <xsl:param name="pcells" />

  <xsl:for-each select="$pcells/cell">
    <xsl:call-template name="Agent-Movement-Rule" />
  </xsl:for-each>
</xsl:template>
...

Of course, this would depend on the relationship between the $num-agents in
the select expression of your for-each and the $current-cell variable. Is it
possible to sort it out at a higher level in the tree, *before* the
Agent-Processing template is called? If so, an approach like this would make
your life much easier, I think... Same goes for the Agent-Movement-Rule
template: equip it with an xsl:param and pass the current cell in through
there.

<snip />
> This template needs to dynamically alter the global variable.
>

It seems that you are struggling more with the scope of the variable in
question than with the need of its being mutable. In any case, both sides
can be dealt with by using parameters... the parameter being passed in is
always in scope for the current template, and can be modified to make it
depend upon a higher-level condition.


Hope this helps!

Cheers,

Andreas

Current Thread