we build software to span your digital divide
Home Blog Partners Technology Wiki Jobs About Us Contact

PHP, XSLT and XHTML

The Geek Dinners in Cape Town - a must do event for technophiles, Geeks and open source software fanatics - regularly feature a prize which is won by one of the attendees. Jonathan Endersby one of the organisers wrote a javascript app which randomly flashes attendee numbers until suddenly stopping and repeatedly flashing the winners name.

All the names appear on an Wiki page - how much nicer would it be to see names flashing instead of numbers? I chatted with Jonathan and he requested a JSON array of strings as input for a new script which would presumably use the numbers as indexes into the array - a minor adjustment.

Creating the array must be almost equally simple I thought. Wiki pages are XHTML. Writing an XSLT to strip the names out of the HTML must be really a simple task. So simple we might as well generalise the problem and solve it for all HTML pages, as there are numerous converters from HTML to XHTML (Pear library). The XSLT was simple to write... but getting it plugged into PHP was well nigh impossible. To make things worse the HTML to XHTML converter in the Pear library didn't produce valid XML in all cases (some tags just weren't closed).

Passing XHTML into the Sablotron XSLT library also did not produce any happy results! Sablotron consistently produced error 69 and refused to continue. Strangely enough, the error message said "unkown encoding'', but in the Sablotron error number list 69 means bad URI or something like that. After checking all the encoding statements, I eventually found a reference to older parsers not understanding the XHTML namespace and not loading the DTD which defines all the encodings, correctly. I had to give up on the PHP solution! My hoster runs PHP 4.3.x and installing new libraries was not an option. PHP + XHTML + XSLT a natural combination one might think. But it had failed.

Instead I just used the XSLT processor on the W3C website - it works just fine!

The script can be run here: http://ekhayaict.com/_gds/gds.php (call it with a parameter xhtml to process other pages)

The XSLT file is here: http://ekhayaict.com/_gds/xslt/gds.xslt

The W3C Transformer is here: http://www.w3.org/2005/08/online_xslt/

Geek Dinner: http://planet.geekdinner.org.za/

Posted: February 2nd 2008 08:50
[permalink]


(no comments at present)





aw-profile
Ron Wertlen Ron Wertlen
[chat]
Tablet Face Recognition Login
New technologies are solving common denominator problems, so of course they are also applicable in developing countries.  awarenet's picture login [1] is a fairly low security but effective way of allowing school children with low levels of literacy to log in and use the csocial network...
by: Ron Wertlen
[permalink]
Node.js stays close to its roots: Ultra-fast.
Recently one of the big node.js community stars, creator of the express middleware framework, the jade templating language and koa -- TJ Holowaychuk -- announced that he was no longer going to be using node.js [1]. The main reason that he cited is the reason why we find node.js so compelling...
by: Ron Wertlen
[permalink]
Javascript Platforms for Development
Node.js is a new-comer on the Internet Web Server block. It is programmed in Javascript, and it is something worth watching in the ICT4D arena for these reasons: It runs on light-weight hardware, like the Raspberry Pi and requires much fewer hardware resources than traditional systems like apache, ...
by: Ron Wertlen
[permalink]
Innovation Made in the Eastern Cape, South Africa
A brand new 2012 CSIR research project into Technologies for Rural Education will make use of awareNet technology. The CSIR (Council for Scientific and Industrial Research) is South Africa's first and largest technology innovation institution and very active in the development and rural development ...
by: Ron Wertlen
[permalink]
eKhaya ICT - Recalibration
eKhaya ICT has unveiled a new direction - as reflected in our current web site changes. What's changing?ICT for development -- our research over the past 5 years shows that this topic belongs firmly in the sociological and anthropological drawer and has nothing to do with software development! ...
by: Ron Wertlen
[permalink]



eKhaya ICT is an Eastern Cape based software company, specialising in quality solutions and software components of ICT4D.

Contact:
9 Florence Street
Grahamstown
6139
South Africa
Tel: +27 79 4354681
Fax: +27 46 6227507
www: ekhayaict.com
Products:
awarenet
Discontinued:
Reed House Systems
Site Links:
About Us
Jobs
Contact
Log In



--- (c) 2014, eKhaya ICT ---