Whitebeam Object Definition

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Object Definition

Method Description

XmlParser.execute()

Re-execute part of an XML tag tree. Each note gets to re-evaluate its contribution to the document being generated. ADVANCED.

Syntax

void = XmlParser.execute(parameters)

Parameters

The 'XmlParser.execute' method takes 1 parameter:

Name Type/Value Range/Length Description
parametersMetaData  Optional. JavaScript parameters to be passed to the tagtree. These appear as global JavaScript variables to any JavaScript executed within the tag-tree.

Results

The 'XmlParser.execute' method returns no useful information.

Remarks

This method uses the Whitebeam Presentation Engine to re-execute the source XML of the tag tree. Invoking this method will discard the current text output of the tag tree and rerun the entire subtree. In the case where the tag tree simply contains static HTML - this will generate the same text. Where the tree contains active Whitebeam server-side code however that code will be re-executed using the current executing environment. So for example the JavaScript within the tree could have access to different parameters.

The tag tree re-executed may include content that executes JavaScript - either directly through things like the <rb:script...> or <rb:eval...> tags, or indirectly because the content includes a tag for which there is a macro tag definition - an <rb:macrotag...>. In these situations it can be useful to pass some parameters into the tagtree. Consider the very simple example:

   <rb:block rb:id="myBlock">
      <tr>
         <td>
            <rb:eval expr="name"/>
         </td>
         <td>
            <rb:eval expr="dataset[name]"/>
         </td>
      </tr>
   </rb:block>

   <rb:script>
      var data = ["this", "is", "the", "dataset"];
      var tags = rb.page.tagtree("myBlock");

      for var (count=0;count<data.length;count++) {
         tags.regenerate();
         rb.page.writr(tags.bodytext());
      }
   </rb:script>
            

In this case we want to repeat the block a number of times - each time the code generates a different table row. The example won't work because the contents of the tagtree is always executed in the global context. To make this work you have to pass the parameters into the execution. Re-writing the script yields the correct behaviour:

   <rb:script>
      var data = ["this", "is", "the", "dataset"];
      var tags = rb.page.tagtree("myBlock");

      for var (count=0;count<data.length;count++) {
         tags.regenerate({count:count, dataset:data});
         rb.page.writr(tags.bodytext());
      }
   </rb:script>
            

'regenerate' now has a single parameter - an object that is initialised to contain two attributes, 'count' and 'dataset'. This object is placed at the front of the JavaScript scope chain before executing the XML subtree.

Whitebeam release 1.3.36
(loadtime : 12ms)