Last night I installed the Joomla open source content management system on my local web server and explored its ability to consume XML data feeds (web services, developer APIs, and RSS news feeds). The News Feed module did not allow me to specify a news feed stylesheet, aka XSL file, so I had to look for an extension to add this functionality. I found botMosXslt, a Mambot allowing processing from xml/xsl file using xslt processor and render the result in content. There were no instructions on how to install it so I will describe how to do so on a Windows web server running PHP 5.0:
- Copy mosxslt.php and mosxslt.xml to C:\Inetpub\wwwroot\joomla\mambots\content
- Create directory for XSL files at C:\Inetpub\wwwroot\joomla\custom\xml
- Select Mambots / Site Mambots in Joomla Administrator!
- In the Mambot Manager [Site] click the New button
- Enter “botMosXslt” for the Name field
- Leave content selected for the Folder field
- Enter “mosxslt” for the Mambot file field
- Leave Yes radio button selected for Published field
- Click the Save button
The new botMosXslt mambot should now appear in the list:
Next I will describe how to use it to display LiveVideo Featured Videos and deal with an error:
- Select Content / All Content Items in Joomla Administrator!
- Click the New button
- Enter a title
- Enter the title alias
- Select a section
- Enter “{mosxslt GetFeaturedVideos.xml FeaturedVideos.xsl} ” as your content
- Click the Save button
- Copy GetFeaturedVideos.xml and FeaturedVideos.xsl to C:\Inetpub\wwwroot\joomla\custom\xml
- If Fatal error on xslt_create function, edit mosxslt.php
I got a fatal error because I did not have the required libraries to process XSLT using PHP on my system. Fortunately, I had already figured out an alternative way of doing it using the built-in capabilities of PHP 5.0. So if you get the following error add the code I list below it:
Fatal error: Call to undefined function xslt_create() in c:Inetpubwwwrootjoomlamambotscontentmosxslt.php on line 74
Edit the mosxslt.php file to work around this problem:
/* // Process xml
$xh = xslt_create();
$xsltResult = xslt_process($xh,
$fullXmlFilename, $fullXslFilename);
if ($xsltResult)
$htmlContents = $xsltResult;
else
$htmlContents = "!!! Error in executing XSLT !!!";
return $htmlContents;
*/
// Process xml on Windows
// edited by Robert S. Robbins 02/24/2007
$xml = new DOMDocument;
$xml->load($fullXmlFilename);
$xsl = new DOMDocument;
$xsl->load($fullXslFilename);
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
// attach the xsl rules
return $proc->transformToXML($xml);
As you can see I finally got this to work for me. However I did have to use a static XML file rather than pull the current list of LiveVideo Featured Videos using their Developer XPI.
2 Responses to Joomla And botMosXslt – XML Feeds In Portals