December 2002
Intermediate to advanced
672 pages
16h 53m
English
You want to generate the switching code that will route incoming messages to their message handlers.
The message repository stores information about which processes receive which messages. Therefore, given a process name, you can generate a message switch that routes inbound messages to handlers:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:param name="process" select=" '*' "/> <xsl:variable name="message-dir" select=" 'messages' "/> <xsl:variable name="directory-sep" select=" '/' "/> <xsl:variable name="include-ext" select=" '.h' "/> <xsl:template match="MessageRepository"> <!-- Generate source file preliminaries --> <xsl:call-template name="file-start"/> <!-- Generate includes for messages this process recives --> <xsl:apply-templates select="Messages/ Message[Receivers/ ProcessRef = $process or $process = '*']" mode="includes"/> <!-- Generate message switch preliminaries --> <xsl:call-template name="switch-start"/> <!-- Generate switch body --> <xsl:apply-templates select="Messages/ Message[Receivers/ ProcessRef = $process or $process = '*']" mode="switch"/> <!-- Generate switch end --> <xsl:call-template name="switch-end"/> <!-- Generate file end --> <xsl:call-template name="file-end"/> </xsl:template> <!-- Generate an include for each message --> <xsl:template match="Message" mode="includes"> <xsl:text>#include <</xsl:text> ...
Read now
Unlock full access