Generating a Test Data-Entry Web Client
Problem
You want to test a process in isolation by entering information in a form and having the information converted into a message that is sent to a process.
Solution
This example generates a test data-entry tool’s client side. It takes the shape of an HTML-based form that can be used to enter the fields that make up a message. It specifies that the form data be handled by a CGI that is generated in Recipe 10.7:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" /> <xsl:param name="message"/> <!--Key to locate data types by name --> <xsl:key name="dataTypes" match="Structure" use="Name" /> <xsl:key name="dataTypes" match="Primitive" use="Name" /> <xsl:key name="dataTypes" match="Array" use="Name" /> <xsl:key name="dataTypes" match="Enumeration" use="Name" /> <xsl:template match="/"> <html> <head> <title><xsl:value-of select="$message"/> Entry</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <h1><xsl:value-of select="$message"/> Entry</h1> <form name="{concat($message,'Form')}" method="post" action="{concat('/cgi-bin/',$message,'Process.pl')}"> <xsl:apply-templates select="*/Messages/Message[Name=$message]"/> <br/><center><input type="submit" name="Submit" value="Submit"/></center> </form> </body> </html> </xsl:template> <xsl:template match="Message"> <xsl:apply-templates select="key('dataTypes',DataTypeName)"> <xsl:with-param name="field" select="Name"/> </xsl:apply-templates> ...
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.