Question: XSL & Dynamic Changes During Run-time

Subject: Question: XSL & Dynamic Changes During Run-time
From: "L. John Junod" <junod@xxxxxxxxxxx>
Date: Tue, 24 Feb 1998 17:23:21 -0500
Given:
"7.2. Limited Side-Effects

The ECMAScript language supports side-effects. However, unrestricted use of side-effects in XSL would create serious implementation problems for progressive rendering and for handling large documents. In XSL it is an error for **code** in a **construction rule** to change a **global variable**, or any object reachable from a global variable. It is also an error for code to change any object reachable from an object specified as the value of an inherited characteristic.

Enforcing these restrictions would be difficult for XSL implementations that use existing JavaScript implementations; therefore, this is not required of XSL implementations. However, the results of applying a stylesheet causing side-effects is unpredictable in systems that do not enforce the restrictions."


Assumed Definitions:

1) Code == ECMAScript

2) Construction Rule: ==:"The construction rules contain a pattern to identify specific
 elements in the source tree, and an action to specify a resulting sub-tree of flow objects. "

"In addition to construction rules, XSL also supports style rules....."

(Thus, rule elements are **construction rule** elements? Right?)

3) Global Variable == for XSL defined within the define-script element (equiv to C global var.)
<note regarding global variables in ECMAScript>
NOTES:  If ECMAScript is JAVA then "Java in a Nutshell, 2nd Edition, Oreilly, David Flanagan, 
ISBN 1-56592-262-X"  says in regards to global variables:  Pg 16 "As a language that
is designed to support dynamic loading of modules over the entire Internet, Java  takes
care to avoid name space conflicts.  Global Variables are simply not part of the language.
Neither are 'global'  functions or procedures for that matter."
Futher, pg 55 "What is different from a global variable in C is that there is no possiblity of name conflicts....Since each class variable must be part of a class and must be referred to with its class name each has a unique name."
</note>

MY READING

Per
"7.5. Scripting in XSL
The scripting language can be used in XSL in a number of different ways:
At the top level (**outside of any construction rules**), variable declarations and function definitions may be specified within a define-script element.

<define-script>
  var defaultFontSize = "12pt";

  function hierarchicalIndent(elementType, element)
  {
    return length(hierarchicalNumberRecursive(
                  elementType, element)) * 12pt;
  }
</define-script>"


Therefore,  "defaultFontSize" is a global variable and "hierarchicalIndent(elementType, element)" is a global function.

Q1: Is this correct?
 
Q2: Is there a planned way to maintain a "session" while in a web where a global record is kept of the session from within XSL given the words regarding the ability of a rule to change (denied) a global variable in 7.2?

Q3: Is there a way in XSL (or via the scripting extension) for a user to input a value into a form, which then is recorded in a global variable, and then change the behavior of the subsequent rendering?  That is, can one set a filter based upon a run-time user input value (or choice from a list of say checkboxes)?  As in Q2, does the restriction on setting global variables from within rules in section 7.2 apply






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread