XML Processing using the Whitebeam Environment

Site Map
Application Guide
  Quick Start
  PHP and ASP
  Writing Apps
    Postgres Interface
    XML Processing
      Processing Data
      The XML JavaScript API
      Special Behaviour
      Manual Execution
      XML Macros
    Using XPath
    Binary Object
    Using HttpRequest
    Meta Data
    Memb Services
    Page Look&feel
    Message Groups
    Form Handling
Contact Whitebeam
Whitebeam Users

XML Processing using the Whitebeam Environment

Manually Executing XML Subtrees

The XML tree built with the XmlParser.build is generally 'executed' in order to populate the 'output' area of each element. It is not 'required' that you execute the XML - there are applications that may just require the basic structure of the tree.

At any time the output area may contain different things:

  • If the tag has yet to be executed the output area will be empty.
  • If it has been executed then it will contain the contents from that execution.

  • A tag tree can be executed multiple times in order to produce different output. At any time the 'output' area of an element contains the text from the last execution of that element.

You can see from the description of the rb:block tag above that initially the output areas of all children of the block will be empty. In JavaScript you can however get hold of the sub-tree of the rb:block tag and execute it. To do this give the block tag an id (using the rb:id attribute). This is illustrated below:

<rb:block rb:id="myBlock">
         <rb:eval expr="prop">
         <rb:eval expr="object[prop]">

This example block is labeled - so we can find it - it has an 'id' and so we can simply search for the element with the XmlTag.findId method on the root of the tree. eg:

   var tag = rb.xml.root.findId("myBlock")

Remember at this stage these tags have never been executed! If you now call 'var text=tag.bodytext()' the result will be an empty string. To generate output you have to first execute the tag. Do this using the tag.execute() method. The normal behaviour of this method is to run the tag on which it is invoked. An exception occurs where the tag is an 'rb:block' tag - because the effect of that tags execute is to do nothing! In the case of an rb:block tag all of the children of the tag are executed. This will effectively populate the output areas of each of the children. Note that in the example above the block contains active server-side behaviour in the form of <rb:eval...> tags. The block can be used in a loop to dump the contents of an object's properties:

   var object = new Object;
   object.name = "Peter";
   object.sname = "Wilson";

   var prop, testObj;
   var tag = rb.xml.root.findId("myBlock")

   rb.page.write('<table border="1">');
   for (var prop in object) {
      // generate new output for this row.

      // Now output to the client (adds to my output area).

Whitebeam release 1.3.36
(loadtime : 20ms)