Definition of Whitebeam XML Tags

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
    authenticate
    block
    cachecontrol
    eval
    false
    header
    include
    insertblock
    insertdebug
    macrotag
    marksession
    nomacro
    noscript
    parser
    redirect
    repeatfor
    return
    script
    if
    test
    true
    xmp
    eval
    id
    marksession
    test
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Definition of Whitebeam XML Tags

rb:macrotag

Define a new XML tag with JavaScript implementation

Body

The body of this tag contains the JavaScript implementation for this tag.

This tag allows a Pattern Page to dynamically create a new pseudo XML tag.

Attributes

Attribute Required Description

name

required

This is the name of the new tag.

proc

implied

opaque or subtree. The default is 'subtree' which means that the  XML parser will completely decode the subtree of elements within the tag. The alternative, opaque, means the parser will treat the contents as literal text until it finds a matching end-tag. The contents are then available to the script implementation as a block of text.

body

implied

Specifies the legal contents of the body of this tag. Legal values are:

  • empty - must contain nothing.

  • text - can only contain text, but no contained tags.

  • any - can contain text and any set of tags.

  • tags - body may contain only tags and no text.

  • list - the 'taglist' element will be present and will contain a list of the valid tags that can appear within the body of this tag.

taglist

implied

A white space separated list of tag names that identify the types of tags that may appear within the body of this tag.

attribs

implied

Specifies which attributes may be used in this tag.

  • empty - this tag should contain no attributes.

  • any - this tag can contain any (or no) attributes. The parser does not validate the contents.

  • list - the 'attriblist' attribute will contain a list of attributes that are valid for this tag. If an attribute is used that is not in the list then the XML parser will generate an error.

attriblist

implied

Space separated list of attributes that may appear within this tag declaration. Note that if this attribute is present then the implied value of 'attribs' is 'list'.

Remarks

The body of the tag contains Whitebeam JavaScript that provides the implementation of the new tag. Whenever the new tag appears in a presentation page the system will execute the JavaScript implementation and replace the tag with the output generated.

The various attributes defined on this tag tell the presentation engine how the new tag is to be treated and what legal usage can be applied to the tag. These attributes are used as follows:

One intended use of this macro is to simplify the integration partners use of a template by encapsulating frequent template operations in a single tag - avoiding the need to do "everything"  in JavaScript.

Example:

<rb:macrotag name="rb:searchfor">
   var SearchString = rb.page.attribute("string");

   if (SearchString.length()>0) {
      var iterator = rb.shop.search(SearhString);
      var count=0;

      rb.page.write("<TABLE>\n");
      while (count<20 && iterator.next()) {
         rb.page.write('<TR><TD>'+
                   iterator.value("reliability")+
                   '</TD><TD>'+iterator.value("title")+
                   '</TD><TD>'+iterator.value("summary")+
                   '</TD></TR>');
         count++;
      }
      rb.page.write('</TABLE>');
      if (count==20 && iterator.remaining()) {
         rb.page.write("<P><B>More matches to follow...</B></P>");
      }
   }
</rb:macrotag>

<!-- This new tag can then be used as follows: -->
<rb:searchfor string="life"/>

Another use of this tag is to define a custom way to process specific XML tags. There are a number of cases where the JavaScript implementation of the tag needs to interrogate the contents of the tags body. That is to look at the tags and text contained within the opening and closing elements of an instance of the declared tag or at the attribute of the tag. The Whitebeam system provides two JavaScript functions for this purpose. 

FunctionDescription

rb.page.attribute

Provides access to the attributes specified within the opening tag.

rb.page.tagtree

Provides access to the body of the tag. This allows the script implementation to recursively parse each attribute in the XML sub-tree and to ask each tag, if necessary, to generate the text representation of it's own subtree.

The glossary sample application is a good example of the use of the <rb:macrotag...> in conjunction with the above functions.

Whitebeam release 1.3.35
(loadtime : 16ms)