Workaround: generate explicit closing tag in XSLT

It looks like the PHP XSLT functions have a bug when generating HTML output: they generate self-closing <script src="..."/> tags that cause Internet Explorer to hickup, although the XSLT transformation engines should take care of HTML peculiarities (including the set of <script></script> tags) when you set xsl:output to html.

The workaround provided in PHP documentation comes handy in any situation where you want to have an explicit closing tag for whatever reason. Instead of <tag></tag> which is usually output as <tag />, your XSLT transformation should contain <tag><xsl:comment /></tag>, which will generate the opening and closing tag.

Output XML data from ASP

These are the steps you need to take to output XML data from ASP script:

  • Clear the output buffer to ensure no HTML tags are sent to the client;
  • Set the content-type to text/xml;
  • Optionally (but highly recommended) set the character set to utf-8 and change the ASP code page;
  • Output the XML data (for example, writing a DOM object xml property to the output stream);
  • Stop ASP script processing.

The sample ASP code is included below and you can get more in-depth description of the necessary operations in my InformIT article Optimized presentation of XML content.

Response.Clear
Response.ContentType = contentType
Response.Charset = "utf-8"
Response.Codepage = 65001
Response.Write txt
Response.End

Note: this post is part of You've asked for it series of articles.

Converting forms to AJAX

Form submission handling is probably one of the more challenging topics if you've decided to deploy an AJAX application instead of a traditional page-by-page web application. In his short article, Kris Hadlock has provided an excellent sample code that you can deploy to transform a form submission request into an AJAX request (thus retaining tight control over the results and error handling).

How to avoid common CSS mistakes

I admit it - I was also one of those web developers that jumped in CSS waters with helping hand of uncle Google instead of a good introductory and reference book on the topic. If you want to avoid some of the stupidities I've been doing, read the Seven Common CSS Mistakes and How to Avoid Them article I wrote for InformIT.

Using transformNode in IE7

Apparently a lot of people land on my blog when using Google to figure out how to use transformNode function in IE7. The answer is simple - you don't do it, as it's IE-only function that will obviously not work in any other browser.

What you should do instead is to use a wrapper library like Sarissa that gives you XSLTProcessor object in both Firefox and Internet Explorer environments. The XSLTProcessor API is described in Mozilla documentation (which also includes a simple example).