<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/snf">
      <html>
          <head>
              <link href="snf-configuration.css" rel="stylesheet" type="text/css"/> 
              <title> Message Sniffer Configuration </title> 
          </head> 
          <body>
              <div class="banner">
                  Message Sniffer Configuration
              </div>
              <xsl:apply-templates/>
          </body>
      </html>
    </xsl:template> 

    <xsl:template match="node">
        <div class="section node">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/index.jsp">
                    Node
                </a>
            </div>
            <div class="section-item">
                <table>
                    <xsl:if test="@identity">
                        <xsl:call-template name="line-item">
                            <xsl:with-param name="label" select="'Identity File:'"/>
                            <xsl:with-param name="value" select="@identity"/>
                        </xsl:call-template>
                    </xsl:if>
                    <xsl:if test="@licenseid">
                        <xsl:call-template name="line-item">
                            <xsl:with-param name="label" select="'License ID:'"/>
                            <xsl:with-param name="value" select="@licenseid"/>
                        </xsl:call-template>
                    </xsl:if>
                    <xsl:if test="@authentication">
                        <xsl:call-template name="line-item">
                            <xsl:with-param name="label" select="'Authentication:'"/>
                            <xsl:with-param name="value" select="@authentication"/>
                        </xsl:call-template>
                    </xsl:if>
                </table>
            </div>
        </div>
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="paths">
        <div class="section paths">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/paths/index.jsp">
                Paths
                </a>
            </div>
            <table class="sub-section">
                <xsl:call-template name="line-item">
                    <xsl:with-param name="label" select="'Log Directory:'"/>
                    <xsl:with-param name="value" select="log/@path"/>
                </xsl:call-template>
                <xsl:call-template name="line-item">
                    <xsl:with-param name="label" select="'Rulebase Directory:'"/>
                    <xsl:with-param name="value" select="rulebase/@path"/>
                </xsl:call-template>
                <xsl:call-template name="line-item">
                    <xsl:with-param name="label" select="'Workspace Directory:'"/>
                    <xsl:with-param name="value" select="workspace/@path"/>
                </xsl:call-template>
            </table> 
        </div>
    </xsl:template>

    <xsl:template match="logs">
        <div class="section logs">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/logs">
                    Logs
                </a>
            </div>
            <div class="section-item">
                <div class="section-label">
                    <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/logs/rotation.jsp">
                        Rotation Timing
                    </a>
                </div>
                <div class="section-item">
                    <table>
                        <xsl:call-template name="line-item">
                            <xsl:with-param name="label" select="'Use Local Time To Rotate Logs:'"/>
                            <xsl:with-param name="value" select="rotation/@localtime"/>
                        </xsl:call-template>
                    </table>
                </div>
            </div>
            <div class="section-item">
                <div class="section-label">
                    <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/logs/status">
                        Status Data
                    </a>
                </div>
                <div class="sub-section">
                    <table style="border-collapse: collapse;" class="chart">
                        <tr class="chart-header">
                            <td class="chart-header">
                                Data Class
                            </td>
                            <td class="chart-header">
                                Generate
                            </td>
                            <td class="chart-header">
                                Append
                            </td>
                        </tr>
                        <tr>
                            <td class="chart-label">
                                Per Second
                            </td>
                            <xsl:call-template name="chart-on-off-cell">
                                <xsl:with-param name="value" select="status/second/@log"/>
                            </xsl:call-template>
                            <xsl:call-template name="chart-on-off-cell">
                                <xsl:with-param name="value" select="status/second/@append"/>
                            </xsl:call-template>
                        </tr>
                        <tr>
                            <td class="chart-label">
                                Per Minute
                            </td>
                            <xsl:call-template name="chart-on-off-cell">
                                <xsl:with-param name="value" select="status/minute/@log"/>
                            </xsl:call-template>
                            <xsl:call-template name="chart-on-off-cell">
                                <xsl:with-param name="value" select="status/minute/@append"/>
                            </xsl:call-template>
                        </tr>
                        <tr>
                            <td class="chart-label">
                                Per Hour
                            </td>
                            <xsl:call-template name="chart-on-off-cell">
                                <xsl:with-param name="value" select="status/hour/@log"/>
                            </xsl:call-template>
                            <xsl:call-template name="chart-on-off-cell">
                                <xsl:with-param name="value" select="status/hour/@append"/>
                            </xsl:call-template>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="section-item">
                <div class="section-label">
                    <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/logs/scan">
                        Scan Data
                    </a>
                </div>
                <div class="sub-section">
                    <div class="section-label">
                        <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/logs/scan/identifier.jsp">
                            Message Identification
                        </a>
                    </div>
                    <div class="section-item">
                        <table>
                            <xsl:call-template name="line-item">
                                <xsl:with-param name="label" select="'Extract Message-ID For Log Entries:'"/>
                                <xsl:with-param name="value" select="scan/identifier/@force-message-id"/>
                            </xsl:call-template>
                        </table>
                    </div>
                    <div class="section-label">
                        <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/logs/scan/classic.jsp">
                            Classic Log File
                        </a>
                    </div>
                    <div class="section-item">
                        <table>
                            <xsl:call-template name="line-item">
                                <xsl:with-param name="label" select="'Output Mode:'"/>
                                <xsl:with-param name="value" select="scan/classic/@mode"/>
                            </xsl:call-template>
                            <xsl:call-template name="line-item">
                                <xsl:with-param name="label" select="'Rotate By Date:'"/>
                                <xsl:with-param name="value" select="scan/classic/@rotate"/>
                            </xsl:call-template>
                            <xsl:call-template name="line-item">
                                <xsl:with-param name="label" select="'Log Pattern Matches:'"/>
                                <xsl:with-param name="value" select="scan/classic/@matches"/>
                            </xsl:call-template>
                        </table>
                    </div>
                    <div class="section-label">
                        <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/logs/scan/xml.jsp">
                            XML Log File
                        </a>
                    </div>
                    <div class="section-item">
                        <table>
                            <xsl:call-template name="line-item">
                                <xsl:with-param name="label" select="'Output Mode:'"/>
                                <xsl:with-param name="value" select="scan/xml/@mode"/>
                            </xsl:call-template>
                            <xsl:call-template name="line-item">
                                <xsl:with-param name="label" select="'Rotate By Date:'"/>
                                <xsl:with-param name="value" select="scan/xml/@rotate"/>
                            </xsl:call-template>
                            <xsl:call-template name="line-item">
                                <xsl:with-param name="label" select="'Log Pattern Matches:'"/>
                                <xsl:with-param name="value" select="scan/xml/@matches"/>
                            </xsl:call-template>
                            <xsl:call-template name="line-item">
                                <xsl:with-param name="label" select="'Log Performance Data:'"/>
                                <xsl:with-param name="value" select="scan/xml/@performance"/>
                            </xsl:call-template>
                            <xsl:call-template name="line-item">
                                <xsl:with-param name="label" select="'Log GBUdb Data:'"/>
                                <xsl:with-param name="value" select="scan/xml/@gbudb"/>
                            </xsl:call-template>
                        </table>
                    </div>
                    <div class="section-label">
                        <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/logs/scan/xheaders">
                            X-Header Generation
                        </a>
                    </div>
                    <div class="section-item">
                        <table>
                            <xsl:call-template name="line-item">
                                <xsl:with-param name="label" select="'Output Mode:'"/>
                                <xsl:with-param name="value" select="scan/xheaders/output/@mode"/>
                            </xsl:call-template>
                        </table>
                    </div>
                    <div class="sub-section">
                        <table style="border-collapse: collapse;" class="chart xhdr-chart">
                            <tr class="chart-header">
                                <td colspan="3" class="item-label">
                                    Scanner Data
                                </td>
                            </tr>
                            <xsl:call-template name="xhdr-chart-header"/>
                            <xsl:call-template name="xhdr-chart-line">
                                <xsl:with-param name="path" select="scan/xheaders/version"/>
                                <xsl:with-param name="description" select="'Software Version'"/>
                            </xsl:call-template>
                            <xsl:call-template name="xhdr-chart-line">
                                <xsl:with-param name="path" select="scan/xheaders/license"/>
                                <xsl:with-param name="description" select="'SNF License ID'"/>
                            </xsl:call-template>
                            <xsl:call-template name="xhdr-chart-line">
                                <xsl:with-param name="path" select="scan/xheaders/rulebase"/>
                                <xsl:with-param name="description" select="'Rulebase Timestamp'"/>
                            </xsl:call-template>
                        </table>
                    </div>
                    <div class="sub-section">
                        <table style="border-collapse: collapse;" class="chart xhdr-chart">
                            <tr class="chart-header">
                                <td colspan="3" class="item-label">
                                    Scan Details
                                </td>
                            </tr>
                            <xsl:call-template name="xhdr-chart-header"/>
                            <xsl:call-template name="xhdr-chart-line">
                                <xsl:with-param name="path" select="scan/xheaders/identifier"/>
                                <xsl:with-param name="description" select="'Message Identifier'"/>
                            </xsl:call-template>
                            <xsl:call-template name="xhdr-chart-line">
                                <xsl:with-param name="path" select="scan/xheaders/gbudb"/>
                                <xsl:with-param name="description" select="'GBUdb Analysis'"/>
                            </xsl:call-template>
                            <xsl:call-template name="xhdr-chart-line">
                                <xsl:with-param name="path" select="scan/xheaders/result"/>
                                <xsl:with-param name="description" select="'Result Code'"/>
                            </xsl:call-template>
                            <xsl:call-template name="xhdr-chart-line">
                                <xsl:with-param name="path" select="scan/xheaders/matches"/>
                                <xsl:with-param name="description" select="'Rule Matches'"/>
                            </xsl:call-template>
                        </table>
                    </div>
                    <div class="sub-section">
                        <table style="border-collapse: collapse;" class="chart xhdr-chart">
                            <tr class="chart-header">
                                <td colspan="3" class="item-label">
                                    Basic Result Signals
                                </td>
                            </tr>
                            <xsl:call-template name="xhdr-chart-header"/>
                            <xsl:call-template name="xhdr-chart-line">
                                <xsl:with-param name="path" select="scan/xheaders/black"/>
                                <xsl:with-param name="description" select="'Black (spam/malware)'"/>
                            </xsl:call-template>
                            <xsl:call-template name="xhdr-chart-line">
                                <xsl:with-param name="path" select="scan/xheaders/white"/>
                                <xsl:with-param name="description" select="'White (White Rule)'"/>
                            </xsl:call-template>
                            <xsl:call-template name="xhdr-chart-line">
                                <xsl:with-param name="path" select="scan/xheaders/clean"/>
                                <xsl:with-param name="description" select="'Clean (No Match)'"/>
                            </xsl:call-template>
                        </table>
                    </div>
                    <div class="sub-section">
                        <table style="border-collapse: collapse;" class="chart xhdr-chart">
                            <tr class="chart-header">
                                <td colspan="3" class="item-label">
                                    Result Code Signals
                                </td>
                            </tr>
                            <xsl:call-template name="xhdr-chart-header"/>
                            <xsl:apply-templates select="scan/xheaders/symbol"/>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </xsl:template>
    
    <xsl:template match="symbol">
        <xsl:variable name="code" select="@n"/>
        <xsl:call-template name="xhdr-chart-line">
            <xsl:with-param name="path" select="."/>
            <xsl:with-param name="description" select="concat('Result Code [',$code,']')"/>
        </xsl:call-template>
    </xsl:template>
    
    <xsl:template name="xhdr-chart-header">
        <tr class="chart-header">
            <td class="chart-header xhdr-col1">
                Information Provided
            </td>
            <td class="chart-header xhdr-col2">
                On/Off
            </td>
            <td class="chart-header xhdr-col3">
                X-Header Field Name
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="xhdr-chart-line">
        <xsl:param name="path"/>
        <xsl:param name="description"/>
        <tr>
            <td class="chart-label">
                <xsl:value-of select="$description"/>
            </td>
            <xsl:call-template name="chart-on-off-cell">
                <xsl:with-param name="value" select="$path/@on-off"/>
            </xsl:call-template>
            <td class="chart-value">
                <xsl:value-of select="$path"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="on-off-switch">
        <xsl:param name="value"/>
        <xsl:variable name="vlower" select="translate($value,'YESONTRU','yesontru')"/>
        <xsl:choose>
            <xsl:when test="$vlower = 'on'">on</xsl:when> 
            <xsl:when test="$vlower = 'yes'">on</xsl:when> 
            <xsl:when test="$vlower = 'true'">on</xsl:when> 
            <xsl:otherwise>off</xsl:otherwise> 
        </xsl:choose> 
    </xsl:template>

    <xsl:template name="chart-on-off-cell">
        <xsl:param name="value"/>
        <xsl:variable name="switch">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="$value"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$switch = 'on'">
                <td class="chart-value oncolor">
                    <xsl:value-of select="$value"/>
                </td>
            </xsl:when>
            <xsl:otherwise>
                <td class="chart-value offcolor">
                    <xsl:value-of select="$value"/>
                </td>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="line-item">
        <xsl:param name="label"/>
        <xsl:param name="value"/>
        <tr>
            <td class="item-label">
                <xsl:value-of select="$label"/>
            </td>
            <td class="item-value">
                <xsl:value-of select="$value"/> 
            </td> 
        </tr> 
    </xsl:template>

    <xsl:template match="network">
        <div class="section network">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/network">
                    Network
                </a>
            </div>
            <div class="section-item">
                <div class="section-label">
                    <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/network/sync.jsp">
                        SNF Node Synchronization
                    </a>
                </div>
                <div class="section-item">
                    <table>
                        <xsl:call-template name="line-item">
                            <xsl:with-param name="label" select="'Retry Secs:'"/>
                            <xsl:with-param name="value" select="sync/@secs"/>
                        </xsl:call-template>
                        <xsl:call-template name="line-item">
                            <xsl:with-param name="label" select="'SYNC Host:'"/>
                            <xsl:with-param name="value" select="sync/@host"/>
                        </xsl:call-template>
                        <xsl:call-template name="line-item">
                            <xsl:with-param name="label" select="'SYNC Port:'"/>
                            <xsl:with-param name="value" select="sync/@port"/>
                        </xsl:call-template>
                    </table>
                </div>
            </div>
            <div class="section-item">
                <div class="section-label">
                    <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/network/update-script.jsp">
                        Automated Rulebase Updates
                    </a>
                </div>
                <div class="section-item">
                    <table>
                        <xsl:call-template name="line-item">
                            <xsl:with-param name="label" select="'Automated Update-Script:'"/>
                            <xsl:with-param name="value" select="update-script/@on-off"/>
                        </xsl:call-template>
                        <xsl:call-template name="line-item">
                            <xsl:with-param name="label" select="'Update-Script Path:'"/>
                            <xsl:with-param name="value" select="update-script/@call"/>
                        </xsl:call-template>
                        <xsl:call-template name="line-item">
                            <xsl:with-param name="label" select="'Guard Time Secs:'"/>
                            <xsl:with-param name="value" select="update-script/@guard-time"/>
                        </xsl:call-template>
                    </table>
                </div>
            </div>
        </div>
    </xsl:template>

    <xsl:template match="xci">
        <div class="section xci">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/xci.jsp">
                    XCI
                </a>
            </div>
            <div class="section-item">
                <table>
                    <xsl:call-template name="line-item">
                        <xsl:with-param name="label" select="'XCI Interface:'"/>
                        <xsl:with-param name="value" select="@on-off"/>
                    </xsl:call-template>
                    <xsl:call-template name="line-item">
                        <xsl:with-param name="label" select="'XCI Listener Port:'"/>
                        <xsl:with-param name="value" select="@port"/>
                    </xsl:call-template>
                </table>
            </div>
        </div>
    </xsl:template>

    <xsl:template match="gbudb">
        <div class="section gbudb">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb">
                    GBUdb
                </a>
            </div>
            <xsl:apply-templates/>
        </div>
    </xsl:template>

    <xsl:template match="gbudb/database">
        <div class="sub-section">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb">
                    Database Maintenance
                </a>
            </div>
            <div class="section-item">
                <table>
                    <xsl:apply-templates/>
                </table>
            </div>
        </div>
    </xsl:template>

    <xsl:template match="database/condense">
        <tr>
            <td class="item-label">
                Condensation Guard Time (secs):
            </td>
            <td class="item-value">
                <xsl:value-of select="@minimum-seconds-between"/>
            </td>
        </tr>
        <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="condense/time-trigger">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="condense-time-trigger-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="condense-time-trigger-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="condense-time-trigger-on">
        <tr>
            <td class="item-label">
                Trigger Condensation After (secs):
            </td>
            <td class="item-value">
                <xsl:value-of select="@seconds"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="condense-time-trigger-off">
        <tr>
            <td class="item-label">
                Condensation Time Trigger Disabled
            </td>
            <td class="item-value"/>
        </tr>
    </xsl:template>

    <xsl:template match="condense/posts-trigger">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="condense-posts-trigger-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="condense-posts-trigger-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="condense-posts-trigger-on">
        <tr>
            <td class="item-label">
                Trigger Condensation After (posts):
            </td>
            <td class="item-value">
                <xsl:value-of select="@posts"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="condense-posts-trigger-off">
        <tr>
            <td class="item-label">
                Condensation Posts Trigger Disabled
            </td>
            <td class="item-value"/>
        </tr>
    </xsl:template>

    <xsl:template match="condense/records-trigger">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="condense-records-trigger-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="condense-records-trigger-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="condense-records-trigger-on">
        <tr>
            <td class="item-label">
                Trigger Condensation At (records):
            </td>
            <td class="item-value">
                <xsl:value-of select="@records"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="condense-records-trigger-off">
        <tr>
            <td class="item-label">
                Condensation Records Trigger Disabled
            </td>
            <td class="item-value"/>
        </tr>
    </xsl:template>

    <xsl:template match="condense/size-trigger">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="condense-size-trigger-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="condense-size-trigger-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="condense-size-trigger-on">
        <tr>
            <td class="item-label">
                Trigger Condensation At (megabytes):
            </td>
            <td class="item-value">
                <xsl:value-of select="@megabytes"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="condense-size-trigger-off">
        <tr>
            <td class="item-label">
                Condensation Size Trigger Disabled
            </td>
            <td class="item-value"/>
        </tr>
    </xsl:template>

    <xsl:template match="database/checkpoint">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="checkpoint-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="checkpoint-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="checkpoint-on">
        <tr>
            <td class="item-label">
                Save Checkpoint Every (secs):
            </td>
            <td class="item-value">
                <xsl:value-of select="@secs"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="checkpoint-off">
        <tr>
            <td class="item-label">
                Save Checkpoint Disabled
            </td>
            <td class="item-value"/>
        </tr>
    </xsl:template>

    <xsl:template match="gbudb/regions">
        <div class="sub-section">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/">
                    Reputation Evaluation Regions
                </a>
            </div>
            <div class="section-item">
                <table>
                    <xsl:apply-templates select="white"/>
                    <xsl:apply-templates select="caution"/>
                    <xsl:apply-templates select="black"/>
                </table>
            </div>
        </div>
    </xsl:template>

    <xsl:template match="regions/white">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="white-region-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="white-region-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="white-region-off">
        <tr>
            <td class="item-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/white.jsp">
                    White Region Disabled
                </a>
            </td> 
            <td class="item-value"/> 
        </tr>
    </xsl:template>

    <xsl:template name="white-region-on">
        <tr>
            <td colspan="2" class="chart-value">
                <table>
                    <tr>
                        <td class="item-label">
                            <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/white.jsp">
                                White Region Symbol:
                            </a>
                        </td>
                        <td class="item-value">
                            <xsl:value-of select="@symbol"/>
                        </td>
                    </tr>
                    <xsl:call-template name="edges"/>
                    <tr><td colspan="2"><hr/></td></tr> 
                    <xsl:apply-templates select="panic"/>
                </table>
            </td>
        </tr>
    </xsl:template>

    <xsl:template match="white/panic">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="white-panic-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="white-panic-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="white-panic-on">
        <tr>
            <td class="item-label">
                Auto-Panic Rule Range:
            </td>
            <td class="item-value">
                <xsl:value-of select="@rule-range"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="white-panic-off">
        <tr>
            <td class="item-label">
                Auto-Panic Disabled
            </td>
            <td class="item-value"/>
        </tr>
    </xsl:template>

    <xsl:template name="edges">
        <tr>
            <td colspan="2">
                <table style="border-collapse: collapse;">
                    <xsl:for-each select="edge">
                        <tr>
                            <td class="item-label">
                                Edge (probability, confidence):
                            </td>
                            <td class="chart-value">
                                <xsl:value-of select="@probability"/>
                            </td>
                            <td class="chart-value">
                                <xsl:value-of select="@confidence"/>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </td>
        </tr>
    </xsl:template>

    <xsl:template match="regions/caution">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="caution-region-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="caution-region-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="caution-region-off">
        <tr>
            <td class="item-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/caution.jsp">
                    Caution Region Disabled
                </a>
            </td>
            <td class="item-value"/> 
        </tr>
    </xsl:template>

    <xsl:template name="caution-region-on">
        <tr>
            <td colspan="2" class="chart-value">
                <table>
                    <tr>
                        <td class="item-label">
                            <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/caution.jsp">
                                Caution Region Symbol:
                            </a>
                        </td>
                        <td class="item-value">
                            <xsl:value-of select="@symbol"/>
                        </td>
                    </tr>
                    <xsl:call-template name="edges"/>
                </table>
            </td>
        </tr>
    </xsl:template>

    <xsl:template match="regions/black">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="black-region-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="black-region-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="black-region-off">
        <tr>
            <td class="item-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/black.jsp">
                    Black Region Disabled
                </a>
            </td>
            <td class="item-value"/> 
        </tr>
    </xsl:template>

    <xsl:template name="black-region-on">
        <tr>
            <td colspan="2" class="chart-value">
                <table>
                    <tr>
                        <td class="item-label">
                            <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/black.jsp">
                                 Black Region Symbol: 
                            </a>
                        </td>
                        <td class="item-value">
                            <xsl:value-of select="@symbol"/>
                        </td>
                    </tr>
                    <xsl:call-template name="edges"/>
                    <tr><td colspan="2"><hr/></td></tr>
                    <xsl:apply-templates select="truncate"/>
                    <xsl:apply-templates select="sample"/>
                </table>
            </td>
        </tr>
    </xsl:template>

    <xsl:template match="black/truncate">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="black-truncate-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="black-truncate-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="black-truncate-on">
        <tr>
            <td class="item-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/black-trucate.jsp">
                    Truncate Region Symbol:
                </a>
            </td>
            <td class="item-value">
                <xsl:value-of select="@symbol"/>
            </td>
        </tr>
        <tr>
            <td class="item-label">
                Truncate Minimum Probability:
            </td>
            <td class="item-value">
                <xsl:value-of select="@probability"/>
            </td>
        </tr>
        <tr>
            <td class="item-label">
                Peek Inside One Truncate Out Of:
            </td>
            <td class="item-value">
                <xsl:value-of select="@peek-one-in"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="black-truncate-off">
        <tr>
            <td class="item-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/black-trucate.jsp">
                    Truncate Region Disabled
                </a>
            </td>
            <td class="item-value"/>
        </tr>
    </xsl:template>

    <xsl:template match="black/sample">
        <xsl:variable name="on-off">
            <xsl:call-template name="on-off-switch">
                <xsl:with-param name="value" select="@on-off"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$on-off = 'on'">
                <xsl:call-template name="black-sample-on"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="black-sample-off"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="black-sample-on">
        <tr><td colspan="2"><hr/></td></tr> 
        <tr>
            <td class="item-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/black-sample.jsp">
                    Sampling Minimum Probability:
                </a>
            </td>
            <td class="item-value">
                <xsl:value-of select="@probability"/>
            </td>
        </tr>
        <tr>
            <td class="item-label">
                Sampling Grabs One Out Of:
            </td>
            <td class="item-value">
                <xsl:value-of select="@grab-one-in"/>
            </td>
        </tr>
        <tr>
            <td class="item-label">
                Use Passthrough Sampling:
            </td>
            <td class="item-value">
                <xsl:value-of select="@passthrough"/>
            </td>
        </tr>
        <tr>
            <td class="item-label">
                Passthrough Symbol:
            </td>
            <td class="item-value">
                <xsl:value-of select="@passthrough-symbol"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="black-sample-off">
        <tr>
            <td class="item-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/regions/black-sample.jsp">
                    Message Sampling Is Disabled
                </a>
            </td>
            <td class="item-value"/>
        </tr>
    </xsl:template>

    <xsl:template match="gbudb/training">
        <div class="sub-section">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/training/">
                    Automated Training
                </a>
            </div>
            <div class="sub-section">
                <xsl:apply-templates select="bypass"/>
                <xsl:apply-templates select="drilldown"/>
                <xsl:apply-templates select="source"/>
                <xsl:apply-templates select="white"/>
            </div>
        </div>
    </xsl:template>

    <xsl:template match="training/bypass">
        <div class="section-label">
            <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/training/bypass.jsp">
                Bypass Directives
            </a>
        </div>
    </xsl:template>

    <xsl:template match="training/bypass">
        <div class="section-label">
            <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/training/bypass.jsp">
                Bypass Directives
            </a>
        </div>
        <xsl:apply-templates select="header"/>
    </xsl:template>

    <xsl:template match="bypass/header">
        <div class="section-item">
            <table>
                <tr>
                    <td class="chart-label">
                        Bypass GBUdb if header
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@name"/>
                    </td>
                    <xsl:if test="@ordinal">
                        <td class="chart-label">
                            at ordinal
                        </td>
                        <td class="chart-value">
                            <xsl:value-of select="@ordinal"/>
                        </td>
                    </xsl:if>
                    <td class="chart-label">
                        contains
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@find"/>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template match="training/drilldown">
        <div class="section-label">
            <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/training/drilldown.jsp">
                Drill-Down Directives
            </a>
        </div>
        <xsl:apply-templates select="received"/>
    </xsl:template>

    <xsl:template match="drilldown/received">
        <div class="section-item">
            <table>
                <tr>
                    <td class="chart-label">
                        Ignore Received at ordinal
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@ordinal"/>
                    </td>
                    <td class="chart-label">
                        if we find
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@find"/>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template match="training/source">
        <div class="section-label">
            <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/training/source.jsp">
                Message Source Directives
            </a>
        </div>
        <xsl:apply-templates select="header"/>
    </xsl:template>

    <xsl:template match="source/header">
        <div class="section-item">
            <table>
                <tr>
                    <td class="chart-label">
                        Use Source Header
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@name"/>
                    </td>
                    <td class="chart-label">
                        if we find
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@received"/>
                    </td>
                    <td class="chart-label">
                        in Received at ordinal
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@ordinal"/>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template match="training/white">
        <div class="section-label">
            <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/gbudb/training/white.jsp">
                Treat As White Directives
            </a>
        </div>
        <xsl:apply-templates select="result"/>
        <xsl:apply-templates select="header"/>
    </xsl:template>

    <xsl:template match="white/result">
        <div class="section-item">
            <table>
                <tr>
                    <td class="chart-label">
                        Record a good event for result code
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@code"/>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template match="white/header">
        <div class="section-item">
            <table>
                <tr>
                    <td class="chart-label">
                        Record a good event if header
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@name"/>
                    </td>
                    <xsl:if test="@ordinal">
                        <td class="chart-label">
                            at ordinal
                        </td>
                        <td class="chart-value">
                            <xsl:value-of select="@ordinal"/>
                        </td>
                    </xsl:if>
                    <td class="chart-label">
                        contains
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@find"/>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template match="rule-panics">
        <div class="section rule-panics">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/rule-panics.jsp">
                    Rule Panics
                </a>
            </div>
            <div class="section-item">
                <xsl:apply-templates/>
            </div>
        </div>
    </xsl:template>

    <xsl:template match="rule-panics/rule">
        <xsl:value-of select="@id"/><br/>
    </xsl:template>

    <xsl:template match="platform">
        <div class="section platform">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/platform.jsp">
                    Platform
                </a>
            </div>
            <xsl:apply-templates/>
        </div>
    </xsl:template>

    <xsl:template match="platform/mdaemon">
        <div class="sub-section">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/mDaemonPlugin/">
                    Message Sniffer Plugin for MDaemon
                </a>
            </div>
            <xsl:apply-templates select="ip-test"/>
            <xsl:apply-templates select="configurator"/>
        </div>
    </xsl:template>

    <xsl:template match="mdaemon/ip-test">
        <div class="section-item">
            <table>
                <tr>
                    <td class="chart-label">
                        Reject IPs during SMTP
                    </td>
                    <xsl:call-template name="chart-on-off-cell">
                        <xsl:with-param name="value" select="@on-off"/>
                    </xsl:call-template>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template match="mdaemon/configurator">
        <div class="section-item">
            <table>
                <tr>
                    <td class="chart-label">
                        Configurator Command
                    </td>
                    <td class="chart-value">
                        <xsl:value-of select="@command"/>
                    </td>
                    <td class="chart-label">
                        Append Configuration Path
                    </td>
                    <xsl:call-template name="chart-on-off-cell">
                        <xsl:with-param name="value" select="@append-path"/>
                    </xsl:call-template>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template match="platform/snf4cgp">
        <div class="sub-section">
            <div class="section-label">
                <a href="http://www.armresearch.com/products/SNF4CGP.jsp">
                    Message Sniffer For CommuniGate Pro
                </a>
            </div>
            <div class="section-item">
                <table style="border-collapse: collapse;" class="chart">
                    <xsl:apply-templates select="ham"/>
                    <tr><td colspan="8"><br/></td></tr> 
                    <xsl:apply-templates select="spam"/>
                </table>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="snf4cgp-column-names">
        <tr>
            <td class="chart-header">
                Code
            </td>
            <td class="chart-header">
                Action
            </td>
            <td class="chart-header">
                Reason
            </td>
            <td class="chart-header">
                Comment
            </td>
            <td class="chart-header">
                Headers
            </td>
            <td class="chart-header">
                Classic
            </td>
            <td class="chart-header">
                XML
            </td>
            <td class="chart-header">
                Hold Path
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="snf4cgp/ham">
        <tr>
            <td colspan="8" class="chart-header">
                Settings For Good Message Scan Results (ham)
            </td>
        </tr>
        <xsl:call-template name="snf4cgp-column-names"/>
        <xsl:call-template name="snf4cgp-row-data"/>
        <xsl:for-each select="result">
            <xsl:call-template name="snf4cgp-row-data"/>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="snf4cgp/spam">
        <tr>
            <td colspan="8" class="chart-header">
                Settings For Bad Message Scan Results (spam)
            </td>
        </tr>
        <xsl:call-template name="snf4cgp-column-names"/>
        <xsl:call-template name="snf4cgp-row-data"/>
        <xsl:for-each select="result">
            <xsl:call-template name="snf4cgp-row-data"/>
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="snf4cgp-row-data">
        <tr>
            <td class="chart-label">
                <xsl:if test="@code">
                    <xsl:value-of select="@code"/>
                </xsl:if>
                <xsl:if test="name()='ham'">
                    *
                </xsl:if>
                <xsl:if test="name()='spam'">
                    *
                </xsl:if>
            </td>
            <xsl:choose>
                <xsl:when test="@action">
                    <td class="chart-value">
                        <xsl:value-of select="@action"/>
                    </td>
                </xsl:when>
                <xsl:otherwise>
                    <td class="chart-value notset"/>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:choose>
                <xsl:when test="@reason">
                    <td class="chart-value">
                        <xsl:value-of select="@reason"/>
                    </td>
                </xsl:when>
                <xsl:otherwise>
                    <td class="chart-value notset"/>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:choose>
                <xsl:when test="@comment">
                    <td class="chart-value">
                        <xsl:value-of select="@comment"/>
                    </td>
                </xsl:when>
                <xsl:otherwise>
                    <td class="chart-value notset"/>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:choose>
                <xsl:when test="@headers">
                    <xsl:call-template name="chart-on-off-cell">
                        <xsl:with-param name="value" select="@headers"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <td class="chart-value notset"/>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:choose>
                <xsl:when test="@classic">
                    <xsl:call-template name="chart-on-off-cell">
                        <xsl:with-param name="value" select="@classic"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <td class="chart-value notset"/>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:choose>
                <xsl:when test="@xml">
                    <xsl:call-template name="chart-on-off-cell">
                        <xsl:with-param name="value" select="@xml"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <td class="chart-value notset"/>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:choose>
                <xsl:when test="@hold-path">
                    <td class="chart-value">
                        <xsl:value-of select="@hold-path"/>
                    </td>
                </xsl:when>
                <xsl:otherwise>
                    <td class="chart-value notset"/>
                </xsl:otherwise>
            </xsl:choose>
        </tr>
    </xsl:template>
    
    <xsl:template match="platform/milter">
        <div class="sub-section">
            <div class="section-label">
                <a href="http://www.armresearch.com/products/SNFMilter.jsp">
                    Message Sniffer Milter For Sendmail / Postfix
                </a>
            </div>
            <div class="section-item">
                <table>
                    <tr>
                        <td class="item-label">
                            Milter Socket Type:
                        </td>
                        <td class="item-value">
                            <xsl:value-of select="socket/@type"/>
                        </td>
                    </tr>
                    <xsl:if test="socket/@type = 'unix'">
                        <tr>
                            <td class="item-label">
                                Socket Path:
                            </td>
                            <td class="item-value">
                                <xsl:value-of select="socket/@path"/>
                            </td>
                        </tr>
                        <tr>
                            <td class="item-label">
                                Socket Group:
                            </td>
                            <td class="iteam-value">
                                <xsl:value-of select="socket/@group"/>
                            </td>
                        </tr>
                    </xsl:if>
                    <xsl:if test="socket/@type = 'tcp'">
                        <tr>
                            <td class="item-label">
                                Socket IP:
                            </td>
                            <td class="item-value">
                                <xsl:value-of select="socket/@ip"/>
                            </td>
                        </tr>
                        <tr>
                            <td class="item-label">
                                Socket Port:
                            </td>
                            <td class="iteam-value">
                                <xsl:value-of select="socket/@port"/>
                            </td>
                        </tr>
                    </xsl:if>
                </table>
            </div>
            <div class="section-item">
                <table style="border-collapse: collapse;" class="chart">
                    <xsl:apply-templates select="connect"/>
                    <tr><td colspan="2"><br/></td></tr> 
                    <xsl:apply-templates select="scan"/>
                </table>
            </div>
        </div>
    </xsl:template>

    <xsl:template match="milter/connect">
        <tr>
            <td colspan="2" class="chart-header">
                Connect-time Actions
            </td>
        </tr>
        <tr>
            <td class="chart-header">
                GBUdb Range
            </td>
            <td class="chart-header">
                Action
            </td>
        </tr>
        <xsl:if test="white">
            <tr>
                <td class="chart-value">
                    White
                </td>
                <td class="chart-value">
                    <xsl:value-of select="white/@action"/>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="caution">
            <tr>
                <td class="chart-value">
                    Caution
                </td>
                <td class="chart-value">
                    <xsl:value-of select="caution/@action"/>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="black">
            <tr>
                <td class="chart-value">
                    Black
                </td>
                <td class="chart-value">
                    <xsl:value-of select="black/@action"/>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="truncate">
            <tr>
                <td class="chart-value">
                    Truncate
                </td>
                <td class="chart-value">
                    <xsl:value-of select="truncate/@action"/>
                </td>
            </tr>
        </xsl:if>
    </xsl:template>

    <xsl:template match="milter/scan">
        <tr>
            <td colspan="2" class="chart-header">
                Scan-time Actions
            </td>
        </tr>
        <tr>
            <td class="chart-header">
                Scan Result
            </td>
            <td class="chart-header">
                Action
            </td>
        </tr>
        <xsl:if test="nonzero">
            <tr>
                <td class="chart-value">
                    Nonzero
                </td>
                <td class="chart-value">
                    <xsl:value-of select="nonzero/@action"/>
                </td>
            </tr>
        </xsl:if>
        <xsl:apply-templates select="result"/>
    </xsl:template>

    <xsl:template match="milter/scan/result">
        <tr>
            <td class="chart-value">
                <xsl:value-of select="@code"/>
            </td>
            <td class="chart-value">
                <xsl:value-of select="@action"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template match="msg-file">
        <div class="section msg-file">
            <div class="section-label">
                <a href="http://www.armresearch.com/support/articles/software/snfServer/config/node/msg-file.jsp">
                    Message Format
                </a>
            </div>
            <div class="section-item">
                <table>
                    <xsl:call-template name="line-item">
                        <xsl:with-param name="label" select="'Message Data Type:'"/>
                        <xsl:with-param name="value" select="@type"/>
                    </xsl:call-template>
                </table>
            </div>
        </div>
    </xsl:template>

</xsl:stylesheet> 

