XML/XSL View engine

Inspired by the Java framework Pustefix this view engine creates the view by applying XSL stylesheets on a XML tree created by the application.

Basic Configuration

To use the XML/XSL view engine you need to configure the appropriate processor in the processor configuration. The processor class for this is net::stubbles::websites::xml::stubXMLProcessor. For information on how to configure the processor configuration see Controller, Processors and Processor resolvers.

How the XML/XSL view engine works

The engine creates the view in two steps:

  1. The processor handles the incoming request and creates a XML document that contains all required data to answer the request properly.
  2. Then it takes this XML document and applies a XSL stylesheet on it which results in the HTML that gets delivered back to the browser.

To make this clear we will take a look at the processing of a specific request. Let's assume that a page named "foo" is requested by the browser.

1. work of XML document creation detailed

When the request comes to the XML processor, it first checks if such a page exists. This is done by checking if in the pages path a file named foo.xml exists in the subdirectory conf. If this is not the case it falls back to processing the request as if the page index was requested.

Within this XML file the page is configured which means it has a list of all classes that should be executed on this request. (Simplified, more details can be found in the documentation about the page configuration.) The processor now executes the process() method of all these classes, and writes the return value of this method into a XML document using the XML serializer. Beside this some values will be serialized into the XML document by default, for instance some informations about the session and the request itself. The created XML document is written into the response object.

2. work of applying the stylesheet on the XML document detailed

In a second step it creates a style sheet dynamically by applying the master.xsl stylesheet to the skin stylesheet which resides in a file default.xml in the skin subdirectory of the page path, which itself includes a file named main_foo.xml in the txt subdirectory of the page path. For every configured page in the conf directory a matching style sheet file should exist in the txt directory. Finally the generated XSL stylesheet gets applied to the XML document taken out of the response, and the result of this transformation replaces the contents of the response. These steps and how they can be influenced by your application are explained in detail in the stylesheets section.