04 Sep 2005
My Website-Generator keeps me busy during the free summer time, alright...
The input will be an XML file in which just the data structure and a few other things are specified. The generated Output is PHP (which -once on the server- will generate HTML). So we have a nice mix here...

In the code there are mixed code snippets from XHTML, PHP, SQL, all wrapped up in the transforming XSL. So, above all, this is XML because the XSL is really just yet another XML format...
All the XML-special chars that are also used in the XHTML or PHP or SQL (<,>,&) are likely to cause problems in parsing here. While it is apropriate to use CDATA-Sections when the code (HTML or PHP) is stored in XML, in XSL I think it is better to use xsl:text and disable output escaping.
For the freaks, here is a bundle of points made by the experts: http://www.dpawson.co.uk/xsl/sect2/N2215.html#d3457e277

I made up two coding conventions that make it possible to keep most of the code as-is. This should help a lot with the readibility of this code, as I tried hard not to make "<" out of all "<" in the HTML. After all, Syntax Highlighting is a fancy useful thing... So here we go:
  1. use xsl:text whenever a special char is NOT used in XHTML that can be properly parsed (that means: it's valid). So when we have the operator smaller-then ("<") in PHP or SQL, or the PHP delimiters (""), use <. Also do this when xsl:value-of - elements are coded within a XHTML-Element to dynamically fill in values. The WHOLE XHTML-Element then has to be masked.
  2. When you echo out XHTML-Code that uses quotation marks (e.g. for an attribute value), use single qt. marks for the echo-function and for the XHTML string use whatever you like. Either way, it will be double qt. marks in the oputput! Some portions of the code will have to be less readable, but only few. Another Consequence will be that PHP-Vars must be outputted in their own call to echo.
# lastedited 28 Sep 2005
You are seeing a selection of all entries on this page. See all there are.