Rendering the Pages

Top  Previous  Next

Probably the biggest difference between the MoreMotion and other well known web application frameworks is that the MoreMotion relies on the XSLT processing for the rendering of the dynamic HTML pages.

The XSLT processing is done by the XSLT processors. There are a number of XSLT processors available for almost all the platforms. The modern browsers are also equipped with this capability which means the rendering of a dynamic HTML page can be done by them as well as the server side XSLT processors. 

An XSLT processing requires two inputs;

1.An XML document containing the data, 
2.An XSL stylesheet document containing the information about how the data is to be represented.

An XSL stylesheet is nothing but an HTML document which contains embedded XSL instructions.

These two inputs must be ready before the "DisplayPage" service of MoreMotion invokes the XSLT processor. The XSL document should be supplied by the developer under the web application's root directory.  After all the relevant processes and services executed, the XML data is prepared by the MoreMotion at the last stage out of the MoreMotion data objects (ADOMs). This XML document is called "Page XML Data" and  it contains only the data required/referred by the XSL stylesheet document.

Input 1 - Page XML Data prepared by MoreMotion:

   <root>
   <products>
     <item>
       <Name>Desktop Computer</Name>  
       <Stock>10</Stock>
       <Price>749.99</Price>
     </item>
     <item>
       <Name>Notebook Computer</Name> 
       <Stock>5</Stock>
       <Price>1119.99</Price>
     </item>
   </products>
  </root> 

 

Input 2 - XSL Stylesheet Document provided by the developer:

  <?xml version="1.0" encoding="UTF-8"?>

  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:output method="html" encoding="iso-8859-1" version="1.0" />

   <xsl:template match="/">

   <html>

     <body>

       <table border="1" width="100%">

         <xsl:for-each select="/root/products/item">

           <tr>

             <td><xsl:value-of select="Name"/></td>

             <td><xsl:value-of select="Stock"/></td>

             <td><xsl:value-of select="Price"/></td>

           </tr>

         </xsl:for-each>

     </table>

     </body>

   </html>

  </xsl:template>

  </xsl:stylesheet>

 

Output - HTML Document generated by the XSLT processor

<html>

<body>

<table border="1" width="100%">

<tr>

<td>Desktop Computer</td>

<td>10</td>

<td>749.99</td>

</tr>

<tr>

<td>Notebook Computer</td>

<td>5</td>

<td>1119.99</td>

</tr>

</table>

</body>

</html>

XSLT Processing on browser

Modern browsers are equipped with XSLT capability which means they can generate the HTML documents by themselves incase of the XML and the XSL documents are supplied to them. Obviously this is an important advantage since the application server is free from this CPU intensive job and the network transmits up to 10 times less data.

Although new versions of almost all the browsers have integrated XSLT engines, there are slight differences in the outputs they generate.

It is configurable to which browsers the MoreMotion gives the responses as XML instead of HTML. The XSLT capable browsers are defined in system parameters file WEB-INF/MM-INF/config/sysinfo.xml as follows.

  <systemParameters>
    ..
    <param name="xsltCapableBrowsers">MSIE 6.|MSIE 7.|Netscape/7.Still Not</param>
    <param name="xsltInCapableBrowsers">Opera</param>
    ..
  </systemParameters>

In the values of the xsltCapableBrowsers and the xsltInCapableBrowsers parameters, the definition strings are delimited with "|" characters. In order a browser to be entitled as XSL capable browser, its user agent definition must contain one of the strings defined with xsltCapableBrowsers parameter and  must not contain none of the strings defined in xsltInCapableBrowsers parameter.

The default definitions entitle only Internet Explorer 6 and 7 as the XSLT capable browsers.

 

Forcing MoreMotion to respond as HTML to a particular request

In some cases it is desirable to get the response as HTML even though the browser is XSL capable. The request parameter _sendhtml can be utilized for that as follows.

  display.doms?pg=products&_sendhtml=true