===================================================================== Moodle Forum export XML to HTML XSLT convertor Last Updated: 17/Jun/2008 Author: Dean Stringer (deans@waikato.ac.nz) Copyright (C) 2008 University of Waikato This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ===================================================================== Description: Contained in the archive this file is distributed with is an XSLT file which can be used to convert a Moodle forum archive XML file into a human readable HTML page. The rendered page is portable and contains the discussions and posts in their original structure but without the original Moodle theme and header/footer. It also uses some JavaScript which lets the reader expand/collapse the discussions. Usage: You will need access to an XSLT engine of some sort to use this conversion tool. Any generic XSLT processor should do as there are no special or custom functions used in the XSLT file delivered. If you're happy using the command line and are on an Windows desktop the you might consider downloading the MSXSL tool from Microsoft, or Michael Kay's SAXON engine, both of which you would run from a DOS window. If on a *nix machine there is a good chance you will have access to something like xsltproc (LibXSLT) or sabcmd (Sablotron) and if not your administrator might install them for you. Here's how you would process a Moodle export using MSXSL: Start-Run-'CMD' + CD to the folder you saved your moodle.xml file to C:\Tools\MS_XSL\msxsl.exe moodle.xml moodle.xslt > output.html Open up temp.html and you should see you rendered forum archive. Configuration: Rendered versions of the forum archives include links to some dependency icons, css and JavaScript files. You may want to move these somewhere other than where the rendered HTML page goes so you don't have multiple copies of them to manage. To do this you need to tweak the following three lines near the top of moodle.xsl: As you can see their paths are set in the "select" attribute to the value './' which tells the browser to look in the same folder as the HTML page itself. You may want to change them to something like "http://www.mysite.edu/myfolder/" for example. Performance issues: The XML files generated by exporting forum discussions can be very large if there are a good number of posts. Although it is possible to use the XSLT for on-the-fly rendering of the archive using PHP you should test the impact this may have on your server, and possibly use it only on a non-production server if you expect to be performing a lot of conversions. Much better to transform off line in batch mode somehow, possibly from the command-line. Date handling: Moodle stores datestamp/time data in fields within Moodle itself and in the export files in the format that is output by the PHP time function, ie the current time measured in the number of seconds since the UNIX Epoch (January 1 1970 00:00:00 GMT). These are large integers and not human readable or useful for display One possible means of rendering these is to use a XSLT extension functions. This means that you must be able to register the function in your development environment before calling this XSLT transform.