Generating Test-Entry Web CGI

Problem

You want to test a process in isolation by processing text data received from a form and converting that data into a physical message that can be sent to the process under test.

Solution

This server generator goes along with the client generator created in Recipe 10.6. This section shows only a piece of the solution, but the discussion gives further detail.

The generated server is a C++ CGI program. You need it to be C++ (or C) because the form input will be converted into a binary message that is laid out according to the C memory model. It assumes the C++ processes that ultimately consume these message expect them as binary data. The generated CGI uses Enterprise Integration Technologies’ libcgi (http://www.landfield.com/hypermail/source/libcgi/) to simplify the common CGI tasks such as query-string parsing:

<!DOCTYPE xslt [ <!--Used to control code intenting --> <!ENTITY INDENT " "> ]> <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:strip-space elements="*"/> <!--The message to generate data for. '*' for all --> <xsl:param name="message" select=" '*' "/> <!--The directory to generate code --> <xsl:param name="generationDir" select=" 'src/' "/> <!--The C++ header extension to use --> <xsl:param name="headerExt" select=" '.h' "/> <!--The C++ source extension to use --> <xsl:param name="sourceExt" select=" '.C' "/> <!--Key to locate data types by name --> <xsl:key name="dataTypes" ...

Get XSLT Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.