
ajax analysis api apple atom automator backpack browsers camping cheatsheets code console editors ergonomics gems google helipad hpricot internationalisation javascript lies mac optimisation patterns performance personal php plugins productivity programming prototype rails rapidrails rsi rss ruby server snippets standards sysadmin terminal testing textile textmate theory tips tools vim workshops writing xslt
We have a PHP CMS with a lot of poorly written HTML in the client-contributed content. This kept causing my XSL template system to output XML errors. I got around this problem by:
Using CDATA tags around unpredictable HTML helps prevent problems with the XML parser. Without the final step, the resulting HTML …
Textile provides a simple way of writing human-friendly text that can easily be translated to XHTML. HTML tags are simplified into a set of phrase and block modifiers; even tables and attributes can be created.
I was looking at the PHP code for this and wondering if I could create an XSL file that could translate similar text into XHTML. I created some XML to contain my text:
And then used the following recursive algorithm to process it in XSLT:
...
I’ve found two approaches to this:
http://sources.redhat.com/ml/xsl-list/2000-08/msg01318.html
http://www-106.ibm.com/developerworks/library/wa-xslt/
I think the second method looks like the best. I like the idea of using a general XSLT template to add in generic functionality too.
I often use a message class for a lot of things with PHP. This allows me to build messages to display to the user for errors, successes and general feedback.
Classes for each of these three things are created in CSS to display the information, and then I use a simple PHP class for appending messages to a arrays.
I wanted to include this in some XML data I was processing with XSLT, but I found it difficult to combine multiple XML files with PHP’s XSLT processor. However, in PHP4, you can do it like this:
// this is a code fragment
//
$XML = implode('', file($XML_Fi...