XML Processing: A Simple Glossary

run example

overview   applications   limitations   structure diagram   files   details

Overview

This is a simple example that shows some of the XML processing capabilities of the Redbourne system. A basic XML file contains the definitions for a number of glossary items which are read and processes by a "rhtm" file based on a parameter supplied.

There is no management application for this example as the only thing that needs to be managed is the glossary definition file.

Applications

This example application is applicable to all sites requiring simple XML processing to display sections (or all) of a larger document. (Much of the Redbourne documentation - such as the ROM - is displayed by showing requested sections of a larger file).

Limitations

This example is not meant to be a example of content management.

Structure Diagram

Application

Files  

Application

Management Application

1 index.html HTML Page that illustrates the different ways of calling glossary.rhtm    

2 glossary.rhtm

 

Pattern page that includes the glossary definition in an xml file, processes it and outputs the requested sub-set.

   

3 glossary.xml

A cut-down xml file containing the glossary itself.

   

Details

The xml file contains a very simple xml glossary definition:

Markup Explanation
<glossary> The whole glossary is wrapped in this tag.
<item name="itemName"> Each individual item of itemName is wrapped in this tag.

The glossary "rhtm" file processes this by using a special feature of the system that allows you to define custom XML tag actions. Two <rb:macrotag> definitions can be seen for "glossary" and "name", inside each is some server JavaScript that defines how to process <glossary> and <name> tags when they are encountered in the document.

In many ways it is like specifying an XML Stylesheet (XLS) for an XML document, the macrotag definitions tell the Redbourne presentation engine what to do and the output to generate when it encounters the tag. The macrotag definition can override existing, default behaviour for tags as well as defining new behaviour.

Several functions are used within the macrotag block: rb.page.tagtree() is a method that returns an (XMLtag) object that represents the current tag and its contents, rb.page.attribute("name") is a method that returns the value of the attribute called "name" for the current tag, XMLtag.bodytext() returns the text representing the body of the tag. Lastly with <rb:macrotag> (and also <rb:block> ) tags the Presentation Engine does not produce any output for their contents when they are parsed enabling all output to be made under the control of JavaScript. To create output the regenerate method is used. This causes the Presentation Engine to discard any current output associated with the tag and recompute it.