How is this working?

3q is itself an awk script so there must be a trick. First 3q reads the XML file and converts this into a gawk script, static HTML/XML text is converted in printf() calls and source code inside <? awk ... ?> is passed as is. The resulting script code is then passed to a second gawk invocation as command line script.
3q relies heavily on proper shell quoting.

This idea is not new. Recently I found SQAwk on Sourceforge: http://sourceforge.net/projects/sqawk/. The basic principle is the same (quoting then executing) but for some reason this project was abandoned.

Notice:
It was comparable simple to modify 3q in a way that it puts the encoded script into a file which is then passed as argument to the executing gawk. Just make sure that the variable usefiles at the beginning of 3q is set to `1'.

Limitations

The total length of the executed gawk script and passed CGI variables depends on limitations of the shell interpreter regarding the command line length. This is not longer an issue because of the usefiles modification.