<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mostco="http://www.mostcooperation.com" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:exslt="http://exslt.org/common" version="1.0" exclude-result-prefixes="msxsl exslt mostco xs">
        
<xsl:output method="html" indent="yes" encoding="utf-8" omit-xml-declaration="no" version="3.2" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" doctype-system="http://www.w3.org/TR/html4/loose.dtd" />
        
<!-- Modification date: 2015-10-30; based on FCat Schema 3.1.0.10 -->
        
<!-- The Unit, Exponent, and Step attributes have become optional with a default value. To always display them, the value has to be obtained from the Schema definition, which is a bit tedious -->
        
<xsl:variable name="fcatschema" select="document('mostfcat_3_1_0.xsd')" />
        
<xsl:variable name="default-unit" select="$fcatschema//xs:complexType[@name='Number']//xs:attribute[@name='Unit']/@default" />
        
<xsl:variable name="default-step" select="$fcatschema//xs:complexType[@name='Integer']//xs:attribute[@name='Step']/@default" />
        
<xsl:variable name="default-exponent" select="$fcatschema//xs:complexType[@name='Integer']//xs:attribute[@name='Exponent']/@default" />
        
<xsl:variable name="default-enum-size" select="$fcatschema//xs:complexType[@name='TEnum']//xs:attribute[@name='TotalByteLength']/@default" />
        
<xsl:variable name="default-bitlength" select="$fcatschema//xs:complexType[@name='BitBase']//xs:attribute[@name='BitLength']/@default" />
        
<!-- Key definitions -->
        
<!-- All parameter references, grouped by the Function element -->
        
<xsl:key name="parameter-references" match="mostco:ParameterReference" use="concat(generate-id(ancestor::mostco:Function),'::',@Name)" />
        
<!-- All stream parameter references, grouped by the Parameter element -->
        
<xsl:key name="stream-parameter-references" match="mostco:StreamParamReference|mostco:StreamParamReferenceRepeated" use="concat(generate-id((ancestor::*[self::mostco:TStream|self::mostco:TShortStream])[last()]),'::',@Name)" />
        
<!-- All parameters or shared parameter references, grouped by the Function element -->
        
<xsl:key name="parameter-definitions" match="mostco:Function/mostco:Parameters/mostco:Parameter|mostco:Function/mostco:Parameters/mostco:SharedParameterReference|mostco:Function/mostco:Parameters/mostco:NamedSharedParameterReference" use="concat(generate-id(ancestor::mostco:Function),'::',@Name)" />
        
<!-- All stream parameters, grouped by the Parameter element -->
        
<xsl:key name="stream-parameter-definitions" match="mostco:TStream/mostco:Parameters/mostco:Parameter|mostco:TShortStream/mostco:Parameters/mostco:Parameter|mostco:TStream/mostco:Parameters/mostco:SharedParameterReference|mostco:TShortStream/mostco:Parameters/mostco:SharedParameterReference|mostco:TStream/mostco:Parameters/mostco:NamedSharedParameterReference|mostco:TShortStream/mostco:Parameters/mostco:NamedSharedParameterReference" use="concat(generate-id((ancestor::*[self::mostco:TStream|self::mostco:TShortStream])[last()]),'::',@Name)" />
        
<!-- All shared parameter definitions. Those are grandchildren of the FunctionCatalog element -->
        
<xsl:key name="shared-parameter-definitions" match="mostco:SharedParameter" use="@Name" />
        
<!-- OPType lookup table. Used for sorting parameter descriptions and counting unique entries -->
        
<mostco:OPTypeNum name="Set">1</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="Get">2</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="SetGet">3</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="Increment">4</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="Decrement">5</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="Status">6</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="Start">7</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="Abort">8</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="StartResult">9</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="StartResultAck">10</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="AbortAck">11</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="StartAck">12</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="ErrorAck">13</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="ProcessingAck">14</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="Processing">15</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="Result">16</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="ResultAck">17</mostco:OPTypeNum>
        
<mostco:OPTypeNum name="Error">18</mostco:OPTypeNum>
        
<!-- Strip whitespace from element-only types in DTD; Speedup >30 %-->
        
<xsl:strip-space elements="FunctionCatalog CatalogVersion Modification FBlock FBlockVersion Function FunctionVersion FunctionClass Property Method TArray TArrayType TStream TShortStream TCStream StreamCase StreamParam TRecord TRecordType TRecordField TNumber Unit TBool BitValue TBitField TUByte TSByte TUWord TSWord TULong TULongLong TSLong TSLongLong TEnum TString" />
        
<!-- "Levels" loosely refer to minimum call depth to indicate on which tree depth the use of a template can be expected. The FunctionCatalog element is on Level 1, while, for example, Stream parameters can be expected on Level 6. -->
        
<!-- *** Level independent helper templates *** -->
        
<!-- Level-independent helper template: Repeat whatever parameter $output contains for $count times -->
        
<xsl:template name="repeat-output">
                
<xsl:param name="output" />
                
<xsl:param name="count" />
                
<xsl:value-of select="$output" />
                
<xsl:if test="$count &gt; 1">
                        
<xsl:call-template name="repeat-output">
                                
<xsl:with-param name="output" select="$output" />
                                
<xsl:with-param name="count" select="$count - 1" />
                        
</xsl:call-template>
                
</xsl:if>
        
</xsl:template>
        
<!-- Level-independent helper template: Convert a decimal value to a hexadecimal value -->
        
<xsl:template name="convert-dec-to-hex">
                
<xsl:param name="value" />
                
<xsl:if test="$value &gt; 0">
                        
<xsl:call-template name="convert-dec-to-hex">
                                
<xsl:with-param name="value" select="floor($value div 16)" />
                        
</xsl:call-template>
                        
<xsl:choose>
                                
<xsl:when test="$value mod 16 &lt; 10">
                                        
<xsl:value-of select="$value mod 16" />
                                
</xsl:when>
                                
<xsl:otherwise>
                                        
<xsl:choose>
                                                
<xsl:when test="$value mod 16 = 10">A</xsl:when>
                                                
<xsl:when test="$value mod 16 = 11">B</xsl:when>
                                                
<xsl:when test="$value mod 16 = 12">C</xsl:when>
                                                
<xsl:when test="$value mod 16 = 13">D</xsl:when>
                                                
<xsl:when test="$value mod 16 = 14">E</xsl:when>
                                                
<xsl:when test="$value mod 16 = 15">F</xsl:when>
                                                
<xsl:otherwise>A</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:otherwise>
                        
</xsl:choose>
                
</xsl:if>
        
</xsl:template>
        
<!-- Level-independent helper template: From a decimal value, create a hexadecimal value prefixed with "0x" -->
        
<xsl:template name="dec-to-hex">
                
<xsl:param name="value" />
                
<xsl:choose>
                        
<xsl:when test="$value &gt; 0">
                                
<xsl:text>0x</xsl:text>
                                
<!-- perform the actual conversion -->
                                
<xsl:call-template name="convert-dec-to-hex">
                                        
<xsl:with-param name="value" select="$value" />
                                
</xsl:call-template>
                        
</xsl:when>
                        
<xsl:otherwise>0x0</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- Level-independent helper template: From the (decimal) value parameter, create a hexadecimal value prefixed with "0x" a number of padding zeros, depending on the required number of digits (in parameter $digits). For example, FktID needs 3 hexadecimal digits -->
        
<xsl:template name="dec-to-hex-padded">
                
<xsl:param name="value" />
                
<xsl:param name="digits" />
                
<!-- determine the required number of padding bytes for the current value -->
                
<xsl:variable name="value-as-hex">
                        
<xsl:call-template name="convert-dec-to-hex">
                                
<xsl:with-param name="value" select="$value" />
                        
</xsl:call-template>
                
</xsl:variable>
                
<xsl:variable name="value-as-hex-digits" select="string-length($value-as-hex)" />
                
<xsl:variable name="required-padding-zeros" select="$digits - $value-as-hex-digits" />
                
<xsl:choose>
                        
<!-- only perform a conversion if the value is greater than 0 -->
                        
<xsl:when test="$value &gt; 0">
                                
<xsl:text>0x</xsl:text>
                                
<!-- the template will print at least one "0" so it must not be called for if none are required -->
                                
<xsl:if test="$required-padding-zeros &gt; 0">
                                        
<xsl:call-template name="repeat-output">
                                                
<xsl:with-param name="output" select="0" />
                                                
<xsl:with-param name="count" select="$required-padding-zeros" />
                                        
</xsl:call-template>
                                
</xsl:if>
                                
<!-- perform the actual conversion -->
                                
<xsl:call-template name="convert-dec-to-hex">
                                        
<xsl:with-param name="value" select="$value" />
                                
</xsl:call-template>
                        
</xsl:when>
                        
<xsl:otherwise>
                                
<xsl:text>0x</xsl:text>
                                
<!-- not testing if $required-padding-zeros is greater than 0 because one "0" is required anyway -->
                                
<xsl:call-template name="repeat-output">
                                        
<xsl:with-param name="output" select="0" />
                                        
<xsl:with-param name="count" select="$required-padding-zeros" />
                                
</xsl:call-template>
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- Level 5+ helper template: Determine the data type name of one parameter -->
        
<xsl:template mode="get-param-type-name" match="*">
                
<xsl:choose>
                        
<xsl:when test="self::mostco:TBitField">BitField</xsl:when>
                        
<xsl:when test="self::mostco:TBoolean">Boolean</xsl:when>                        
                        
<xsl:when test="self::mostco:TEnum">Enum</xsl:when>
                        
<xsl:when test="self::mostco:TString">String</xsl:when>
                        
<xsl:when test="self::mostco:TLengthCodedString">Length-coded String</xsl:when>
                        
<xsl:when test="self::mostco:TArrayLegacy">
                                
<xsl:apply-templates mode="class-array" select="." />
                        
</xsl:when>
                        
<xsl:when test="self::mostco:TArrayType">Array Type</xsl:when>
                        
<xsl:when test="self::mostco:TRecordLegacy">
                                
<xsl:apply-templates mode="class-record" select="." />
                        
</xsl:when>
                        
<xsl:when test="self::mostco:TRecordType">Record Type</xsl:when>
                        
<xsl:when test="self::mostco:TStream">Stream</xsl:when>
                        
<xsl:when test="self::mostco:TCStream">Classified Stream</xsl:when>
                        
<xsl:when test="self::mostco:TShortStream">Short Stream</xsl:when>
                        
<xsl:when test="self::mostco:TUByte">Unsigned Byte</xsl:when>
                        
<xsl:when test="self::mostco:TSByte">Signed Byte</xsl:when>
                        
<xsl:when test="self::mostco:TUWord">Unsigned Word</xsl:when>
                        
<xsl:when test="self::mostco:TSWord">Signed Word</xsl:when>
                        
<xsl:when test="self::mostco:TULong">Unsigned Long</xsl:when>
                        
<xsl:when test="self::mostco:TSLong">Signed Long</xsl:when>
                
</xsl:choose>
                
<xsl:text> </xsl:text>
                
<!-- "Function classes" output handling ends here -->
                
<!-- Entry point - the root element of the FunctionCatalog is handled here -->
                
<!--  Process the FunctionCatalog element and build the "FBlock Overview" table -->
        
</xsl:template>
        
<!-- *** FBlock - Function - Function classes *** -->
        
<!-- Level 4: "Function classes" output handling; these are helper templates, building, for example, the "Array of { Number }" string -->
        
<!-- Determine the function class of the function and process the parameter data types accordingly -->
        
<xsl:template mode="choose-class" match="*">
                
<xsl:variable name="parameter-name" select="mostco:Status/mostco:ParameterReference[2]/@Name" />
                
<xsl:variable name="tagged-parameter-name" select="mostco:Status/mostco:ParameterReference[3]/@Name" />
                
<xsl:variable name="longarray-parameter-name" select="mostco:Status/mostco:ParameterReference[5]/@Name" />
                
<xsl:variable name="parameter-definition" select="../mostco:Parameters/mostco:Parameter[@Name=$parameter-name]/mostco:DataType" />
                
<xsl:variable name="shared-parameter-definition" select="/*/mostco:SharedParameters/mostco:SharedParameter[@Name=$parameter-name]/mostco:Parameter/mostco:DataType" />
                
<xsl:variable name="tagged-parameter-definition" select="../mostco:Parameters/mostco:Parameter[@Name=$tagged-parameter-name]/mostco:DataType" />
                
<xsl:variable name="tagged-shared-parameter-definition" select="/*/mostco:SharedParameters/mostco:SharedParameter[@Name=$tagged-parameter-name]/mostco:Parameter/mostco:DataType" />
                
<xsl:variable name="longarray-parameter-definition" select="../mostco:Parameters/mostco:Parameter[@Name=$longarray-parameter-name]/mostco:DataType" />
                
<xsl:variable name="longarray-shared-parameter-definition" select="/*/mostco:SharedParameters/mostco:SharedParameter[@Name=$longarray-parameter-name]/mostco:Parameter/mostco:DataType" />
                
<xsl:choose>
                        
<xsl:when test="@Class='Record'">
                                
<xsl:choose>
                                        
<xsl:when test="$shared-parameter-definition">
                                                
<xsl:apply-templates mode="class-record" select="$shared-parameter-definition" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:apply-templates mode="class-record" select="$parameter-definition" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:when>
                        
<xsl:when test="@Class='Array'">
                                
<xsl:choose>
                                        
<xsl:when test="$shared-parameter-definition">
                                                
<xsl:apply-templates mode="class-array" select="$shared-parameter-definition" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:apply-templates mode="class-array" select="$parameter-definition" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:when>
                        
<xsl:when test="@Class='DynamicArray'">
                                
<xsl:choose>
                                        
<xsl:when test="$tagged-shared-parameter-definition">
                                                
<xsl:apply-templates mode="class-dynamicarray" select="$tagged-shared-parameter-definition" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:apply-templates mode="class-dynamicarray" select="$tagged-parameter-definition" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:when>
                        
<xsl:when test="@Class='LongArray'">
                                
<xsl:choose>
                                        
<xsl:when test="$longarray-shared-parameter-definition">
                                                
<xsl:apply-templates mode="class-longarray" select="$longarray-shared-parameter-definition" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:apply-templates mode="class-longarray" select="$longarray-parameter-definition" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:when>
                        
<xsl:when test="@Class='Map'">
                                
<xsl:choose>
                                        
<xsl:when test="$tagged-shared-parameter-definition">
                                                
<xsl:apply-templates mode="class-map" select="$tagged-shared-parameter-definition" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:apply-templates mode="class-map" select="$tagged-parameter-definition" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:when>
                        
<xsl:otherwise>
                                
<xsl:value-of select="@Class" />
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- Level 5: Output for Record function class: "Record of { ... }" -->
        
<xsl:template mode="class-record" match="mostco:TRecordLegacy">
                
<xsl:text>Record of { </xsl:text>
                
<!-- Use for-each to make sure that the order of the record members prevails and not the order of the shared parameters -->
                
<xsl:for-each select="mostco:TRecordField|mostco:SharedRecordFieldReference|mostco:NamedSharedRecordFieldReference">
                        
<xsl:choose>
                                
<xsl:when test="self::mostco:TRecordField">
                                        
<xsl:apply-templates select="mostco:DataType/*" mode="get-param-type-name" />
                                
</xsl:when>
                                
<xsl:when test="self::mostco:SharedRecordFieldReference">
                                        
<xsl:apply-templates select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@Name]/mostco:Parameter/mostco:DataType/*" mode="get-param-type-name" />
                                
</xsl:when>
                                
<xsl:when test="self::mostco:NamedSharedRecordFieldReference">
                                        
<xsl:apply-templates select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@NameRef]/mostco:Parameter/mostco:DataType/*" mode="get-param-type-name" />
                                
</xsl:when>                                
                        
</xsl:choose>
                
</xsl:for-each>
                
<xsl:text>}</xsl:text>
        
</xsl:template>
        
<!-- Level 5: Output for Array function class: "Array of { ... }" -->
        
<xsl:template mode="class-array" match="mostco:TArrayLegacy">
                
<xsl:text>Array of { </xsl:text>
                
<xsl:apply-templates select="mostco:DataType/*|/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/*" mode="get-param-type-name" />
                
<xsl:text>}</xsl:text>
        
</xsl:template>
        
<!-- Level 5: Output for DynamicArray function class: "DynamicArray of { ... }" -->
        
<xsl:template mode="class-dynamicarray" match="mostco:TArrayLegacy">
                
<xsl:text>DynamicArray of { </xsl:text>
                
<xsl:apply-templates select="mostco:DataType/*|/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/*" mode="get-param-type-name" />
                
<xsl:text>}</xsl:text>
        
</xsl:template>
        
<!-- Level 5: Output for LongArray function class: "LongArray of { ... }" -->
        
<xsl:template mode="class-longarray" match="mostco:TArrayLegacy">
                
<xsl:text>LongArray of { </xsl:text>
                
<xsl:apply-templates select="mostco:DataType/*|/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/*" mode="get-param-type-name" />
                
<xsl:text>}</xsl:text>
        
</xsl:template>
        
<!-- Level 5: Output for Map function class: "Map of { ... }" -->
        
<xsl:template mode="class-map" match="mostco:TArrayLegacy">
                
<xsl:text>Map of { </xsl:text>
                
<xsl:apply-templates select="mostco:DataType/*|/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/*" mode="get-param-type-name" />
                
<xsl:text>}</xsl:text>
        
</xsl:template>
        
<!-- *** Function catalog *** -->
        
<!-- Level 1: Processing the one and only global element: FunctionCatalog -->
        
<xsl:template match="mostco:FunctionCatalog">
                
<!-- HTML Header -->
                
<html>
                        
<head>
                                
<title>Function Catalog</title>
                                
<link rel="stylesheet" type="text/css" href="most.css" />
                        
</head>
                        
<body>
                                
<h1>Function Catalog</h1>
                                
<!-- Create release, author, etc.; Build "Modifications" table -->
                                
<xsl:apply-templates select="mostco:CatalogVersion" />
                                
                                
<!-- Hyperlink creation is different for function catalogs that have no FBlocks at all -->
                                
<xsl:variable name="fblock-exists" select="count(mostco:FBlock) &gt; 0" />
                                        
                                
<xsl:choose>
                                        
<xsl:when test="mostco:FBlock">
                                                
<!-- FBlocks exist. -->
                                                
<table border="2" cellpadding="3" cellspacing="0">
                                                        
<!-- "FBlock Overview" table header -->
                                                        
<tr>
                                                                
<th colspan="2" class="functiontable">FBlock Overview</th>
                                                        
</tr>
                                                        
<tr>
                                                                
<th class="functiontable">FBlockID</th>
                                                                
<th class="functiontable">Name</th>
                                                        
</tr>
                                                        
<!-- "FBlock Overview" table contents  -->
                                                        
<xsl:apply-templates mode="fblock-table" select="mostco:FBlock">
                                                                
<xsl:sort data-type="number" select="@Id" />
                                                        
</xsl:apply-templates>
                                                
</table>
                                                
<!-- Detailed descriptions of FBlocks -->
                                                
<xsl:apply-templates select="mostco:FBlock">
                                                        
<xsl:sort data-type="number" select="@Id" />
                                                
</xsl:apply-templates>
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<!-- No FBlocks present. List shared functions instead -->
                                                
<xsl:variable name="function-group-exists" select="count(/*/mostco:SharedFunctions/mostco:SharedFunction/mostco:Function/@FunctionGroup) &gt; 0" />
                                                
<!-- "Function Overview" table for shared functions -->
                                                
<table border="2" cellpadding="3" cellspacing="0">
                                                        
<!-- "Function Overview" table header -->
                                                        
<tr>
                                                                
<xsl:choose>
                                                                        
<xsl:when test="$function-group-exists = true()">
                                                                                
<th colspan="4" class="functiontable">Function Overview</th>
                                                                        
</xsl:when>
                                                                        
<xsl:otherwise>
                                                                                
<th colspan="3" class="functiontable">Function Overview</th>
                                                                        
</xsl:otherwise>
                                                                
</xsl:choose>
                                                        
</tr>
                                                        
<tr>
                                                                
<th class="functiontable">FktID</th>
                                                                
<th class="functiontable">Name</th>
                                                                
<th class="functiontable">Occurrence</th>
                                                                
<xsl:if test="$function-group-exists = true()">
                                                                        
<th class="functiontable">FunctionGroup</th>
                                                                
</xsl:if>
                                                        
</tr>
                                                        
<!-- "Function Overview" table contents -->
                                                        
<xsl:apply-templates mode="function-overview-table-row" select="/mostco:FunctionCatalog/mostco:SharedFunctions/mostco:SharedFunction/mostco:Function">
                                                                
<xsl:with-param name="function-group-exists" select="$function-group-exists" />
                                                                
<xsl:with-param name="fblock-exists" select="$fblock-exists" />
                                                                
<xsl:with-param name="fblock-id" select="@Id" />                                                                
                                                                
<xsl:sort data-type="number" order="ascending" select="@Id" />
                                                        
</xsl:apply-templates>
                                                
</table>
                                                
<!-- Function descriptions -->
                                                
<xsl:apply-templates select="/mostco:FunctionCatalog/mostco:SharedFunctions/mostco:SharedFunction/mostco:Function" mode="zero-fblocks">
                                                        
<xsl:sort data-type="number" order="ascending" select="@Id" />
                                                        
<!-- <xsl:with-param name="fblock-id" select="text()"/> -->
                                                
</xsl:apply-templates>
                                        
</xsl:otherwise>
                                
</xsl:choose>
                                
<!-- "FBlock Overview" table -->
                                
<!-- HTML Footer -->
                        
</body>
                
</html>
        
</xsl:template>
        
<!-- Level 2: Create one row of the "FBlock Overview" table that lists the invidvidual FBlocks  -->
        
<xsl:template match="mostco:FBlock" mode="fblock-table">
                
<tr>
                        
<!-- Convert FBlockID to hex -->
                        
<td class="functionformat">
                                
<xsl:call-template name="dec-to-hex-padded">
                                        
<xsl:with-param name="value" select="@Id" />
                                        
<xsl:with-param name="digits" select="2" />
                                
</xsl:call-template>
                        
</td>
                        
<!-- Name of the FBlock with hyperlink -->
                        
<td class="functionformat">
                                
<xsl:element name="a">
                                        
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="@Id" /></xsl:attribute>
                                        
<xsl:value-of select="@Name" />
                                
</xsl:element>
                        
</td>
                
</tr>
        
</xsl:template>
        
<!-- *** FBlock description *** -->
        
<!-- Level 2: Create the detailed description of an FBlock  -->
        
<xsl:template match="mostco:FBlock">
                
<!-- Title -->
                
<xsl:element name="a">
                        
<xsl:attribute name="name"><xsl:number value="@Id" /></xsl:attribute>
                
</xsl:element>
                
<h2>
                        
<xsl:value-of select="@Name" />
                        
<!-- Omit FBlockID for FBlock templates; those do not have an ID -->
                        
<xsl:if test="@Id">
                                
<xsl:text> </xsl:text>
                                
<xsl:text>(FBlockID =        </xsl:text>
                                
<xsl:call-template name="dec-to-hex-padded">
                                        
<xsl:with-param name="value" select="@Id" />
                                        
<xsl:with-param name="digits" select="2" />
                                
</xsl:call-template>
                                
<xsl:text>)</xsl:text>
                        
</xsl:if>
                
</h2>
                
<!-- Create release, author, etc.; Build "Modifications" table -->
                
<xsl:apply-templates select="mostco:FBlockVersion" />
                
<!-- FBlock description   -->
                
<xsl:if test="mostco:Description/text()">
                        
<p class="description">
                                
<xsl:value-of disable-output-escaping="yes" select="mostco:Description/text()" />
                        
</p>
                
</xsl:if>
                
<xsl:variable name="function-group-exists" select="count(mostco:Function/@FunctionGroup | /*/mostco:SharedFunctions/mostco:SharedFunction[@Name = current()/mostco:SharedFunctionReference/@Name]/mostco:Function/@FunctionGroup) &gt; 0" />
                
<!-- "Function Overview" table for one FBlock -->
                
<table border="2" cellpadding="3" cellspacing="0">
                        
<!-- "Function Overview" table header -->
                        
<tr>
                                
<xsl:choose>
                                        
<xsl:when test="$function-group-exists = true()">
                                                
<th colspan="4" class="functiontable">Function Overview</th>
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<th colspan="3" class="functiontable">Function Overview</th>
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</tr>
                        
<tr>
                                
<th class="functiontable">FktID</th>
                                
<th class="functiontable">Name</th>
                                
<th class="functiontable">Occurrence</th>
                                
<xsl:if test="$function-group-exists = true()">
                                        
<th class="functiontable">FunctionGroup</th>
                                
</xsl:if>
                        
</tr>
                        
<!-- "Function Overview" table contents -->
                        
<!-- The following has to take a few things into consideration: Functions may be defined locally, or shared. If shared, the Id attribute could be overwritten in the SharedFunctionReference. To sort all the functions properly, those that carry the desired Id attribute have to be collected, sorted, and passed on to the template -->
                        
<xsl:apply-templates mode="function-overview-table-row" select="mostco:Function | mostco:SharedFunctionReference[@Id] | /mostco:FunctionCatalog/mostco:SharedFunctions/mostco:SharedFunction[@Name = current()/mostco:SharedFunctionReference/@Name]/mostco:Function">
                                
<xsl:with-param name="function-group-exists" select="$function-group-exists" />
                                
<xsl:with-param name="fblock-exists" select="true()" />
                                
<xsl:with-param name="fblock-id" select="@Id" />

                                
<xsl:sort data-type="number" order="ascending" select="@Id" />
                        
</xsl:apply-templates>
                
</table>
                
<!-- Function descriptions -->
                
<xsl:apply-templates select="mostco:Function | mostco:SharedFunctionReference[@Id] | /mostco:FunctionCatalog/mostco:SharedFunctions/mostco:SharedFunction[@Name = current()/mostco:SharedFunctionReference/@Name]/mostco:Function">
                        
<xsl:sort data-type="number" order="ascending" select="@Id" />
                        
<xsl:with-param name="fblock-id" select="@Id" />
                
</xsl:apply-templates>
                
<p class="PageBreakPossible">
                        
<xsl:text> </xsl:text>
                
</p>
        
</xsl:template>
        
<!-- *** FBlock description - Version information *** -->
        
<!-- Level 3+: Create version information -->
        
<xsl:template match="mostco:CatalogVersion|mostco:FBlockVersion|mostco:FunctionVersion">
                
<xsl:choose>
                        
<xsl:when test="self::mostco:CatalogVersion or @Access='public'">
                                
<table border="0">
                                        
<tr>
                                                
<td class="VerInfo">Release:</td>
                                                
<td class="VerInfo">
                                                        
<xsl:choose>
                                                                
<xsl:when test="@Release">
                                                                        
<xsl:value-of select="@Release" />
                                                                
</xsl:when>
                                                                
<xsl:otherwise>unknown</xsl:otherwise>
                                                        
</xsl:choose>
                                                
</td>
                                        
</tr>
                                        
<tr>
                                                
<td class="VerInfo">Date:</td>
                                                
<td class="VerInfo">
                                                        
<xsl:choose>
                                                                
<xsl:when test="@Date">
                                                                        
<xsl:value-of select="@Date" />
                                                                
</xsl:when>
                                                                
<xsl:otherwise>unknown</xsl:otherwise>
                                                        
</xsl:choose>
                                                
</td>
                                        
</tr>
                                        
<tr>
                                                
<td class="VerInfo">Author:</td>
                                                
<td class="VerInfo">
                                                        
<xsl:choose>
                                                                
<xsl:when test="mostco:Author/text()">
                                                                        
<xsl:value-of select="mostco:Author/text()" />
                                                                
</xsl:when>
                                                                
<xsl:otherwise>unknown</xsl:otherwise>
                                                        
</xsl:choose>
                                                
</td>
                                        
</tr>
                                        
<tr>
                                                
<td class="VerInfo">Company:</td>
                                                
<td class="VerInfo">
                                                        
<xsl:choose>
                                                                
<xsl:when test="mostco:Company/text()">
                                                                        
<xsl:value-of select="mostco:Company/text()" />
                                                                
</xsl:when>
                                                                
<xsl:otherwise>unknown</xsl:otherwise>
                                                        
</xsl:choose>
                                                
</td>
                                        
</tr>
                                
</table>
                                
<table border="2" cellpadding="3" cellspacing="0">
                                        
<xsl:variable name="AuthorCount">
                                                
<xsl:choose>
                                                        
<xsl:when test="mostco:Modification/@Author">
                                                                
<xsl:value-of select="1" />
                                                        
</xsl:when>
                                                        
<xsl:otherwise>
                                                                
<xsl:value-of select="0" />
                                                        
</xsl:otherwise>
                                                
</xsl:choose>
                                        
</xsl:variable>
                                        
<xsl:variable name="DateCount">
                                                
<xsl:choose>
                                                        
<xsl:when test="mostco:Modification/@Date">
                                                                
<xsl:value-of select="1" />
                                                        
</xsl:when>
                                                        
<xsl:otherwise>
                                                                
<xsl:value-of select="0" />
                                                        
</xsl:otherwise>
                                                
</xsl:choose>
                                        
</xsl:variable>
                                        
<xsl:variable name="TimeCount">
                                                
<xsl:choose>
                                                        
<xsl:when test="mostco:Modification/@Time">
                                                                
<xsl:value-of select="1" />
                                                        
</xsl:when>
                                                        
<xsl:otherwise>
                                                                
<xsl:value-of select="0" />
                                                        
</xsl:otherwise>
                                                
</xsl:choose>
                                        
</xsl:variable>
                                        
<tr>
                                                
<th colspan="{2 + $AuthorCount+ $DateCount+ $TimeCount}" class="functiontable">Modifications</th>
                                        
</tr>
                                        
<tr>
                                                
<th class="functiontable">Change</th>
                                                
<th class="functiontable">Reason</th>
                                                
<xsl:if test="mostco:Modification/@Author">
                                                        
<th class="functiontable">Author</th>
                                                
</xsl:if>
                                                
<xsl:if test="mostco:Modification/@Date">
                                                        
<th class="functiontable">Date</th>
                                                
</xsl:if>
                                                
<xsl:if test="mostco:Modification/@Time">
                                                        
<th class="functiontable">Time</th>
                                                
</xsl:if>
                                        
</tr>
                                        
<xsl:apply-templates mode="list-modifications" select="mostco:Modification" />
                                
</table>
                                
<br />
                        
</xsl:when>
                        
<xsl:otherwise>
                                
<p class="VerInfo">(The version information is not publicly available.)</p>
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- Level 4+: Modification -->
        
<xsl:template mode="list-modifications" match="mostco:Modification">
                
<tr>
                        
<td class="VerInfo">
                                
<xsl:value-of select="mostco:Change/text()" />
                        
</td>
                        
<td class="VerInfo">
                                
<xsl:value-of select="mostco:Reason/text()" />
                        
</td>
                        
<xsl:if test="../mostco:Modification/@Author">
                                
<td class="VerInfo">
                                        
<xsl:value-of select="@Author" />
                                
</td>
                        
</xsl:if>
                        
<xsl:if test="../mostco:Modification/@Date">
                                
<td class="VerInfo">
                                        
<xsl:value-of select="@Date" />
                                
</td>
                        
</xsl:if>
                        
<xsl:if test="../mostco:Modification/@Time">
                                
<td class="VerInfo">
                                        
<xsl:value-of select="@Time" />
                                
</td>
                        
</xsl:if>
                
</tr>
        
</xsl:template>
        
<!-- *** FBlock description - Function Overview table *** -->
        
<!-- Level 3: Create one row of the "Function Overview" table that lists the functions of an FBlock or all shared functions if no FBlock exists -->
        
<xsl:template mode="function-overview-table-row" match="mostco:Function|mostco:SharedFunctionReference">
                
<xsl:param name="function-group-exists" />
                
<xsl:param name="fblock-exists" />
                
<xsl:param name="fblock-id" />        
                
<xsl:variable name="is-function-reference" select="boolean(self::mostco:SharedFunctionReference)" />
                
<!-- a node set is the desired selection, so everything has to be crammed into the select attribute -->
                
<xsl:variable name="function-node" select="self::node() [not($is-function-reference)] | /mostco:FunctionCatalog/mostco:SharedFunctions/mostco:SharedFunction[@Name=current()/@Name]/mostco:Function [$is-function-reference]" />
                
<!-- A SharedFunction Reference may overwrite the FktID of the shared function. The Id of the SharedFunctionReference should then be listed. -->
                
<xsl:variable name="id-attribute-exists" select="boolean(@Id)" />
                
<xsl:variable name="resulting-function-id" select="self::node() [$id-attribute-exists]/@Id | /mostco:FunctionCatalog/mostco:SharedFunctions/mostco:SharedFunction[@Name=current()/@Name]/mostco:Function [not($id-attribute-exists)]/@Id" />
                
<tr>
                        
<td class="functionformat">
                                
<xsl:call-template name="dec-to-hex-padded">
                                        
<xsl:with-param name="value" select="$resulting-function-id" />
                                        
<xsl:with-param name="digits" select="3" />
                                
</xsl:call-template>
                        
</td>
                        
<td class="functionformat">
                                
<xsl:element name="a">
                                        
<xsl:attribute name="href"><xsl:text>#</xsl:text>
                                        
<xsl:choose>
                                                
<!-- different names if no FBlocks exist -->
                                                
<xsl:when test="$fblock-exists = true()">
                                                        
<xsl:call-template name="function-anchor"><xsl:with-param name="fblock-id" select="$fblock-id" /><xsl:with-param name="resulting-function-id" select="$resulting-function-id" /></xsl:call-template>
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<xsl:call-template name="shared-function-anchor"><xsl:with-param name="fblock-id" select="$fblock-id" /><xsl:with-param name="resulting-function-id" select="$resulting-function-id" /></xsl:call-template>
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                        
</xsl:attribute>
                                        
<xsl:value-of select="$function-node/@Name" />
                                
</xsl:element>
                        
</td>
                        
<td class="functionformat">
                                
<xsl:value-of select="$function-node/@Occurrence" />
                        
</td>
                        
<xsl:if test="$function-group-exists = true()">
                                
<td class="functionformat">
                                        
<xsl:value-of select="$function-node/@FunctionGroup" />
                                
</td>
                        
</xsl:if>
                
</tr>
        
</xsl:template>
        
<!-- Level 4: Helper function to generate HTML anchor for functions -->
        
<xsl:template name="function-anchor">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />
                
<xsl:value-of select="$fblock-id" />
                
<xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text>
                
<xsl:value-of select="ancestor-or-self::mostco:Function/@Name | @Name" />
        
</xsl:template>
        
<!-- Level 4: Helper function to generate HTML anchor for shared functions -->
        
<xsl:template name="shared-function-anchor">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />
                
<xsl:value-of select="$fblock-id" />
                
<xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text>
                
<xsl:value-of select="ancestor-or-self::mostco:SharedFunction/@Name" />
        
</xsl:template>        
        
<!-- *** FBlock details - Function *** -->
        
<!-- Level 3: Detailed description of one function -->
        
<xsl:template match="mostco:Function|mostco:SharedFunctionReference">
                
<xsl:param name="fblock-id" />
                
<xsl:variable name="is-function-reference" select="boolean(self::mostco:SharedFunctionReference)" />
                
<!-- a node set is the desired selection, so everything has to be crammed into the select attribute -->
                
<xsl:variable name="function-node" select="self::node() [not($is-function-reference)] | /mostco:FunctionCatalog/mostco:SharedFunctions/mostco:SharedFunction[@Name=current()/@Name]/mostco:Function [$is-function-reference]" />
                
<xsl:variable name="id-attribute-exists" select="boolean(@Id)" />
                
<xsl:variable name="resulting-function-id" select="self::node() [$id-attribute-exists]/@Id | /mostco:FunctionCatalog/mostco:SharedFunctions/mostco:SharedFunction[@Name=current()/@Name]/mostco:Function [not($id-attribute-exists)]/@Id" />
                
<!-- Function name with hyperlink  -->
                
<xsl:element name="a">
                        
<xsl:attribute name="name"><xsl:call-template name="function-anchor"><xsl:with-param name="fblock-id" select="$fblock-id" /><xsl:with-param name="resulting-function-id" select="$resulting-function-id" /></xsl:call-template></xsl:attribute>
                
</xsl:element>
                
<h3>
                        
<xsl:value-of select="$function-node/@Name" /> (<xsl:call-template name="dec-to-hex-padded">
                                
<xsl:with-param name="value" select="$resulting-function-id" />
                                
<xsl:with-param name="digits" select="3" />
                        
</xsl:call-template>
                        
<xsl:if test="@FunctionGroup">
                                
<xsl:text> - Function Group: </xsl:text>
                                
<xsl:value-of select="@FunctionGroup" />
                        
</xsl:if>
                        
<xsl:text>)</xsl:text>
                
</h3>
                
<p class="description">Occurrence: <xsl:value-of select="$function-node/@Occurrence" />
                
</p>
                
<xsl:if test="$function-node/mostco:Description/text()">
                        
<p class="description">
                                
<xsl:value-of disable-output-escaping="yes" select="$function-node/mostco:Description/text()" />
                        
</p>
                
</xsl:if>
                
<h4>Format of Function</h4>
                
<p class="functionformat">
                        
<b>Function class: </b>
                        
<!-- build the structure of the function class names -->
                        
<xsl:apply-templates mode="choose-class" select="$function-node/mostco:Property|$function-node/mostco:Method" />
                
</p>
                
<!-- OPType table for the function -->
                
<table width="100%" border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="functionformat" width="15%">FBlock</th>
                                
<th class="functionformat" width="15%">Function</th>
                                
<th class="functionformat" width="15%">OPType</th>
                                
<xsl:if test="count(($function-node/mostco:Property|$function-node/mostco:Method)/*[@Channel])">
                                        
<th class="functionformat" width="15%">Channel</th>
                                
</xsl:if>
                                
<th class="functionformat">Parameter</th>
                        
</tr>
                        
<!-- create the table that lists all OPTypes and parameters for this function-->
                        
<xsl:apply-templates mode="function-table" select="$function-node/mostco:Property|$function-node/mostco:Method">
                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                        
</xsl:apply-templates>
                
</table>
                
<!-- Parameter descriptions  -->
                
<!-- Extract the set of parameters that is supposed to appear in the ouput. If the set is empty, suppress the "Parameter" heading.-->
                
<xsl:if test="count($function-node/mostco:Parameters/mostco:Parameter|$function-node/mostco:Parameters/mostco:SharedParameterReference|$function-node/mostco:Parameters/mostco:NamedSharedParameterReference) &gt; 0">
                        
<h4>Parameter</h4>
                        
<xsl:variable name="function-name" select="ancestor::mostco:SharedFunction/@Name | @Name[not(ancestor::mostco:SharedFunction)]" />                
                        
                        
<xsl:for-each select="$function-node/*/*/mostco:ParameterReference">
                                
<xsl:sort data-type="number" order="ascending" select="document('')/*/mostco:OPTypeNum[@name=name(current()/parent::*)]" />
                                
<!-- somewhat awkward but key sorting for this structure is one off in some cases -->
                                
<xsl:variable name="first-parameter-reference">
                                        
<xsl:for-each select="../../*/mostco:ParameterReference[@Name = current()/@Name]">
                                                
<xsl:sort data-type="number" order="ascending" select="document('')/*/mostco:OPTypeNum[@name=name(current()/parent::*)]" />
                                                
<xsl:if test="position()=1">
                                                        
<xsl:value-of select="generate-id(.)" />
                                                
</xsl:if>
                                        
</xsl:for-each>
                                
</xsl:variable>
                                
<xsl:if test="generate-id(.) = $first-parameter-reference">
                                        
<xsl:choose>
                                                
<xsl:when test="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::', @Name))/self::mostco:Parameter">
                                                        
<xsl:apply-templates mode="parameter-description" select="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))">
                                                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                
                                                                
<xsl:with-param name="function-name" select="$function-name" />
                                                        
</xsl:apply-templates>
                                                
</xsl:when>
                                                
<xsl:when test="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))/self::mostco:SharedParameterReference">
                                                        
<xsl:apply-templates mode="shared-parameter-description" select="key('shared-parameter-definitions',./@Name)/mostco:Parameter">
                                                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                        
                                                                
<xsl:with-param name="function-name" select="$function-name" />
                                                        
</xsl:apply-templates>
                                                
</xsl:when>
                                                
<xsl:when test="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))/self::mostco:NamedSharedParameterReference">
                                                        
<xsl:apply-templates mode="named-shared-parameter-description" select="key('shared-parameter-definitions', key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))/self::mostco:NamedSharedParameterReference/@NameRef)/mostco:Parameter">
                                                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                        
                                                                
<xsl:with-param name="function-name" select="$function-name" />
                                                                
<xsl:with-param name="name-substitute" select="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))/self::mostco:NamedSharedParameterReference/@Name" />
                                                                
<xsl:with-param name="description-substitute" select="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))/self::mostco:NamedSharedParameterReference/mostco:Description" />
                                                        
</xsl:apply-templates>
                                                
</xsl:when>                                                
                                                
<xsl:otherwise>
                                                        
<!-- Neither parameter nor shared parameter. We have a problem. -->
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:if>
                        
</xsl:for-each>
                
</xsl:if>
        
</xsl:template>
        
<!-- Level 3: Detailed description of one function - no FBlocks present -->
        
<xsl:template match="mostco:Function" mode="zero-fblocks">
                
<xsl:param name="fblock-id" />
                
<xsl:variable name="function-node" select="self::node()" />
                
<xsl:variable name="resulting-function-id" select="self::node()/@Id" />
                
<!-- Function name with hyperlink  -->
                
<xsl:element name="a">
                        
<xsl:attribute name="name"><xsl:call-template name="shared-function-anchor"><xsl:with-param name="fblock-id" select="$fblock-id" /><xsl:with-param name="resulting-function-id" select="$resulting-function-id" /></xsl:call-template></xsl:attribute>
                
</xsl:element>
                
<h3>
                        
<xsl:value-of select="$function-node/@Name" /> (<xsl:call-template name="dec-to-hex-padded">
                                
<xsl:with-param name="value" select="$resulting-function-id" />
                                
<xsl:with-param name="digits" select="3" />
                        
</xsl:call-template>
                        
<xsl:if test="@FunctionGroup">
                                
<xsl:text> - Function Group: </xsl:text>
                                
<xsl:value-of select="@FunctionGroup" />
                        
</xsl:if>
                        
<xsl:text>)</xsl:text>
                
</h3>
                
<p class="description">Occurrence: <xsl:value-of select="$function-node/@Occurrence" />
                
</p>
                
<xsl:if test="$function-node/mostco:Description/text()">
                        
<p class="description">
                                
<xsl:value-of disable-output-escaping="yes" select="$function-node/mostco:Description/text()" />
                        
</p>
                
</xsl:if>
                
<h4>Format of Function</h4>
                
<p class="functionformat">
                        
<b>Function class: </b>
                        
<!-- build the structure of the function class names -->
                        
<xsl:apply-templates mode="choose-class" select="$function-node/mostco:Property|$function-node/mostco:Method" />
                
</p>
                
<!-- OPType table for the function -->
                
<table width="100%" border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="functionformat" width="15%">FBlock</th>
                                
<th class="functionformat" width="15%">Function</th>
                                
<th class="functionformat" width="15%">OPType</th>
                                
<xsl:if test="count(($function-node/mostco:Property|$function-node/mostco:Method)/*[@Channel])">
                                        
<th class="functionformat" width="15%">Channel</th>
                                
</xsl:if>
                                
<th class="functionformat">Parameter</th>
                        
</tr>
                        
<!-- create the table that lists all OPTypes and parameters for this function-->
                        
<xsl:apply-templates mode="zero-fblocks-function-table" select="$function-node/mostco:Property|$function-node/mostco:Method">
                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                        
</xsl:apply-templates>
                
</table>
                
<!-- Parameter descriptions  -->
                
<!-- Extract the set of parameters that is supposed to appear in the ouput. If the set is empty, suppress the "Parameter" heading.-->
                
<xsl:if test="count($function-node/mostco:Parameters/mostco:Parameter|$function-node/mostco:Parameters/mostco:SharedParameterReference|$function-node/mostco:Parameters/mostco:NamedSharedParameterReference) &gt; 0">
                        
<h4>Parameter</h4>
                        
<xsl:variable name="function-name" select="ancestor::mostco:SharedFunction/@Name | ancestor-or-self::mostco:Function/@Name[not(ancestor::mostco:SharedFunction)]" />
                        
<xsl:for-each select="$function-node/*/*/mostco:ParameterReference">
                                
<xsl:sort data-type="number" order="ascending" select="document('')/*/mostco:OPTypeNum[@name=name(current()/parent::*)]" />
                                
<!-- somewhat awkward but key sorting for this structure is one off in some cases -->
                                
<xsl:variable name="first-parameter-reference">
                                        
<xsl:for-each select="../../*/mostco:ParameterReference[@Name = current()/@Name]">
                                                
<xsl:sort data-type="number" order="ascending" select="document('')/*/mostco:OPTypeNum[@name=name(current()/parent::*)]" />
                                                
<xsl:if test="position()=1">
                                                        
<xsl:value-of select="generate-id(.)" />
                                                
</xsl:if>
                                        
</xsl:for-each>
                                
</xsl:variable>
                                
<xsl:if test="generate-id(.) = $first-parameter-reference">
                                        
<xsl:choose>
                                                
<xsl:when test="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::', @Name))/self::mostco:Parameter">
                                                        
<xsl:apply-templates mode="parameter-description" select="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))">
                                                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                
                                                                
<xsl:with-param name="function-name" select="$function-name" />
                                                        
</xsl:apply-templates>
                                                
</xsl:when>
                                                
<xsl:when test="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))/self::mostco:SharedParameterReference">
                                                        
<xsl:apply-templates mode="shared-parameter-description" select="key('shared-parameter-definitions',./@Name)/mostco:Parameter">
                                                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                        
                                                                
<xsl:with-param name="function-name" select="$function-name" />
                                                        
</xsl:apply-templates>
                                                
</xsl:when>
                                                
<xsl:when test="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))/self::mostco:NamedSharedParameterReference">
                                                        
<xsl:apply-templates mode="named-shared-parameter-description" select="key('shared-parameter-definitions', key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))/self::mostco:NamedSharedParameterReference/@NameRef)/mostco:Parameter">
                                                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                        
                                                                
<xsl:with-param name="function-name" select="$function-name" />
                                                                
<xsl:with-param name="name-substitute" select="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))/self::mostco:NamedSharedParameterReference/@Name" />
                                                                
<xsl:with-param name="description-substitute" select="key('parameter-definitions', concat(generate-id(ancestor::mostco:Function),'::',@Name))/self::mostco:NamedSharedParameterReference/mostco:Description" />
                                                        
</xsl:apply-templates>
                                                
</xsl:when>                                                
                                                
<xsl:otherwise>
                                                        
<!-- Neither parameter nor shared parameter. We have a problem. -->
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:if>
                        
</xsl:for-each>
                
</xsl:if>
        
</xsl:template>
        
<!-- Level 4: OPType table for one function -->
        
<xsl:template match="mostco:Method|mostco:Property" mode="function-table">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />
                
<!-- Create a properly sorted set of OPTypes -->
                
<xsl:variable name="used-optypes-sorted">
                        
<xsl:for-each select="*">
                                
<xsl:sort data-type="number" order="ascending" select="document('')/*/mostco:OPTypeNum[@name=name(current())]" />
                                
<xsl:copy-of select="." />
                        
</xsl:for-each>
                
</xsl:variable>
                
<!-- Count entries to determine correct rowspan of Function table -->
                
<xsl:variable name="number-of-used-optypes" select="count(*)" />
                
<xsl:variable name="number-of-channel-attributes" select="count(*[@Channel])" />
                
<xsl:variable name="first-used-optype">
                        
<xsl:for-each select="*">
                                
<xsl:sort data-type="number" order="ascending" select="document('')/*/mostco:OPTypeNum[@name=name(current())]" />
                                
<xsl:if test="position()=1">
                                        
<xsl:value-of select="name(.)" />
                                
</xsl:if>
                        
</xsl:for-each>
                
</xsl:variable>
                
<!-- create one table row for every OPType -->
                
<xsl:for-each select="*">
                        
<xsl:sort data-type="number" order="ascending" select="document('')/*/mostco:OPTypeNum[@name=name(current())]" />
                        
<xsl:call-template name="function-table-entry">
                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                
<xsl:with-param name="optype-node" select="." />
                                
<xsl:with-param name="optype-name" select="name(.)" />
                                
<xsl:with-param name="first-used-optype" select="$first-used-optype" />
                                
<xsl:with-param name="number-of-used-optypes" select="$number-of-used-optypes" />
                                
<xsl:with-param name="number-of-channel-attributes" select="$number-of-channel-attributes" />
                        
</xsl:call-template>
                
</xsl:for-each>
        
</xsl:template>
        
<!-- Level 4: OPType table for one function - no FBlocks present -->
        
<xsl:template match="mostco:Method|mostco:Property" mode="zero-fblocks-function-table">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />
                
<!-- Create a properly sorted set of OPTypes -->
                
<xsl:variable name="used-optypes-sorted">
                        
<xsl:for-each select="*">
                                
<xsl:sort data-type="number" order="ascending" select="document('')/*/mostco:OPTypeNum[@name=name(current())]" />
                                
<xsl:copy-of select="." />
                        
</xsl:for-each>
                
</xsl:variable>
                
<!-- Count entries to determine correct rowspan of Function table -->
                
<xsl:variable name="number-of-used-optypes" select="count(*)" />
                
<xsl:variable name="number-of-channel-attributes" select="count(*[@Channel])" />
                
<xsl:variable name="first-used-optype">
                        
<xsl:for-each select="*">
                                
<xsl:sort data-type="number" order="ascending" select="document('')/*/mostco:OPTypeNum[@name=name(current())]" />
                                
<xsl:if test="position()=1">
                                        
<xsl:value-of select="name(.)" />
                                
</xsl:if>
                        
</xsl:for-each>
                
</xsl:variable>
                
<!-- create one table row for every OPType -->
                
<xsl:for-each select="*">
                        
<xsl:sort data-type="number" order="ascending" select="document('')/*/mostco:OPTypeNum[@name=name(current())]" />
                        
<xsl:call-template name="zero-fblocks-function-table-entry">
                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                
<xsl:with-param name="optype-node" select="." />
                                
<xsl:with-param name="optype-name" select="name(.)" />
                                
<xsl:with-param name="first-used-optype" select="$first-used-optype" />
                                
<xsl:with-param name="number-of-used-optypes" select="$number-of-used-optypes" />
                                
<xsl:with-param name="number-of-channel-attributes" select="$number-of-channel-attributes" />
                        
</xsl:call-template>
                
</xsl:for-each>
        
</xsl:template>
        
<!-- Level 5: One row in the OPType table -->
        
<xsl:template name="function-table-entry">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />
                
<xsl:param name="optype-node" />
                
<xsl:param name="optype-name" />
                
<xsl:param name="first-used-optype" />
                
<xsl:param name="number-of-used-optypes" />
                
<xsl:param name="number-of-channel-attributes" />
                
<xsl:if test="$optype-node">
                        
<tr>
                                
<!-- Only create FBlock name and Function name output for the first entry -->
                                
<xsl:if test="name($optype-node)=$first-used-optype">
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>functionformat</xsl:text></xsl:attribute>
                                                
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-used-optypes" /></xsl:attribute>
                                                
<xsl:text />
                                                
<xsl:value-of select="ancestor::mostco:FBlock/@Name" />
                                                
<xsl:text> (</xsl:text>
                                                
<xsl:call-template name="dec-to-hex-padded">
                                                        
<xsl:with-param name="value" select="$fblock-id" />
                                                        
<xsl:with-param name="digits" select="2" />
                                                
</xsl:call-template>
                                                
<xsl:text>)</xsl:text>
                                        
</xsl:element>
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>functionformat</xsl:text></xsl:attribute>
                                                
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-used-optypes" /></xsl:attribute>
                                                
<xsl:text />
                                                
<xsl:value-of select="ancestor::mostco:Function/@Name" />
                                                
<xsl:text> (</xsl:text>
                                                
<xsl:call-template name="dec-to-hex-padded">
                                                        
<xsl:with-param name="value" select="$resulting-function-id" />
                                                        
<xsl:with-param name="digits" select="3" />
                                                
</xsl:call-template>
                                                
<xsl:text>)</xsl:text>
                                        
</xsl:element>
                                
</xsl:if>
                                
<td class="functionformat">
                                        
<xsl:value-of select="$optype-name" />
                                
</td>
                                
<xsl:if test="$number-of-channel-attributes &gt; 0">
                                        
<xsl:choose>
                                                
<xsl:when test="@Channel">
                                                        
<td class="functionformat">
                                                                
<xsl:value-of select="@Channel" />
                                                        
</td>
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<td class="functionformat" />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:if>
                                
<td class="functionformat">
                                        
<xsl:for-each select="mostco:ParameterReference">
                                                
<xsl:if test="position() &gt; 1"></xsl:if>
                                                
<xsl:element name="a">
                                                        
<!-- for hyperlinks, not the actual name of the parameter is used but the reference name -->
                                                        
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="ancestor::mostco:SharedFunction/@Name | ancestor-or-self::mostco:Function/@Name[not(ancestor::mostco:SharedFunction)]" /><xsl:text>_</xsl:text><xsl:value-of select="@Name" /></xsl:attribute>
                                                        
<xsl:apply-templates mode="actual-parameter-name" select="." />
                                                
</xsl:element>
                                        
</xsl:for-each>
                                        
<!-- If ErrorCode and ErrorInfo do not exist for the ErrorAck and Error OPTypes, create dummy output. Otherwise, do nothing. -->
                                        
<xsl:choose>
                                                
<xsl:when test="$optype-name='Error' and count(mostco:ParameterReference)=0 and count(../mostco:ErrorAck/*)&lt;3">ErrorCode, ErrorInfo</xsl:when>
                                                
<xsl:when test="$optype-name='ErrorAck' and count(mostco:ParameterReference)=1 and count(../mostco:Error/*)=0">, ErrorCode, ErrorInfo</xsl:when>
                                        
</xsl:choose>
                                
</td>
                        
</tr>
                
</xsl:if>
        
</xsl:template>
        
<!-- Level 5: One row in the OPType table -->
        
<xsl:template name="zero-fblocks-function-table-entry">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />
                
<xsl:param name="optype-node" />
                
<xsl:param name="optype-name" />
                
<xsl:param name="first-used-optype" />
                
<xsl:param name="number-of-used-optypes" />
                
<xsl:param name="number-of-channel-attributes" />
                
<xsl:if test="$optype-node">
                        
<tr>
                                
<!-- Only create FBlock name and Function name output for the first entry -->
                                
<xsl:if test="name($optype-node)=$first-used-optype">
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>functionformat</xsl:text></xsl:attribute>
                                                
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-used-optypes" /></xsl:attribute>
                                                
<xsl:text />
                                        
</xsl:element>
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>functionformat</xsl:text></xsl:attribute>
                                                
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-used-optypes" /></xsl:attribute>
                                                
<xsl:text />
                                                
<xsl:value-of select="ancestor::mostco:Function/@Name" />
                                                
<xsl:text> (</xsl:text>
                                                
<xsl:call-template name="dec-to-hex-padded">
                                                        
<xsl:with-param name="value" select="$resulting-function-id" />
                                                        
<xsl:with-param name="digits" select="3" />
                                                
</xsl:call-template>
                                                
<xsl:text>)</xsl:text>
                                        
</xsl:element>
                                
</xsl:if>
                                
<td class="functionformat">
                                        
<xsl:value-of select="$optype-name" />
                                
</td>
                                
<xsl:if test="$number-of-channel-attributes &gt; 0">
                                        
<xsl:choose>
                                                
<xsl:when test="@Channel">
                                                        
<td class="functionformat">
                                                                
<xsl:value-of select="@Channel" />
                                                        
</td>
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<td class="functionformat" />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:if>
                                
<td class="functionformat">
                                        
<xsl:for-each select="mostco:ParameterReference">
                                                
<xsl:if test="position() &gt; 1"></xsl:if>
                                                
<xsl:element name="a">
                                                        
<!-- for hyperlinks, not the actual name of the parameter is used but the reference name -->
                                                        
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="ancestor::mostco:SharedFunction/@Name | ancestor-or-self::mostco:Function/@Name[not(ancestor::mostco:SharedFunction)]" /><xsl:text>_</xsl:text><xsl:value-of select="@Name" /></xsl:attribute>
                                                        
<xsl:apply-templates mode="actual-parameter-name" select="." />
                                                
</xsl:element>
                                        
</xsl:for-each>
                                        
<!-- If ErrorCode and ErrorInfo do not exist for the ErrorAck and Error OPTypes, create dummy output. Otherwise, do nothing. -->
                                        
<xsl:choose>
                                                
<xsl:when test="$optype-name='Error' and count(mostco:ParameterReference)=0 and count(../mostco:ErrorAck/*)&lt;3">ErrorCode, ErrorInfo</xsl:when>
                                                
<xsl:when test="$optype-name='ErrorAck' and count(mostco:ParameterReference)=1 and count(../mostco:Error/*)=0">, ErrorCode, ErrorInfo</xsl:when>
                                        
</xsl:choose>
                                
</td>
                        
</tr>
                
</xsl:if>
        
</xsl:template>
        
<!-- *** FBlock details - Function - Parameter *** -->
        
<!-- Level 4: Description of one parameter. The way the template is called, it will not have to deal with shared parameter references-->
        
<xsl:template match="*" mode="parameter-description">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />
                
<xsl:param name="function-name" />
                
<!-- parameter table -->
                
<xsl:element name="a">
                        
<xsl:attribute name="name"><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:value-of select="@Name" /></xsl:attribute>
                
</xsl:element>
                
<!-- heading -->
                
<p class="parameter">
                        
<xsl:value-of select="@Name" />
                        
<xsl:if test="@DataElementGroup">
                                (Data Element Group: 
<xsl:value-of select="@DataElementGroup" />)
                        
</xsl:if>
                
</p>
                
<hr size="2" noshade="true" />
                
<xsl:if test="mostco:Description">
                        
<p class="description">
                                
<xsl:value-of disable-output-escaping="yes" select="mostco:Description/text()" />
                        
</p>
                
</xsl:if>
                
<xsl:apply-templates select="mostco:DataType/*" mode="parameter-table">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                
                        
<xsl:with-param name="function-name" select="$function-name" />
                
</xsl:apply-templates>
        
</xsl:template>
        
<!-- Level 4: Description of one shared parameter -->
        
<xsl:template match="*" mode="shared-parameter-description">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<!-- parameter table -->
                
<xsl:element name="a">
                        
<xsl:attribute name="name"><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:value-of select="parent::*/@Name" /></xsl:attribute>
                
</xsl:element>
                
<!-- heading -->
                
<p class="parameter">
                        
<xsl:value-of select="@Name" />
                        
<xsl:if test="@DataElementGroup">
                                (Data Element Group: 
<xsl:value-of select="@DataElementGroup" />)
                        
</xsl:if>
                
</p>
                
<hr size="2" noshade="true" />
                
<!-- <xsl:variable name="parameter-description" select="/*/SharedParameters/SharedParameter[@Name=current()/parent::*/@Name]/Parameter/Description"/> -->
                
<xsl:if test="mostco:Description">
                        
<p class="description">
                                
<xsl:value-of disable-output-escaping="yes" select="mostco:Description" />
                        
</p>
                
</xsl:if>
                
<!-- generate parameter table -->
                
<xsl:apply-templates select="mostco:DataType/*" mode="parameter-table">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                        
<xsl:with-param name="function-name" select="$function-name" />
                
</xsl:apply-templates>
        
</xsl:template>
                
<!-- Level 4: Description of one named shared parameter -->
        
<xsl:template match="*" mode="named-shared-parameter-description">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<!-- The next two parameters are used for name and description substitution in the reference -->
                
<xsl:param name="name-substitute" />
                
<xsl:param name="description-substitute" />
                
<!-- parameter table -->
                
<xsl:element name="a">
                        
<xsl:attribute name="name"><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:value-of select="parent::*/@Name" /></xsl:attribute>
                
</xsl:element>
                
<!-- heading -->
                
<p class="parameter">
                        
<xsl:value-of select="@Name[not($name-substitute)]|$name-substitute[$name-substitute]" />
                        
<xsl:if test="@DataElementGroup">
                                (Data Element Group: 
<xsl:value-of select="@DataElementGroup" />)
                        
</xsl:if>
                
</p>
                
<hr size="2" noshade="true" />
                
<!-- <xsl:variable name="parameter-description" select="/*/SharedParameters/SharedParameter[@Name=current()/parent::*/@Name]/Parameter/Description"/> -->
                
<xsl:if test="mostco:Description|$description-substitute">
                        
<p class="description">
                                
<xsl:value-of disable-output-escaping="yes" select="mostco:Description[not($description-substitute)]|$description-substitute[$description-substitute]" />
                        
</p>
                
</xsl:if>
                
<!-- generate parameter table -->
                
<xsl:apply-templates select="mostco:DataType/*" mode="parameter-table">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                        
                        
<xsl:with-param name="function-name" select="$function-name" />
                
</xsl:apply-templates>
        
</xsl:template>
        
<!-- *** FBlock details - Function - Parameter tables *** -->
        
<!-- *** Record (legacy) *** -->
        
<!-- Level 5: Parameter description for Record (legacy) and Record Type parameter -->
        
<xsl:template mode="parameter-table" match="mostco:TRecordLegacy | mostco:TRecordType">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<!-- Create parameter table for TRecord parameter -->
                
<xsl:apply-templates select="." mode="record-table">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                        
                        
<xsl:with-param name="function-name" select="$function-name" />
                
</xsl:apply-templates>
                
<!-- Create parameter description for TRecordField parameters -->
                
<xsl:apply-templates select="mostco:TRecordField|mostco:SharedRecordFieldReference|mostco:NamedSharedRecordFieldReference" mode="record-member-description">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                
                        
<xsl:with-param name="function-name" select="$function-name" />
                
</xsl:apply-templates>
        
</xsl:template>
        
<!-- Level 6: Create parameter table for TRecordLegacy parameter -->
        
<xsl:template mode="record-table" match="mostco:TRecordLegacy">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:variable name="PosCount" select="count(mostco:TRecordField|mostco:SharedRecordFieldReference|mostco:NamedSharedRecordFieldReference)" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat" colspan="2">Description</th>
                        
</tr>
                        
<tr>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$PosCount+2" /></xsl:attribute>
                                        
<xsl:text>Record</xsl:text>
                                
</xsl:element>
                                
<td class="paramformat">Pos</td>
                                
<td class="paramformat">Data</td>
                        
</tr>
                        
<tr>
                                
<td class="paramformat">
                                        
<!-- Entire table has to be fabricated, no more Pos descriptions -->
                                        
<xsl:text>{ x=0 }</xsl:text>
                                
</td>
                                
<td class="paramformat2">
                                        
<xsl:for-each select="mostco:TRecordField|mostco:SharedRecordFieldReference|mostco:NamedSharedRecordFieldReference">
                                                
<xsl:element name="a">
                                                        
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-record-field-name" select="." /></xsl:attribute>
                                                        
<xsl:apply-templates mode="resulting-record-field-name" select="." />
                                                
</xsl:element>
                                                
<xsl:choose>
                                                        
<xsl:when test="last()=position()" />
                                                        
<xsl:otherwise>
                                                                
<xsl:text></xsl:text>
                                                        
</xsl:otherwise>
                                                
</xsl:choose>
                                        
</xsl:for-each>
                                
</td>
                        
</tr>
                        
<!-- Create individual rows of the parameter table for TRecordLegacy -->
                        
<xsl:apply-templates mode="record-table-row" select="mostco:TRecordField">
                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                        
                                
<xsl:with-param name="function-name" select="$function-name" />
                        
</xsl:apply-templates>
                
</table>
        
</xsl:template>
        
<!-- Level 6: Create parameter table for TRecordType parameter -->
        
<xsl:template mode="record-table" match="mostco:TRecordType">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:variable name="PosCount" select="count(mostco:TRecordField|mostco:SharedRecordFieldReference|mostco:NamedSharedRecordFieldReference)" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat" colspan="2">Description</th>
                        
</tr>
                        
<tr>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:text>Record Type</xsl:text>
                                
</xsl:element>
                                
<td class="paramformat2">
                                        
<xsl:for-each select="mostco:TRecordField|mostco:SharedRecordFieldReference|mostco:NamedSharedRecordFieldReference">
                                                
<xsl:element name="a">
                                                        
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-record-field-name" select="." /></xsl:attribute>
                                                        
<xsl:apply-templates mode="resulting-record-field-name" select="." />
                                                
</xsl:element>
                                                
<xsl:choose>
                                                        
<xsl:when test="last()=position()" />
                                                        
<xsl:otherwise>
                                                                
<xsl:text></xsl:text>
                                                        
</xsl:otherwise>
                                                
</xsl:choose>
                                        
</xsl:for-each>
                                
</td>
                        
</tr>
                
</table>
        
</xsl:template>
        
<!-- Level 7: One row in the parameter table, containing one TRecordField of a TRecord -->
        
<xsl:template mode="record-table-row" match="mostco:TRecordField">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<tr>
                        
<td class="paramformat">
                                
<!-- Entire table has to be fabricated, no more Pos descriptions -->
                                
<xsl:text>{ x=</xsl:text>
                                
<xsl:value-of select="position()" />
                                
<xsl:text> }</xsl:text>
                        
</td>
                        
<td class="paramformat2">
                                
<xsl:element name="a">
                                        
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:value-of select="@Name" /></xsl:attribute>
                                        
<xsl:value-of select="@Name" />
                                
</xsl:element>
                        
</td>
                
</tr>
        
</xsl:template>
        
<!-- Level 6: Parameter description for Record field parameter -->
        
<xsl:template mode="record-member-description" match="mostco:TRecordField">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />
                
<xsl:param name="function-name" />
                
<p class="parameter">
                        
<xsl:element name="a">
                                
<xsl:attribute name="name"><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:value-of select="@Name" /></xsl:attribute>
                        
</xsl:element>
                        
<xsl:value-of select="@Name" />
                        
<xsl:if test="@DataElementGroup">
                                (Data Element Group: 
<xsl:value-of select="@DataElementGroup" />)
                        
</xsl:if>
                
</p>
                
<hr size="2" noshade="true" />
                
<xsl:if test="mostco:Description">
                        
<p class="description">
                                
<xsl:value-of disable-output-escaping="yes" select="mostco:Description" />
                        
</p>
                
</xsl:if>
                
<!-- Parameter description for contained parameter -->
                
<xsl:apply-templates select="mostco:DataType/*" mode="parameter-table">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                        
                        
<xsl:with-param name="function-name" select="$function-name" />
                        
<xsl:with-param name="ancestor-array-or-record" select="ancestor::mostco:TArrayLegacy|ancestor::mostco:TRecordLegacy" />
                
</xsl:apply-templates>
        
</xsl:template>
        
<!-- Level 6: Parameter description for Record field parameter as reference to shared element -->
        
<xsl:template mode="record-member-description" match="mostco:SharedRecordFieldReference">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<xsl:variable name="resulting-parameter-name">
                        
<xsl:value-of select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@Name]/mostco:Parameter/@Name" />
                
</xsl:variable>
                
<xsl:variable name="resulting-parameter-description">
                        
<xsl:value-of select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@Name]/mostco:Parameter/mostco:Description" />
                
</xsl:variable>
                
<p class="parameter">
                        
<xsl:element name="a">
                                
<xsl:attribute name="name"><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:value-of select="$resulting-parameter-name" /></xsl:attribute>
                        
</xsl:element>
                        
<xsl:value-of select="$resulting-parameter-name" />
                        
<xsl:if test="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@Name]/mostco:Parameter/@DataElementGroup">
                                (Data Element Group: 
<xsl:value-of select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@Name]/mostco:Parameter/@DataElementGroup" />)
                        
</xsl:if>
                
</p>
                
<hr size="2" noshade="true" />
                
<xsl:if test="not($resulting-parameter-description = '')">
                        
<p class="description">
                                
<xsl:value-of disable-output-escaping="yes" select="$resulting-parameter-description" />
                        
</p>
                
</xsl:if>
                
<!-- Parameter description for contained parameter -->
                
<xsl:apply-templates select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@Name]/mostco:Parameter/mostco:DataType/*" mode="parameter-table">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                        
                        
<xsl:with-param name="function-name" select="$function-name" />
                        
<!-- In the case of legacy array and record it is required to know if an ancestor is an array or record. The shared parameter does not have this information in its context so it has to be provided here.  -->
                        
<xsl:with-param name="ancestor-array-or-record" select="ancestor::mostco:TArrayLegacy|ancestor::mostco:TRecordLegacy" />
                
</xsl:apply-templates>
        
</xsl:template>
                
<!-- Level 6: Parameter description for Record field parameter as reference to shared element -->
        
<xsl:template mode="record-member-description" match="mostco:NamedSharedRecordFieldReference">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:variable name="resulting-parameter-name">
                        
<xsl:value-of select="@Name" />
                
</xsl:variable>
                
<xsl:variable name="resulting-parameter-description">
                        
<xsl:choose>
                                
<xsl:when test="mostco:Description">
                                        
<!-- The Description of the NamedSharedRecordFieldReference is used instead of the description of the referenced data element -->
                                        
<xsl:value-of select="mostco:Description" />
                                
</xsl:when>
                                
<xsl:otherwise>
                                        
<!-- No local shared parameter description found; the Description of the referenced data element is used -->
                                        
<xsl:value-of select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@NameRef]/mostco:Parameter/mostco:Description" />
                                
</xsl:otherwise>
                        
</xsl:choose>                
                
</xsl:variable>
                
<p class="parameter">
                        
<xsl:element name="a">
                                
<xsl:attribute name="name"><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:value-of select="$resulting-parameter-name" /></xsl:attribute>
                        
</xsl:element>
                        
<xsl:value-of select="$resulting-parameter-name" />
                        
<xsl:if test="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@NameRef]/mostco:Parameter/@DataElementGroup">
                                (Data Element Group: 
<xsl:value-of select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@NameRef]/mostco:Parameter/@DataElementGroup" />)
                        
</xsl:if>
                
</p>
                
<hr size="2" noshade="true" />
                
<xsl:if test="not($resulting-parameter-description = '')">
                        
<p class="description">
                                
<xsl:value-of disable-output-escaping="yes" select="$resulting-parameter-description" />
                        
</p>
                
</xsl:if>
                
<!-- Parameter description for contained parameter -->
                
<xsl:apply-templates select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@NameRef]/mostco:Parameter/mostco:DataType/*" mode="parameter-table">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                        
                        
<xsl:with-param name="function-name" select="$function-name" />
                        
<!-- In the case of legacy array and record it is required to know if an ancestor is an array or record. The shared parameter does not have this information in its context so it has to be provided here.  -->
                        
<xsl:with-param name="ancestor-array-or-record" select="ancestor::mostco:TArrayLegacy|ancestor::mostco:TRecordLegacy" />
                
</xsl:apply-templates>
        
</xsl:template>
        
<!-- *** Array (legacy) *** -->
        
<!-- Level 5: Parameter description for Array parameter -->
        
<xsl:template mode="parameter-table" match="mostco:TArrayLegacy">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:param name="ancestor-array-or-record" />
                
<xsl:choose>
                        
<!-- If the array is embedded within another array or a record, no detailed Position table is required -->
                        
<xsl:when test="$ancestor-array-or-record">
                                
<xsl:apply-templates select="." mode="simple-array-table">
                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                
                                        
<xsl:with-param name="function-name" select="$function-name" />
                                
</xsl:apply-templates>
                                
<xsl:apply-templates select="." mode="array-parameter-description">
                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                                        
                                        
<xsl:with-param name="function-name" select="$function-name" />
                                
</xsl:apply-templates>
                        
</xsl:when>
                        
<xsl:otherwise>
                                
<xsl:choose>
                                        
<xsl:when test="mostco:DataType/mostco:TRecordLegacy|/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy">
                                                
<xsl:apply-templates select="." mode="array-of-record-table">
                                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                                                        
                                                        
<xsl:with-param name="function-name" select="$function-name" />
                                                
</xsl:apply-templates>
                                                
<xsl:apply-templates select="mostco:DataType/mostco:TRecordLegacy/mostco:TRecordField| mostco:DataType/mostco:TRecordLegacy/mostco:SharedRecordFieldReference| mostco:DataType/mostco:TRecordLegacy/mostco:NamedSharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:TRecordField| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:SharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@NameRef]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:NamedSharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:NamedSharedDataElementReference/@NameRef]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:TRecordField| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:NamedSharedDataElementReference/@NameRef]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:SharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:NamedSharedDataElementReference/@NameRef]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:NamedSharedRecordFieldReference" mode="record-member-description">
                                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                
                                                        
<xsl:with-param name="function-name" select="$function-name" />
                                                
</xsl:apply-templates>
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:apply-templates select="." mode="structured-array-parameter-table">
                                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                
                                                        
<xsl:with-param name="function-name" select="$function-name" />
                                                
</xsl:apply-templates>
                                                
<xsl:apply-templates select="." mode="array-parameter-description">
                                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                
                                                        
<xsl:with-param name="function-name" select="$function-name" />
                                                
</xsl:apply-templates>
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- Helper template to determine the desired parameter name for a shared record field reference -->
        
<xsl:template mode="resulting-record-field-name" match="*">
                
<xsl:choose>
                        
<xsl:when test="self::mostco:SharedRecordFieldReference">
                                                
<xsl:value-of select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@Name]/mostco:Parameter/@Name" />
                        
</xsl:when>
                        
<xsl:otherwise>
                                
<!-- TRecordField or NamedSharedRecordFieldReference-->
                                
<xsl:value-of select="@Name" />
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- Helper template to determine the desired parameter name for a shared data element reference -->
        
<xsl:template mode="resulting-data-element-name" match="*">
                
<xsl:choose>
                        
<xsl:when test="self::mostco:TArrayType|self::mostco:TArrayLegacy and @Name">
                                
<xsl:value-of select="@Name" />
                        
</xsl:when>
                        
<xsl:otherwise>
                                
<xsl:choose>
                                        
<xsl:when test="mostco:SharedDataElementReference">
                                                                
<xsl:value-of select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/@Name" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<!-- Data element or NamedSharedDataElementReference-->                        
                                                
<xsl:value-of select="@Name" />
                                        
</xsl:otherwise>
                                
</xsl:choose>                        
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- Helper template to determine the desired parameter name for a parameter reference -->
        
<xsl:template mode="actual-parameter-name" match="*">
                
<xsl:choose>
                        
<xsl:when test="../../../mostco:Parameters/mostco:Parameter[@Name=current()/@Name]">
                                
<!-- There is a parameter by this name so that is it -->
                                
<xsl:value-of select="@Name" />
                        
</xsl:when>
                        
<xsl:otherwise>
                                
<xsl:choose>
                                        
<xsl:when test="../../../mostco:Parameters/mostco:NamedSharedParameterReference[@Name=current()/@Name]">
                                                
<!-- There is a substituted name -->
                                                
<xsl:value-of select="../../../mostco:Parameters/mostco:NamedSharedParameterReference[@Name=current()/@Name]/@Name" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<!-- Neither local, nor substituted, grab it from the shared parameter -->
                                                
<xsl:value-of select="/*/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@Name]/mostco:Parameter/@Name" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- *** Array (legacy) - Simple type elements -->
        
<!-- Level 6: Parameter table for Array parameter in array of simple type -->
        
<xsl:template mode="structured-array-parameter-table" match="mostco:TArrayLegacy">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<xsl:if test="@MaxElementCount">
                                        
<th class="paramformat">Max. element count</th>
                                
</xsl:if>
                                
<th class="paramformat" colspan="2">Description</th>
                        
</tr>
                        
<tr>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="4" /></xsl:attribute>
                                        
<xsl:text>Array</xsl:text>
                                
</xsl:element>
                                
<xsl:if test="@MaxElementCount">
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                                
<xsl:attribute name="rowspan"><xsl:value-of select="4" /></xsl:attribute>
                                                
<xsl:value-of select="@MaxElementCount" />
                                        
</xsl:element>
                                
</xsl:if>
                                
<td class="paramformat">Pos</td>
                                
<td class="paramformat">Data</td>
                        
</tr>
                        
<!-- first row with data -->
                        
<tr>
                                
<td class="paramformat">
                                        
<xsl:text>{ x=0 }</xsl:text>
                                
</td>
                                
<td class="paramformat2">
                                        
<xsl:element name="a">
                                                
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-data-element-name" select="." /></xsl:attribute>
                                                
<xsl:apply-templates mode="resulting-data-element-name" select="." />
                                        
</xsl:element>
                                        
<xsl:text>[1]</xsl:text>
                                        
<xsl:text></xsl:text>
                                        
<xsl:element name="a">
                                                
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-data-element-name" select="." /></xsl:attribute>
                                                
<xsl:apply-templates mode="resulting-data-element-name" select="." />
                                        
</xsl:element>
                                        
<xsl:text>[2]</xsl:text>
                                        
<xsl:text>,..., </xsl:text>
                                        
<xsl:element name="a">
                                                
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-data-element-name" select="." /></xsl:attribute>
                                                
<xsl:apply-templates mode="resulting-data-element-name" select="." />
                                        
</xsl:element>
                                        
<xsl:choose>
                                                
<xsl:when test="@MaxElementCount">[<xsl:value-of select="@MaxElementCount" />]</xsl:when>
                                                
<xsl:otherwise>
                                                        
<xsl:text>[NMax]</xsl:text>
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</td>
                        
</tr>
                        
<!-- second row with data -->
                        
<tr>
                                
<td class="paramformat">
                                        
<xsl:text>{ x&gt;0 }</xsl:text>
                                
</td>
                                
<td class="paramformat2">
                                        
<xsl:element name="a">
                                                
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-data-element-name" select="." /></xsl:attribute>
                                                
<xsl:apply-templates mode="resulting-data-element-name" select="." />
                                        
</xsl:element>
                                        
<xsl:text>[x]</xsl:text>
                                
</td>
                        
</tr>
                
</table>
        
</xsl:template>
        
<!-- Level 6: Simple parameter table for Array parameter that is not the outermost parameter. No PosX/PosY descriptions are generated. -->
        
<xsl:template mode="simple-array-table" match="mostco:TArrayLegacy">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<xsl:if test="@MaxElementCount">
                                        
<th class="paramformat">Max. element count</th>
                                
</xsl:if>
                                
<th class="paramformat">Element type</th>
                                
<th class="paramformat">Element name</th>
                        
</tr>
                        
<tr>
                                
<td class="paramformat">Array</td>
                                
<xsl:if test="@MaxElementCount">
                                        
<td class="paramformat">
                                                
<xsl:value-of select="@MaxElementCount" />
                                        
</td>
                                
</xsl:if>
                                
<td class="paramformat">
                                        
<xsl:apply-templates mode="get-param-type-name" select="mostco:DataType/*|/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/*" />
                                
</td>
                                
<td class="paramformat">
                                        
<xsl:element name="a">
                                                
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-data-element-name" select="." /></xsl:attribute>
                                                
<xsl:apply-templates mode="resulting-data-element-name" select="." />
                                        
</xsl:element>
                                
</td>
                        
</tr>
                
</table>
        
</xsl:template>
        
<!-- *** Array (legacy) - Record elements *** -->
        
<!-- Level 6: Parameter table for Array parameter in array of record -->
        
<xsl:template mode="array-of-record-table" match="mostco:TArrayLegacy">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<xsl:variable name="PosCount" select="count(descendant::mostco:TRecordField| descendant::mostco:SharedRecordFieldReference| descendant::mostco:NamedSharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]//mostco:TRecordField| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]//mostco:SharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]//mostco:NamedSharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:NamedSharedDataElementReference/@NameRef]//mostco:TRecordField| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:NamedSharedDataElementReference/@NameRef]//mostco:SharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:NamedSharedDataElementReference/@NameRef]//mostco:NamedSharedRecordFieldReference)" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<xsl:if test="@MaxElementCount">
                                        
<th class="paramformat">Max. element count</th>
                                
</xsl:if>
                                
<th class="paramformat" colspan="2">Description</th>
                        
</tr>
                        
<tr>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$PosCount+3" /></xsl:attribute>
                                        
<xsl:text>Array</xsl:text>
                                
</xsl:element>
                                
<xsl:if test="@MaxElementCount">
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                                
<xsl:attribute name="rowspan"><xsl:value-of select="$PosCount+3" /></xsl:attribute>
                                                
<xsl:value-of select="@MaxElementCount" />
                                        
</xsl:element>
                                
</xsl:if>
                                
<td class="paramformat">Pos</td>
                                
<td class="paramformat">Data</td>
                        
</tr>
                        
<xsl:apply-templates mode="first-row-array-of-record" select="mostco:DataType/mostco:TRecordLegacy|/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy">
                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                        
                                
<xsl:with-param name="function-name" select="$function-name" />
                                
<xsl:with-param name="max-element-count" select="@MaxElementCount" />
                        
</xsl:apply-templates>
                        
<xsl:apply-templates mode="second-row-array-of-record" select="mostco:DataType/mostco:TRecordLegacy|/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy">
                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                
<xsl:with-param name="function-name" select="$function-name" />
                        
</xsl:apply-templates>
                        
<xsl:apply-templates mode="row-array-of-record" select="mostco:DataType/mostco:TRecordLegacy/mostco:TRecordField| mostco:DataType/mostco:TRecordLegacy/mostco:SharedRecordFieldReference| mostco:DataType/mostco:TRecordLegacy/mostco:NamedSharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:TRecordField| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:SharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:NamedSharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:NamedSharedDataElementReference/@NameRef]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:TRecordField| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:NamedSharedDataElementReference/@NameRef]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:SharedRecordFieldReference| /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:NamedSharedDataElementReference/@NameRef]/mostco:Parameter/mostco:DataType/mostco:TRecordLegacy/mostco:NamedSharedRecordFieldReference">
                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                
<xsl:with-param name="function-name" select="$function-name" />
                        
</xsl:apply-templates>
                
</table>
        
</xsl:template>
        
<!-- Level 7: The first row in the parameter table of the outermost array of record, containing all TRecordFields of a TRecord -->
        
<xsl:template mode="first-row-array-of-record" match="mostco:TRecordLegacy">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<!-- @MaxElementCount is an optional attribute of the bounding array. Because the record might be a shared parameter, there could be no access to the array. Therefore, the max. count is passed as a parameter. -->
                
<xsl:param name="max-element-count" />
                
<tr>
                        
<td class="paramformat">
                                
<!-- Entire table has to be generated from scratch, PosDescription elements no longer exist-->
                                
<xsl:text>{ x=0, y=0 }</xsl:text>
                        
</td>
                        
<td class="paramformat2">
                                
<xsl:for-each select="mostco:TRecordField|mostco:SharedRecordFieldReference|mostco:NamedSharedRecordFieldReference">
                                        
<xsl:element name="a">
                                                
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-record-field-name" select="." /></xsl:attribute>
                                                
<xsl:apply-templates mode="resulting-record-field-name" select="." />
                                        
</xsl:element>
                                        
<xsl:text>[1]</xsl:text>
                                        
<xsl:choose>
                                                
<xsl:when test="position() = last()">
                                                        
<xsl:text>,</xsl:text>
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<xsl:text></xsl:text>
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:for-each>
                                
<xsl:text>..., </xsl:text>
                                
<xsl:for-each select="mostco:TRecordField|mostco:SharedRecordFieldReference|mostco:NamedSharedRecordFieldReference">
                                        
<xsl:element name="a">
                                                
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-record-field-name" select="." /></xsl:attribute>
                                                
<xsl:apply-templates mode="resulting-record-field-name" select="." />
                                        
</xsl:element>
                                        
<xsl:choose>
                                                
<xsl:when test="$max-element-count">[<xsl:value-of select="$max-element-count" />]</xsl:when>
                                                
<xsl:otherwise>
                                                        
<xsl:text>[NMax]</xsl:text>
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                        
<xsl:choose>
                                                
<xsl:when test="last()=position()" />
                                                
<xsl:otherwise>
                                                        
<xsl:text></xsl:text>
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:for-each>
                        
</td>
                
</tr>
        
</xsl:template>
        
<!-- Level 7: The second row in the parameter table of the outermost array of record, containing all TRecordFields of a TRecord -->
        
<xsl:template mode="second-row-array-of-record" match="mostco:TRecordLegacy">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<tr>
                        
<td class="paramformat">
                                
<!-- Entire table has to be generated, no more Pos descriptions -->
                                
<xsl:text>{ x&gt;0, y=0 }</xsl:text>
                        
</td>
                        
<td class="paramformat2">
                                
<xsl:for-each select="mostco:TRecordField|mostco:SharedRecordFieldReference|mostco:NamedSharedRecordFieldReference">
                                        
<xsl:element name="a">
                                                
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-record-field-name" select="." /></xsl:attribute>
                                                
<xsl:apply-templates mode="resulting-record-field-name" select="." />
                                        
</xsl:element>
                                        
<xsl:text>[x]</xsl:text>
                                        
<xsl:choose>
                                                
<xsl:when test="position() = last()" />
                                                
<xsl:otherwise>
                                                        
<xsl:text></xsl:text>
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:for-each>
                        
</td>
                
</tr>
        
</xsl:template>
        
<!-- Level 7: One subsequent row in the parameter table of the outermost array of record, containing one TRecordField of a TRecord -->
        
<xsl:template mode="row-array-of-record" match="mostco:TRecordField|mostco:SharedRecordFieldReference|mostco:NamedSharedRecordFieldReference">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<!-- <xsl:comment> Record-Tab-Element </xsl:comment>   -->
                
<tr>
                        
<td class="paramformat">
                                
<!-- Entire table has to be generated, no more Pos descriptions -->
                                
<xsl:text>{ x&gt;0, y=</xsl:text>
                                
<xsl:value-of select="position()" />
                                
<xsl:text> }</xsl:text>
                        
</td>
                        
<td class="paramformat2">
                                
<xsl:element name="a">
                                        
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-record-field-name" select="." /></xsl:attribute>
                                        
<xsl:apply-templates mode="resulting-record-field-name" select="." />
                                
</xsl:element>
                                
<xsl:text>[x]</xsl:text>
                        
</td>
                
</tr>
                
<!-- table generation for array of record ends here -->
        
</xsl:template>
        
<!-- *** Array Type *** -->
        
<!-- Level 5: Parameter description for Array Type -->
        
<xsl:template mode="parameter-table" match="mostco:TArrayType">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:apply-templates select="." mode="simple-array-table">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                        
<xsl:with-param name="function-name" select="$function-name" />
                
</xsl:apply-templates>
                
<xsl:apply-templates select="." mode="array-parameter-description">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                        
<xsl:with-param name="function-name" select="$function-name" />
                
</xsl:apply-templates>
        
</xsl:template>
        
<!-- Level 6: Simple parameter table for Array Type parameter. -->
        
<xsl:template mode="simple-array-table" match="mostco:TArrayType">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat">ElementCount size</th>
                                
<xsl:if test="@MaxElementCount">
                                        
<th class="paramformat">Max. element count</th>
                                
</xsl:if>
                                
<th class="paramformat">Element type</th>
                                
<th class="paramformat">Element name</th>
                        
</tr>
                        
<tr>
                                
<td class="paramformat">Array Type</td>
                                
<td class="paramcode2">
                                        
<xsl:value-of select="@ElementCountByteLength" />
                                
</td>
                                
<xsl:if test="@MaxElementCount">
                                        
<td class="paramcode2">
                                                
<xsl:value-of select="@MaxElementCount" />
                                        
</td>
                                
</xsl:if>
                                
<td class="paramformat">
                                        
<xsl:apply-templates mode="get-param-type-name" select="mostco:DataType/* | /mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/*[@Name]/@Name]/mostco:Parameter/mostco:DataType/*" />
                                
</td>
                                
<td class="paramformat">
                                        
<xsl:element name="a">
                                                
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-data-element-name" select="." /></xsl:attribute>
                                                
<xsl:apply-templates mode="resulting-data-element-name" select="." />
                                        
</xsl:element>
                                
</td>
                        
</tr>
                
</table>
        
</xsl:template>
        
<!-- Level 6: Helper template for Array (legacy) and Array Type description -->
        
<xsl:template mode="array-parameter-description" match="mostco:TArrayLegacy|mostco:TArrayType">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                                                
                
<xsl:param name="function-name" />
                
<p class="parameter">
                        
<xsl:element name="a">
                                
<xsl:attribute name="name"><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:apply-templates mode="resulting-data-element-name" select="." /></xsl:attribute>
                        
</xsl:element>
                        
<xsl:apply-templates mode="resulting-data-element-name" select="." />
                
</p>
                
<hr size="2" noshade="true" />
                
<xsl:variable name="resulting-parameter-description">
                        
<xsl:choose>
                                
<xsl:when test="mostco:SharedDataElementReference">
                                        
<!-- If a SharedDataElementReference exists, the @Description element of TArrayType is ignored. -->
                                        
<xsl:choose>
                                                
<xsl:when test="mostco:SharedDataElementReference/mostco:Description">
                                                        
<!-- The Description of the SharedDataElementReference is used instead of the description of the referenced data element -->
                                                        
<xsl:value-of select="mostco:SharedDataElementReference/mostco:Description" />
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<!-- No local shared parameter description found; the Description of the referenced data element is used -->
                                                        
<xsl:value-of select="/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/*[@Name]/@Name]/mostco:Parameter/mostco:Description" />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:when>
                                
<xsl:otherwise>
                                        
<!-- If there is no shared data element reference, use the @Name and Description of TArrayType -->
                                        
<xsl:value-of select="SharedDataElementReference/@NameSubstitute" />
                                
</xsl:otherwise>
                        
</xsl:choose>
                
</xsl:variable>
                
<xsl:if test="not($resulting-parameter-description = '')">
                        
<p class="description">
                                
<xsl:value-of disable-output-escaping="yes" select="$resulting-parameter-description" />
                        
</p>
                
</xsl:if>
                
<xsl:apply-templates select="mostco:DataType/*[not(current()/mostco:SharedDataElementReference)]|/mostco:FunctionCatalog/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/mostco:SharedDataElementReference/@Name]/mostco:Parameter/mostco:DataType/*" mode="parameter-table">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                                                        
                        
<xsl:with-param name="function-name" select="$function-name" />
                
</xsl:apply-templates>
        
</xsl:template>
        
<!-- *** Boolean *** -->
        
<!-- Level 5: Parameter description for Boolean -->
        
<xsl:template mode="parameter-table" match="mostco:TBoolean">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                        
</tr>
                        
<tr>
                                
<td class="paramformat">Boolean</td>
                        
</tr>
                
</table>
        
</xsl:template>
        
<!-- *** BitField *** -->
        
<!-- Level 5: Parameter description for TBitField -->
        
<xsl:template mode="parameter-table" match="mostco:TBitField">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:variable name="BitValueCount" select="count(mostco:BitValue)" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat">Name</th>
                                
<th class="paramformat">Position (Bit)</th>
                                
<th class="paramformat">Length (Bit)</th>
                                
<th class="paramformat">Value</th>
                                
<th class="paramformat">Description</th>
                        
</tr>
                        
<tr>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$BitValueCount*2" /></xsl:attribute>
                                        
<xsl:text>BitField</xsl:text>
                                        
<br />
                                        
<xsl:text>Size: </xsl:text>
                                        
<xsl:value-of select="@TotalByteLength" />
                                
</xsl:element>
                                
<td rowspan="2" class="paramformat"><xsl:value-of select="mostco:BitValue[1]/@Name" /></td>
                                
<td rowspan="2" class="paramcode2"><xsl:value-of select="mostco:BitValue[1]/@BitPos" /></td>                
                                
<td rowspan="2" class="paramcode2"><xsl:value-of select="mostco:BitValue[1]/@BitLength|$default-bitlength[not(mostco:BitValue[1]/@BitLength)]" /></td>
                                
<td class="paramformat">False</td>
                                
<td class="paramformat2">
                                        
<xsl:value-of select="mostco:BitValue[1]/@FalseDisplayName" />
                                
</td>
                        
</tr>
                        
<tr>
                                
<td class="paramformat">True</td>
                                
<td class="paramformat2">
                                        
<xsl:value-of select="mostco:BitValue[1]/@TrueDisplayName" />
                                
</td>
                        
</tr>
                        
<xsl:if test="$BitValueCount &gt; 1">
                                
<xsl:apply-templates mode="row-bool-field" select="mostco:BitValue[position()&gt;1 and last()&gt;position()]" />
                                
<xsl:variable name="range" select="mostco:BitValue[last()]/@FalseDisplayName" />
                                
<tr>
                                        
<td rowspan="2" class="paramformat"><xsl:value-of select="mostco:BitValue[last()]/@Name" /></td>
                                        
<td rowspan="2" class="paramcode2"><xsl:value-of select="mostco:BitValue[last()]/@BitPos" /></td>                
                                        
<td rowspan="2" class="paramcode2"><xsl:value-of select="mostco:BitValue[last()]/@BitLength|$default-bitlength[not(mostco:BitValue[last()]/@BitLength)]" /></td>                        
                                        
<td class="paramformat">False</td>
                                        
<td class="paramformat2">
                                                
<xsl:value-of select="mostco:BitValue[last()]/@FalseDisplayName" />
                                        
</td>
                                
</tr>
                                
<tr>
                                        
<td class="paramformat">True</td>
                                        
<td class="paramformat2">
                                                
<xsl:value-of select="mostco:BitValue[last()]/@TrueDisplayName" />
                                        
</td>
                                
</tr>
                        
</xsl:if>
                
</table>
        
</xsl:template>
        
<!-- Level 6: Create one row in the BoolField table -->
        
<xsl:template mode="row-bool-field" match="mostco:BitValue[position()&gt;1 and last()&gt;position()]">
                
<tr>
                        
<td rowspan="2" class="paramformat"><xsl:value-of select="@Name" /></td>
                        
<td rowspan="2" class="paramcode2"><xsl:value-of select="@BitPos" /></td>                
                        
<td rowspan="2" class="paramcode2"><xsl:value-of select="@BitLength|$default-bitlength[not (@BitLength)]" /></td>                
                        
<td class="paramformat">False</td>
                        
<td class="paramformat2">
                                
<xsl:value-of select="@FalseDisplayName" />
                        
</td>
                
</tr>
                
<tr>
                        
<td class="paramformat">True</td>
                        
<td class="paramformat2">
                                
<xsl:value-of select="@TrueDisplayName" />
                        
</td>
                
</tr>
        
</xsl:template>
        
<!-- *** String *** -->
        
<!-- Level 5: Parameter description for String -->
        
<xsl:template mode="parameter-table" match="mostco:TString">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat">MaxSize</th>
                        
</tr>
                        
<tr>
                                
<td class="paramformat">String</td>
                                
<td class="paramformat">
                                        
<xsl:value-of select="@MaxSize" />
                                
</td>
                        
</tr>
                
</table>
        
</xsl:template>
        
<!-- *** Length-coded String *** -->
        
<!-- Level 5: Parameter description for Length-coded String -->
        
<xsl:template mode="parameter-table" match="mostco:TLengthCodedString">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat">MaxSize</th>
                        
</tr>
                        
<tr>
                                
<td class="paramformat">Length-coded String</td>
                                
<td class="paramformat">
                                        
<xsl:value-of select="@MaxSize" />
                                
</td>
                        
</tr>
                
</table>
        
</xsl:template>
        
<!-- *** Integer data types *** -->
        
<!-- Level 5: Parameter description for Integer data types -->
        
<xsl:template mode="parameter-table" match="mostco:TUByte | mostco:TSByte | mostco:TUWord | mostco:TSWord | mostco:TULong | mostco:TSLong | mostco:TULongLong | mostco:TSLongLong">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:variable name="number-of-rows">
                        
<xsl:choose>
                                
<xsl:when test="count(mostco:ValueRange) = 0">
                                        
<xsl:number value="1" />
                                
</xsl:when>
                                
<xsl:otherwise>
                                        
<xsl:number value="count(mostco:ValueRange)" />
                                        
<xsl:apply-templates />
                                
</xsl:otherwise>
                        
</xsl:choose>
                
</xsl:variable>
                
<xsl:variable name="value-name-exists" select="mostco:ValueRange/@Name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat">Unit</th>
                                
<th class="paramformat">Exp.</th>
                                
<th class="paramformat">Step</th>
                                
<xsl:if test="mostco:ValueRange">
                                        
<th class="paramformat">Range of values</th>
                                        
<xsl:if test="$value-name-exists = true()">
                                                
<th class="paramformat">Name</th>
                                        
</xsl:if>
                                        
<th class="paramformat">Range description</th>
                                
</xsl:if>
                        
</tr>
                        
<tr>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-rows" /></xsl:attribute>
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:choose>
                                                
<xsl:when test="name(.)='TUByte'">
                                                        
<xsl:text>Unsigned Byte</xsl:text>
                                                
</xsl:when>
                                                
<xsl:when test="name(.)='TSByte'">
                                                        
<xsl:text>Signed Byte</xsl:text>
                                                
</xsl:when>
                                                
<xsl:when test="name(.)='TUWord'">
                                                        
<xsl:text>Unsigned Word</xsl:text>
                                                
</xsl:when>
                                                
<xsl:when test="name(.)='TSWord'">
                                                        
<xsl:text>Signed Word</xsl:text>
                                                
</xsl:when>
                                                
<xsl:when test="name(.)='TULong'">
                                                        
<xsl:text>Unsigned Long</xsl:text>
                                                
</xsl:when>
                                                
<xsl:when test="name(.)='TSLong'">
                                                        
<xsl:text>Signed Long</xsl:text>
                                                
</xsl:when>
                                                
<xsl:when test="name(.)='TULongLong'">
                                                        
<xsl:text>Unsigned Long Long</xsl:text>
                                                
</xsl:when>
                                                
<xsl:when test="name(.)='TSLongLong'">
                                                        
<xsl:text>Signed Long Long</xsl:text>
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<ERROR-TAG />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:element>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-rows" /></xsl:attribute>
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:choose>
                                                
<xsl:when test="@Unit">
                                                        
<xsl:value-of select="@Unit" />
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<xsl:value-of select="$default-unit" />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:element>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-rows" /></xsl:attribute>
                                        
<xsl:attribute name="class"><xsl:text>paramcode2</xsl:text></xsl:attribute>
                                        
<xsl:choose>
                                                
<xsl:when test="@Exponent">
                                                        
<xsl:value-of select="@Exponent" />
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<xsl:value-of select="$default-exponent" />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:element>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-rows" /></xsl:attribute>
                                        
<xsl:attribute name="class"><xsl:text>paramcode2</xsl:text></xsl:attribute>
                                        
<xsl:choose>
                                                
<xsl:when test="@Step">
                                                        
<xsl:value-of select="@Step" />
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<xsl:value-of select="$default-step" />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:element>
                                
<xsl:if test="mostco:ValueRange">
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>paramcode2</xsl:text></xsl:attribute>
                                                
<xsl:value-of select="mostco:ValueRange[1]/@Min" />
                                                
<xsl:if test="mostco:ValueRange[1]/@Min != mostco:ValueRange[1]/@Max">
                                                        
<xsl:text>...</xsl:text>
                                                        
<xsl:value-of select="mostco:ValueRange[1]/@Max" />
                                                
</xsl:if>
                                        
</xsl:element>
                                        
<xsl:if test="$value-name-exists">
                                                
<xsl:element name="td">
                                                        
<xsl:attribute name="class"><xsl:text>paramformat2</xsl:text></xsl:attribute>
                                                        
<xsl:value-of select="mostco:ValueRange[1]/@Name" />
                                                
</xsl:element>
                                        
</xsl:if>
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>paramformat2</xsl:text></xsl:attribute>
                                                
<xsl:value-of select="mostco:ValueRange[1]/mostco:Description" />
                                        
</xsl:element>
                                
</xsl:if>
                        
</tr>
                        
<xsl:if test="mostco:ValueRange">
                                
<xsl:apply-templates mode="parameter-table-row" select="mostco:ValueRange[position() &gt; 1]">
                                        
<xsl:with-param name="value-name-exists" select="$value-name-exists" />
                                
</xsl:apply-templates>
                        
</xsl:if>
                
</table>
                
                
<!-- Create table of bit-oriented values -->
                
<xsl:if test="mostco:BitOriented">
                        
<p class="emphasis">
                                        
<xsl:text>Bit-oriented values for </xsl:text><xsl:value-of select="../../@Name" />
                        
</p>
                        
<table border="1" cellpadding="3" cellspacing="0">
                                
<tr>
                                        
<th class="paramformat">Name</th>
                                        
<th class="paramformat">Position (Bit)</th>
                                        
<th class="paramformat">Length (Bit)</th>                
                                        
<th class="paramformat">Description</th>                                                        
                                
</tr>
                                
<xsl:apply-templates mode="bit-oriented-table-row" select="mostco:BitOriented" />
                        
</table>
                
</xsl:if>
        
</xsl:template>
        
        
<!-- Level 6: One row in the table for bit-oriented values -->        
        
<xsl:template mode="bit-oriented-table-row" match="mostco:BitOriented">
                
<tr>
                        
<td class="paramformat2"><xsl:value-of select="@Name" /></td>
                        
<td class="paramcode2"><xsl:value-of select="@BitPos" /></td>
                        
<td class="paramcode2"><xsl:value-of select="@BitLength|$default-bitlength[not (@BitLength)]" /></td>
                        
<td class="paramformat2"><xsl:value-of select="mostco:Description" /></td>
                
</tr>        
        
</xsl:template>
                
        
<!-- Level 6: One row in the table for ValueRange -->
        
<xsl:template mode="parameter-table-row" match="mostco:ValueRange">
                
<xsl:param name="value-name-exists" />
                
<tr>
                        
<td class="paramcode2">
                                
<xsl:value-of select="@Min" />
                                
<xsl:if test="@Min != @Max">
                                        
<xsl:text>...</xsl:text>
                                        
<xsl:value-of select="@Max" />
                                
</xsl:if>
                        
</td>
                        
<xsl:if test="$value-name-exists">
                                
<xsl:element name="td">
                                        
<xsl:attribute name="class"><xsl:text>paramformat2</xsl:text></xsl:attribute>
                                        
<xsl:value-of select="@Name" />
                                
</xsl:element>
                        
</xsl:if>
                        
<td class="paramformat2">
                                
<xsl:value-of select="mostco:Description" />
                        
</td>
                
</tr>
        
</xsl:template>
        
<!-- *** Floating point data types *** -->
        
<!-- Level 5: Parameter description for floating point data types -->
        
<xsl:template mode="parameter-table" match="mostco:TFloat|mostco:TDouble">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:variable name="number-of-rows">
                        
<xsl:choose>
                                
<xsl:when test="count(mostco:ValueRange) = 0">
                                        
<xsl:number value="1" />
                                
</xsl:when>
                                
<xsl:otherwise>
                                        
<xsl:number value="count(mostco:ValueRange)" />
                                        
<xsl:apply-templates />
                                
</xsl:otherwise>
                        
</xsl:choose>
                
</xsl:variable>
                
<xsl:variable name="value-name-exists" select="mostco:ValueRange/@Name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat">Unit</th>
                                
<xsl:if test="mostco:ValueRange">
                                        
<th class="paramformat">Range of values</th>
                                        
<xsl:if test="$value-name-exists = true()">
                                                
<th class="paramformat">Name</th>
                                        
</xsl:if>
                                        
<th class="paramformat">Range description</th>
                                
</xsl:if>
                        
</tr>
                        
<tr>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-rows" /></xsl:attribute>
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:choose>
                                                
<xsl:when test="name(.)='TFloat'">
                                                        
<xsl:text>Float</xsl:text>
                                                
</xsl:when>
                                                
<xsl:when test="name(.)='TDouble'">
                                                        
<xsl:text>Double</xsl:text>
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<ERROR-TAG />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:element>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-rows" /></xsl:attribute>
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:choose>
                                                
<xsl:when test="@Unit">
                                                        
<xsl:value-of select="@Unit" />
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<xsl:value-of select="$default-unit" />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:element>
                                
<xsl:if test="mostco:ValueRange">
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>paramcode2</xsl:text></xsl:attribute>
                                                
<xsl:value-of select="mostco:ValueRange[1]/@Min" />
                                                
<xsl:if test="mostco:ValueRange[1]/@Min != mostco:ValueRange[1]/@Max">
                                                        
<xsl:text>...</xsl:text>
                                                        
<xsl:value-of select="mostco:ValueRange[1]/@Max" />
                                                
</xsl:if>
                                        
</xsl:element>
                                        
<xsl:if test="$value-name-exists">
                                                
<xsl:element name="td">
                                                        
<xsl:attribute name="class"><xsl:text>paramformat2</xsl:text></xsl:attribute>
                                                        
<xsl:value-of select="mostco:ValueRange[1]/@Name" />
                                                
</xsl:element>
                                        
</xsl:if>
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>paramformat2</xsl:text></xsl:attribute>
                                                
<xsl:value-of select="mostco:ValueRange[1]/mostco:Description" />
                                        
</xsl:element>
                                
</xsl:if>
                        
</tr>
                                                
<xsl:if test="mostco:ValueRange">
                                
<xsl:apply-templates mode="parameter-table-row" select="mostco:ValueRange[position() &gt; 1]">
                                        
<xsl:with-param name="value-name-exists" select="$value-name-exists" />
                                
</xsl:apply-templates>
                        
</xsl:if>
                
</table>
        
</xsl:template>
        
<!-- *** Classified Stream *** -->
        
<!-- Level 5: Parameter description for Classified Stream -->
        
<xsl:template mode="parameter-table" match="mostco:TCStream">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat">Length</th>
                                
<th class="paramformat">Media type</th>
                        
</tr>
                        
<tr>
                                
<td class="paramformat">Classified Stream</td>
                                
<td class="paramcode2">
                                        
<xsl:value-of select="@MaxLength" />
                                
</td>
                                
<td class="paramformat">
                                        
<xsl:value-of select="@MediaType" />
                                
</td>
                        
</tr>
                
</table>
        
</xsl:template>
        
<!-- *** Stream and Short Stream *** -->
        
<!-- Level 5: Parameter description for Stream and Short Stream -->
        
<xsl:template mode="parameter-table" match="mostco:TShortStream|mostco:TStream">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:variable name="StreamCaseCount" select="count(mostco:StreamSwitch/mostco:ParamStreamCase)" />
                
<xsl:choose>
                        
<xsl:when test="$StreamCaseCount=0">
                                
<!-- Only a parameter or signal sequence present -->
                                
<xsl:apply-templates mode="zero-stream-case-table" select=".">
                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
 
                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                        
<xsl:with-param name="function-name" select="$function-name" />
                                
</xsl:apply-templates>
                                
<xsl:if test="count(mostco:SignalSequence/mostco:StreamSignalReference|mostco:SignalSequence/mostco:StreamSignalReferenceRepeated) &gt; 0">
                                        
<xsl:apply-templates mode="stream-signal-sequence-description" select="mostco:SignalSequence">
                                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                                
<xsl:with-param name="function-name" select="$function-name" />
                                        
</xsl:apply-templates>
                                
</xsl:if>
                                
<xsl:if test="count(mostco:ParameterSequence/mostco:StreamParamReference|mostco:ParameterSequence/mostco:StreamParamReferenceRepeated) &gt; 0">
                                        
<xsl:for-each select="./*/mostco:StreamParamReference|./*/mostco:StreamParamReferenceRepeated">
                                                
<xsl:if test="1 = count(.|key('stream-parameter-references', concat(generate-id((ancestor::*[self::mostco:TStream|self::mostco:TShortStream])[last()]),'::',./@Name))[1])">
                                                        
<xsl:apply-templates mode="stream-parameter-description" select="key('stream-parameter-definitions', concat(generate-id((ancestor::*[self::mostco:TStream|self::mostco:TShortStream])[last()]),'::',@Name))">
                                                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                                                
<xsl:with-param name="function-name" select="$function-name" />
                                                                
<xsl:with-param name="parent-parameter-name" select="(ancestor::mostco:Parameter)[last()]/@Name" />
                                                        
</xsl:apply-templates>
                                                
</xsl:if>
                                        
</xsl:for-each>
                                
</xsl:if>
                        
</xsl:when>
                        
<!-- StreamCases present -->
                        
<xsl:otherwise>
                                
<xsl:apply-templates mode="multi-stream-case-table" select=".">
                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                        
<xsl:with-param name="function-name" select="$function-name" />
                                
</xsl:apply-templates>
<!-- 
                                <xsl:for-each select="mostco:StreamSwitch/mostco:ParamStreamCase">
                                        <xsl:if test="count(mostco:StreamSignalReference) > 0">
                                                <xsl:apply-templates mode="stream-case-signals-table" select=".">
                                                        <xsl:with-param name="fblock-id" select="$fblock-id"/>
                                                        <xsl:with-param name="function-name" select="$function-name"/>
                                                </xsl:apply-templates>
                                        </xsl:if>
                                </xsl:for-each> 
-->
                                
<!--  StreamParamReference descriptions -->
                                
<!-- This selection only works for stream switches -->
                                
<xsl:for-each select="./*/*/mostco:StreamParamReference">
                                        
<xsl:if test="1 = count(.|key('stream-parameter-references', concat(generate-id((ancestor::*[self::mostco:TStream|self::mostco:TShortStream])[last()]),'::',./@Name))[1])">
                                                
<xsl:apply-templates mode="stream-parameter-description" select="key('stream-parameter-definitions', concat(generate-id((ancestor::*[self::mostco:TStream|self::mostco:TShortStream])[last()]),'::',@Name))">
                                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                        
<xsl:with-param name="function-name" select="$function-name" />
                                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                                        
<xsl:with-param name="parent-parameter-name" select="(ancestor::mostco:Parameter)[last()]/@Name" />
                                                
</xsl:apply-templates>
                                        
</xsl:if>
                                
</xsl:for-each>
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- *** Stream and Short Stream - Simple Stream *** -->
        
<!-- Level 6: Create table if there is only one stream case, without "Condition" heading -->
        
<xsl:template mode="zero-stream-case-table" match="mostco:TShortStream|mostco:TStream">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat">
                                        
<xsl:choose>
                                                
<xsl:when test="self::mostco:TShortStream">Max. Length</xsl:when>
                                                
<xsl:when test="self::mostco:TStream">Length</xsl:when>
                                        
</xsl:choose>
                                
</th>
                                
<xsl:if test="self::mostco:TStream and @MinLength">
                                        
<th class="paramformat">Min. Length</th>
                                
</xsl:if>
                                
<th class="paramformat">Description</th>
                        
</tr>
                        
<tr>
                                
<td class="paramformat">
                                        
<xsl:choose>
                                                
<xsl:when test="self::mostco:TShortStream">Short Stream</xsl:when>
                                                
<xsl:when test="self::mostco:TStream">Stream</xsl:when>
                                        
</xsl:choose>
                                
</td>
                                
<td class="paramcode2">
                                        
<xsl:choose>
                                                
<xsl:when test="self::mostco:TShortStream">
                                                        
<xsl:value-of select="@MaxLength" />
                                                
</xsl:when>
                                                
<xsl:when test="self::mostco:TStream">
                                                        
<xsl:value-of select="@Length" />
                                                
</xsl:when>
                                        
</xsl:choose>
                                
</td>
                                
<xsl:if test="self::mostco:TStream and @MinLength">
                                        
<td class="paramcode2">
                                                
<xsl:value-of select="@MinLength" />
                                        
</td>
                                
</xsl:if>
                                
<td class="paramformat2">
                                
<xsl:if test="count(mostco:ParameterSequence/mostco:StreamParamReference|mostco:ParameterSequence/mostco:StreamParamReferenceRepeated) &gt; 0">
                                        
<xsl:text>Content: </xsl:text>
                                        
<xsl:if test="count(mostco:ParameterSequence/mostco:StreamParamReference) &gt; 0">
                                                
<xsl:apply-templates mode="output-stream-parameter-name" select="mostco:ParameterSequence/mostco:StreamParamReference">
                                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                                        
<xsl:with-param name="function-name" select="$function-name" />
                                                
</xsl:apply-templates>
                                        
</xsl:if>        
                                        
<xsl:if test="count(mostco:ParameterSequence/mostco:StreamParamReferenceRepeated) &gt; 0">
                                                
<xsl:if test="count(mostco:ParameterSequence/mostco:StreamParamReference) &gt; 0">
                                                        
<xsl:text></xsl:text>
                                                
</xsl:if>                                                                
                                                
<xsl:text>{</xsl:text>
                                                
<xsl:apply-templates mode="output-stream-parameter-name" select="mostco:ParameterSequence/mostco:StreamParamReferenceRepeated">
                                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                                
<xsl:with-param name="function-name" select="$function-name" />
                                                
</xsl:apply-templates>
                                                
<xsl:text>}[repeated]</xsl:text>
                                        
</xsl:if>                                                        
                                        
<br />
                                
</xsl:if>
                                
<xsl:if test="count(mostco:SignalSequence/mostco:StreamSignalReference|mostco:SignalSequence/mostco:StreamSignalReferenceRepeated) &gt; 0">
                                                
<xsl:text>Stream signals: </xsl:text>
                                                
<xsl:if test="count(mostco:SignalSequence/mostco:StreamSignalReference) &gt; 0">
                                                        
<xsl:apply-templates mode="output-stream-parameter-name" select="mostco:SignalSequence/mostco:StreamSignalReference" />
                                                
</xsl:if>
                                                
<xsl:if test="count(mostco:SignalSequence/mostco:StreamSignalReferenceRepeated) &gt; 0">
                                                        
<xsl:if test="count(mostco:SignalSequence/mostco:StreamSignalReference) &gt; 0">
                                                                
<xsl:text></xsl:text>
                                                        
</xsl:if>                                                                
                                                        
<xsl:text>{</xsl:text>                                                        
                                                        
<xsl:apply-templates mode="output-stream-parameter-name" select="mostco:SignalSequence/mostco:StreamSignalReferenceRepeated" />
                                                        
<xsl:text>}[repeated]</xsl:text>
                                                
</xsl:if>
                                                
<br />
                                        
</xsl:if>
                                        
<xsl:value-of disable-output-escaping="yes" select="mostco:ParameterSequence/mostco:Description/text()|mostco:SignalSequence/mostco:Description/text()" />
                                
</td>
                        
</tr>
                
</table>
        
</xsl:template>
        
<!-- *** Stream and Short Stream - Complex Stream *** -->
        
<!-- Level 6: Create StreamCase table for multiple stream cases, containing "Condition" -->
        
<xsl:template mode="multi-stream-case-table" match="mostco:TShortStream|mostco:TStream">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<!-- Create header row -->
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat">
                                        
<xsl:choose>
                                                
<xsl:when test="self::mostco:TShortStream">Max. Length</xsl:when>
                                                
<xsl:when test="self::mostco:TStream">Length</xsl:when>
                                        
</xsl:choose>
                                
</th>
                                
<!-- Provide MinLength table heading if that attribute exists -->
                                
<xsl:if test="self::mostco:TStream and @MinLength">
                                        
<th class="paramformat">Min. Length</th>
                                
</xsl:if>
                                
<th class="paramformat">Condition</th>
                                
<th class="paramformat">Description</th>
                        
</tr>
                        
<!-- Create content rows of the StreamCase table -->
                        
<xsl:apply-templates mode="stream-case-table-row" select="mostco:StreamSwitch/mostco:ParamStreamCase">
                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                
<xsl:with-param name="function-name" select="$function-name" />
                        
</xsl:apply-templates>
                
</table>
        
</xsl:template>
        
<!-- Level 7: One row in the stream case table -->
        
<xsl:template mode="stream-case-table-row" match="mostco:ParamStreamCase">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<xsl:variable name="StreamCaseCount" select="count(../*)" />
                
<tr>
                        
<xsl:if test="position() = 1">
                                
<xsl:element name="td">
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$StreamCaseCount" /></xsl:attribute>
                                        
<xsl:choose>
                                                
<!-- looking for the grandparent now -->
                                                
<xsl:when test="parent::mostco:StreamSwitch/parent::mostco:TShortStream">Short Stream</xsl:when>
                                                
<xsl:when test="parent::mostco:StreamSwitch/parent::mostco:TStream">Stream</xsl:when>
                                        
</xsl:choose>
                                
</xsl:element>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="class"><xsl:text>paramcode2</xsl:text></xsl:attribute>
                                        
<xsl:attribute name="valign"><xsl:text>top</xsl:text></xsl:attribute>
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$StreamCaseCount" /></xsl:attribute>
                                        
<!-- Choose correct attribute depending on type -->
                                        
<xsl:choose>
                                                
<!-- Use parent's length attribute; current node does not have one. -->
                                                
<xsl:when test="parent::mostco:StreamSwitch/parent::mostco:TShortStream">
                                                        
<xsl:value-of select="parent::mostco:StreamSwitch/parent::mostco:TShortStream/@MaxLength" />
                                                
</xsl:when>
                                                
<xsl:when test="parent::mostco:StreamSwitch/parent::mostco:TStream">
                                                        
<xsl:value-of select="parent::mostco:StreamSwitch/parent::mostco:TStream/@Length" />
                                                
</xsl:when>
                                        
</xsl:choose>
                                
</xsl:element>
                                
<!-- Provide MinLength, which is only supported by TStream and not by TShortStream -->
                                
<xsl:if test="parent::mostco:StreamSwitch/parent::mostco:TStream and parent::mostco:StreamSwitch/parent::mostco:TStream/@MinLength">
                                        
<xsl:element name="td">
                                                
<xsl:attribute name="class"><xsl:text>paramcode2</xsl:text></xsl:attribute>
                                                
<xsl:attribute name="valign"><xsl:text>top</xsl:text></xsl:attribute>
                                                
<xsl:attribute name="rowspan"><xsl:value-of select="$StreamCaseCount" /></xsl:attribute>
                                                
<xsl:value-of select="parent::mostco:StreamSwitch/parent::mostco:TStream/@MinLength" />
                                        
</xsl:element>
                                
</xsl:if>
                        
</xsl:if>
                        
<xsl:variable name="actual-parameter-name">
                                
<xsl:variable name="parameter-definition" select="ancestor::mostco:Parameters/mostco:Parameter[@Name=current()/parent::mostco:StreamSwitch/@SelectorName]" />
                                
<xsl:variable name="shared-parameter-definition" select="/*/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/parent::mostco:StreamSwitch/@SelectorName]" />
                                
<xsl:choose>
                                        
<xsl:when test="$parameter-definition">
                                                
<xsl:value-of select="parent::mostco:StreamSwitch/@SelectorName" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:value-of select="$shared-parameter-definition/mostco:Parameter/@Name" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:variable>
                        
<xsl:element name="td">
                                
<xsl:attribute name="class"><xsl:text>paramformat2</xsl:text></xsl:attribute>
                                
<xsl:attribute name="valign"><xsl:text>top</xsl:text></xsl:attribute>
                                
<xsl:value-of select="$actual-parameter-name" />
                                
<xsl:text> = </xsl:text>
                                
<xsl:choose>
                                        
<xsl:when test="string(number(@MinSelectorValue))='NaN'">
                                                
<xsl:value-of select="@MinSelectorValue" />
                                                
<xsl:if test="@MinSelectorValue!=@MaxSelectorValue">
                                                        
<xsl:text>...</xsl:text>
                                                        
<xsl:value-of select="@MaxSelectorValue" />
                                                
</xsl:if>
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:call-template name="dec-to-hex">
                                                        
<xsl:with-param name="value" select="@MinSelectorValue" />
                                                
</xsl:call-template>
                                                
<xsl:if test="@MinSelectorValue!=@MaxSelectorValue">
                                                        
<xsl:text>...</xsl:text>
                                                        
<xsl:choose>
                                                                
<xsl:when test="string(number(@MaxSelectorValue))='NaN'">
                                                                        
<xsl:value-of select="@MaxSelectorValue" />
                                                                
</xsl:when>
                                                                
<xsl:otherwise>
                                                                        
<xsl:call-template name="dec-to-hex">
                                                                                
<xsl:with-param name="value" select="@MaxSelectorValue" />
                                                                        
</xsl:call-template>
                                                                
</xsl:otherwise>
                                                        
</xsl:choose>
                                                
</xsl:if>
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:element>
                        
<td class="paramformat2">
                                
<xsl:if test="count(mostco:StreamParamReference|mostco:StreamParamReferenceRepeated) &gt; 0">
                                        
<xsl:text>Content: </xsl:text>
                                        
<xsl:apply-templates mode="output-stream-parameter-name" select="mostco:StreamParamReference|mostco:StreamParamReferenceRepeated">
                                                
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                                
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                                
<xsl:with-param name="function-name" select="$function-name" />
                                        
</xsl:apply-templates>
                                        
<br />
                                
</xsl:if>
                                
<xsl:value-of disable-output-escaping="yes" select="mostco:Description/text()" />
                        
</td>
                
</tr>
        
</xsl:template>
        
<!-- *** Templates used by Simple and Complex Streams - Parameter handling *** -->
        
<!-- Level 6: Description of one StreamParamReference -->
        
<xsl:template mode="stream-parameter-description" match="mostco:StreamParamReference">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<xsl:param name="parent-parameter-name" />
                
<xsl:choose>
                        
<xsl:when test="parent::mostco:ParameterSequence">
                                
<xsl:apply-templates mode="stream-parameter-description" select="../../mostco:Parameters/mostco:Parameter[@Name = current()/@Name]">
                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                        
<xsl:with-param name="function-name" select="$function-name" />
                                        
<xsl:with-param name="parent-parameter-name" select="$parent-parameter-name" />
                                
</xsl:apply-templates>
                        
</xsl:when>
                        
<xsl:otherwise>
                                
<!-- the ancestor is a stream switch. Go up an additional level -->
                                
<xsl:apply-templates mode="stream-parameter-description" select="../../../mostco:Parameters/mostco:Parameter[@Name = current()/@Name]">
                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                                        
<xsl:with-param name="function-name" select="$function-name" />
                                        
<xsl:with-param name="parent-parameter-name" select="$parent-parameter-name" />
                                
</xsl:apply-templates>
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- Level 7: Create single hyperlinked StreamParamReference name within table -->
        
<xsl:template mode="output-stream-parameter-name" match="mostco:StreamParamReference|mostco:StreamParamReferenceRepeated">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<xsl:element name="a">
                        
<xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:value-of select="(ancestor::mostco:Parameter)[last()]/@Name" /><xsl:text>_</xsl:text><xsl:choose><xsl:when test="ancestor::*/mostco:Parameters/mostco:SharedParameterReference[@Name = current()/@Name]"><xsl:value-of select="/*/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@Name]/mostco:Parameter/@Name" /></xsl:when><xsl:otherwise><xsl:value-of disable-output-escaping="yes" select="@Name" /></xsl:otherwise></xsl:choose></xsl:attribute>
                        
<xsl:choose>
                                
<xsl:when test="ancestor::*/mostco:Parameters/mostco:SharedParameterReference[@Name = current()/@Name]">
                                        
<xsl:value-of select="/*/mostco:SharedParameters/mostco:SharedParameter[@Name=current()/@Name]/mostco:Parameter/@Name" />
                                
</xsl:when>
                                
<xsl:otherwise>
                                        
<xsl:value-of disable-output-escaping="yes" select="@Name" />
                                
</xsl:otherwise>
                        
</xsl:choose>
                
</xsl:element>
                
<xsl:choose>
                        
<xsl:when test="last()=position()" />
                        
<xsl:otherwise>
                                
<xsl:text></xsl:text>
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!--  Level 7: Stream Parameter description -->
        
<xsl:template mode="stream-parameter-description" match="mostco:Parameter">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:param name="parent-parameter-name" />
                
<xsl:variable name="titel" select="@Name" />
                
<!-- Parameter table -->
                
<xsl:choose>
                        
<xsl:when test="$titel">
                                
<!-- Heading -->
                                
<p class="parameter">
                                        
<xsl:element name="a">
                                                
<xsl:attribute name="name"><xsl:number value="$fblock-id" /><xsl:text>_</xsl:text><xsl:number value="$resulting-function-id" /><xsl:text>_</xsl:text><xsl:value-of select="$function-name" /><xsl:text>_</xsl:text><xsl:value-of select="$parent-parameter-name" /><xsl:text>_</xsl:text><xsl:value-of select="@Name" /></xsl:attribute>
                                        
</xsl:element>
                                        
<xsl:value-of select="$parent-parameter-name" />
                                        
<xsl:text>.</xsl:text>
                                        
<xsl:value-of select="@Name" />
                                
</p>
                                
<hr size="2" noshade="true" />
                                
<xsl:if test="mostco:Description">
                                        
<p class="description">
                                                
<xsl:value-of disable-output-escaping="yes" select="mostco:Description" />
                                        
</p>
                                
</xsl:if>
                                
<xsl:apply-templates select="mostco:DataType/*" mode="parameter-table">
                                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />                                        
                                        
<xsl:with-param name="function-name" select="$function-name" />
                                
</xsl:apply-templates>
                        
</xsl:when>
                        
<xsl:otherwise>
                                
<xsl:comment> ERROR in Stream Parameter (no Name or ErrorName) </xsl:comment>
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- *** Stream and Short Stream - Signal Sequence *** -->
        
<!-- Level 6: Create description of a SignalSequence -->
        
<xsl:template mode="stream-signal-sequence-description" match="mostco:SignalSequence">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                
                
<xsl:param name="function-name" />
                
<!-- select referenced StreamSignals and put them in the same order as the StreamSignalReferences -->
                
<xsl:variable name="signal-nodes">
                        
<xsl:for-each select="mostco:StreamSignalReference|mostco:StreamSignalReferenceRepeated">
                                
<xsl:choose>
                                        
<xsl:when test="(ancestor::*[self::mostco:TStream|self::mostco:TShortStream])[last()]/mostco:StreamSignals/mostco:SharedSignalReference[@Name = current()/@Name]">
                                                
<xsl:copy-of select="/*/mostco:SharedSignals/mostco:SharedSignal[@Name = current()/@Name]/mostco:StreamSignal[1]" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:copy-of select="(ancestor::*[self::mostco:TStream|self::mostco:TShortStream])[last()]/mostco:StreamSignals/mostco:StreamSignal[@Name = current()/@Name][1]" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:for-each>
                
</xsl:variable>
                
<p class="emphasis">
                                
<xsl:text>Stream Signals</xsl:text>
                
</p>
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Signal Name</th>
                                
<th class="paramformat">Bit position</th>
                                
<xsl:variable name="signedness-present">
                                        
<xsl:choose>
                                                
<xsl:when test="function-available('exslt:node-set')or function-available('exslt:nodeSet')">
                                                        
<xsl:value-of select="count(exslt:node-set($signal-nodes)/mostco:StreamSignal/@Signedness) &gt; 0" />
                                                
</xsl:when>
                                                
<xsl:when test="function-available('msxsl:node-set')">
                                                        
<xsl:value-of select="count(msxsl:node-set($signal-nodes)/mostco:StreamSignal/@Signedness) &gt; 0" />
                                                
</xsl:when>
                                                
<xsl:when test="function-available('xsl:node-set')">
                                                        
<xsl:value-of select="count(xsl:node-set($signal-nodes)/mostco:StreamSignal/@Signedness) &gt; 0" />
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<xsl:value-of select="count($signal-nodes/mostco:StreamSignal/@Signedness) &gt; 0" />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</xsl:variable>
                                
<xsl:if test="$signedness-present = 'true'">
                                        
<th class="paramformat">Signedness</th>
                                
</xsl:if>
                                
<th class="paramformat">Number of bits</th>
                                
<xsl:if test="count(mostco:StreamSignalReferenceRepeated) &gt; 0">
                                        
<th class="paramformat">Repetition</th>
                                
</xsl:if>
                                
<th class="paramformat">Description</th>
                        
</tr>
                        
<xsl:apply-templates mode="stream-signal-table-row" select="mostco:StreamSignalReference|mostco:StreamSignalReferenceRepeated">
                                
<xsl:with-param name="signal-nodes" select="$signal-nodes" />
                        
</xsl:apply-templates>
                
</table>
        
</xsl:template>
        
<!-- Level 7: One row in the StreamSignal table of a Signal Sequence -->
        
<xsl:template mode="stream-signal-table-row" match="mostco:StreamSignalReference|mostco:StreamSignalReferenceRepeated">
                
<xsl:param name="signal-nodes" />
                
<tr>
                        
<!-- get the current signal name either from a shared signal or the Name attribute -->
                        
<xsl:variable name="current-signal-name">
                                
<xsl:choose>
                                        
<xsl:when test="(ancestor::*[self::mostco:TStream|self::mostco:TShortStream])[last()]/mostco:StreamSignals/mostco:SharedSignalReference[@Name = current()/@Name]">
                                                
<xsl:value-of select="/*/mostco:SharedSignals/mostco:SharedSignal[@Name=current()/@Name]/mostco:StreamSignal/@Name" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:value-of select="@Name" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:variable>
                        
<!-- Calculate the starting bit position for the current StreamSignal-->
                        
<xsl:variable name="current-signal-node-position">
                                
<xsl:value-of select="position()" />
                        
</xsl:variable>
                        
<!-- Calculate the sum of all preceding BitLenght attributes to determine the current position value -->
                        
<xsl:variable name="current-signal-node-sum">
                                
<!-- The node-set() extension function is required because most XSLT processors cannot handle XPath expressions on Result Tree Fragments; unfortunately, it is defined in more than one namespace -->
                                
<xsl:choose>
                                        
<xsl:when test="function-available('exslt:node-set')or function-available('exslt:nodeSet')">
                                                
<xsl:value-of select="sum(exslt:node-set($signal-nodes)/*[position() &lt; $current-signal-node-position]/@BitLength)" />
                                        
</xsl:when>
                                        
<xsl:when test="function-available('msxsl:node-set')">
                                                
<xsl:value-of select="sum(msxsl:node-set($signal-nodes)/*[position() &lt; $current-signal-node-position]/@BitLength)" />
                                        
</xsl:when>
                                        
<xsl:when test="function-available('xsl:node-set')">
                                                
<xsl:value-of select="sum(xsl:node-set($signal-nodes)/*[position() &lt; $current-signal-node-position]/@BitLength)" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:value-of select="sum($signal-nodes/*[position() &lt; $current-signal-node-position]/@BitLength)" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:variable>
                        
<td class="paramformat">
                                
<xsl:value-of select="$current-signal-name" />
                        
</td>
                        
<td class="paramcode2">
                                
<xsl:value-of select="$current-signal-node-sum" />
                        
</td>
                        
<!-- Determine whether any of the StreamSignals has a Signedness attribute -->
                        
<xsl:variable name="signedness-present">
                                
<!-- The node-set() extension function is required because most XSLT processors cannot handle XPath expressions on Result Tree Fragments; unfortunately, it is defined in more than one namespace -->
                                
<xsl:choose>
                                        
<xsl:when test="function-available('exslt:node-set')or function-available('exslt:nodeSet')">
                                                
<xsl:value-of select="count(exslt:node-set($signal-nodes)/mostco:StreamSignal/@Signedness) &gt; 0" />
                                        
</xsl:when>
                                        
<xsl:when test="function-available('msxsl:node-set')">
                                                
<xsl:value-of select="count(msxsl:node-set($signal-nodes)/mostco:StreamSignal/@Signedness) &gt; 0" />
                                        
</xsl:when>
                                        
<xsl:when test="function-available('xsl:node-set')">
                                                
<xsl:value-of select="count(xsl:node-set($signal-nodes)/mostco:StreamSignal/@Signedness) &gt; 0" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:value-of select="count($signal-nodes/mostco:StreamSignal/@Signedness) &gt; 0" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:variable>
                        
<xsl:if test="$signedness-present = 'true'">
                                
<td class="paramformat">
                                        
<xsl:attribute name="class"><xsl:text>paramcode</xsl:text></xsl:attribute>
                                        
<xsl:choose>
                                                
<xsl:when test="function-available('exslt:node-set')or function-available('exslt:nodeSet')">
                                                        
<xsl:value-of disable-output-escaping="yes" select="exslt:node-set($signal-nodes)/mostco:StreamSignal[@Name = $current-signal-name]/@Signedness" />
                                                
</xsl:when>
                                                
<xsl:when test="function-available('msxsl:node-set')">
                                                        
<xsl:value-of disable-output-escaping="yes" select="msxsl:node-set($signal-nodes)/mostco:StreamSignal[@Name = $current-signal-name]/@Signedness" />
                                                
</xsl:when>
                                                
<xsl:when test="function-available('xsl:node-set')">
                                                        
<xsl:value-of disable-output-escaping="yes" select="xsl:node-set($signal-nodes)/mostco:StreamSignal[@Name = $current-signal-name]/@Signedness" />
                                                
</xsl:when>
                                                
<xsl:otherwise>
                                                        
<xsl:value-of disable-output-escaping="yes" select="$signal-nodes/mostco:StreamSignal[@Name = $current-signal-name]/@Signedness" />
                                                
</xsl:otherwise>
                                        
</xsl:choose>
                                
</td>
                        
</xsl:if>
                        
<td class="paramcode2">
                                
<xsl:choose>
                                        
<xsl:when test="function-available('exslt:node-set')or function-available('exslt:nodeSet')">
                                                
<xsl:value-of disable-output-escaping="yes" select="exslt:node-set($signal-nodes)/mostco:StreamSignal[@Name = $current-signal-name]/@BitLength" />
                                        
</xsl:when>
                                        
<xsl:when test="function-available('msxsl:node-set')">
                                                
<xsl:value-of disable-output-escaping="yes" select="msxsl:node-set($signal-nodes)/mostco:StreamSignal[@Name = $current-signal-name]/@BitLength" />
                                        
</xsl:when>
                                        
<xsl:when test="function-available('xsl:node-set')">
                                                
<xsl:value-of disable-output-escaping="yes" select="xsl:node-set($signal-nodes)/mostco:StreamSignal[@Name = $current-signal-name]/@BitLength" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:value-of disable-output-escaping="yes" select="$signal-nodes/mostco:StreamSignal[@Name = $current-signal-name]/@BitLength" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</td>
                        
<xsl:if test="count(../mostco:StreamSignalReferenceRepeated) &gt; 0">
                                
<xsl:choose>
                                        
<xsl:when test="self::mostco:StreamSignalReferenceRepeated">
                                                
<td class="paramformat">X</td>
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<td class="paramformat" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</xsl:if>
                        
<td class="paramformat2">
                                
<xsl:choose>
                                        
<xsl:when test="function-available('exslt:node-set')or function-available('exslt:nodeSet')">
                                                
<xsl:value-of disable-output-escaping="yes" select="exslt:node-set($signal-nodes)/mostco:StreamSignal[@Name = $current-signal-name]/mostco:Description/text()" />
                                        
</xsl:when>
                                        
<xsl:when test="function-available('msxsl:node-set')">
                                                
<xsl:value-of select="msxsl:node-set($signal-nodes)/mostco:StreamSignal[@Name = $current-signal-name]/mostco:Description/text()" />
                                        
</xsl:when>
                                        
<xsl:when test="function-available('xsl:node-set')">
                                                
<xsl:value-of disable-output-escaping="yes" select="xsl:node-set($signal-nodes)/mostco:StreamSignal[@Name = $current-signal-name]/mostco:Description/text()" />
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:value-of disable-output-escaping="yes" select="$signal-nodes/mostco:StreamSignal[@Name = $current-signal-name]/mostco:Description/text()" />
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</td>
                
</tr>
        
</xsl:template>
        
<!-- *** Stream and Short Stream - Signal Stream Case *** -->

        
<!-- *** Templates used by Simple and Complex Streams - Signal handling *** -->
        
<!-- Level 7: Create single StreamSignalReference name within table -->
        
<xsl:template mode="output-stream-parameter-name" match="mostco:StreamSignalReference|mostco:StreamSignalReferenceRepeated">
                
<xsl:choose>
                        
<xsl:when test="ancestor::*/mostco:StreamSignals/mostco:SharedSignalReference[@Name = current()/@Name]">
                                
<xsl:value-of select="/*/mostco:SharedSignals/mostco:SharedSignal[@Name=current()/@Name]/mostco:StreamSignal/@Name" />
                        
</xsl:when>
                        
<xsl:otherwise>
                                
<xsl:value-of disable-output-escaping="yes" select="@Name" />
                        
</xsl:otherwise>
                
</xsl:choose>
                
<xsl:choose>
                        
<xsl:when test="last()=position()" />
                        
<xsl:otherwise>
                                
<xsl:text></xsl:text>
                        
</xsl:otherwise>
                
</xsl:choose>
        
</xsl:template>
        
<!-- Description of one SharedParamReference -->
        
<xsl:template mode="stream-parameter-description" match="mostco:SharedParameterReference">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:param name="parent-parameter-name" />
                
<xsl:apply-templates mode="stream-parameter-description" select="/*/mostco:SharedParameters/mostco:SharedParameter[@Name = current()/@Name]/mostco:Parameter">
                        
<xsl:with-param name="fblock-id" select="$fblock-id" />
                        
<xsl:with-param name="resulting-function-id" select="$resulting-function-id" />
                        
<xsl:with-param name="function-name" select="$function-name" />
                        
<xsl:with-param name="parent-parameter-name" select="$parent-parameter-name" />
                
</xsl:apply-templates>
        
</xsl:template>
        
<!-- *** Enum *** -->
        
<!-- Level 5: Enum parameter table -->
        
<xsl:template mode="parameter-table" match="mostco:TEnum">
                
<xsl:param name="fblock-id" />
                
<xsl:param name="resulting-function-id" />                        
                
<xsl:param name="function-name" />
                
<xsl:variable name="number-of-rows" select="count(mostco:TEnumValue) + count(mostco:TEnumReserved)" />
                
<!-- Helper variables to properly sort the table entries -->
                
<xsl:variable name="enum-and-reserved-sorted">
                        
<xsl:for-each select="mostco:TEnumValue|mostco:TEnumReserved">
                                
<xsl:sort data-type="number" order="ascending" select="@Code|@StartCode" />
                                
<xsl:copy-of select="." />
                        
</xsl:for-each>
                
</xsl:variable>
                
<xsl:variable name="enum-sorted">
                        
<xsl:for-each select="mostco:TEnumValue">
                                
<xsl:sort data-type="number" order="ascending" select="@Code" />
                                
<xsl:copy-of select="." />
                        
</xsl:for-each>
                
</xsl:variable>
                
<!-- Determine how many hex digits are required -->
                
<xsl:variable name="required-hex-digits">
                        
<xsl:choose>
                                
<xsl:when test="@TotalByteLength">
                                        
<xsl:value-of select="@TotalByteLength * 2" />
                                
</xsl:when>
                                
<xsl:otherwise>
                                        
<!-- The default is a byte -->
                                        
<xsl:value-of select="2" />
                                
</xsl:otherwise>
                        
</xsl:choose>
                
</xsl:variable>
                
<table border="1" cellpadding="3" cellspacing="0">
                        
<tr>
                                
<th class="paramformat">Basis data type</th>
                                
<th class="paramformat">Code</th>
                                
<th class="paramformat">Name</th>
                                
<th class="paramformat">Description</th>
                        
</tr>
                        
<tr>
                                
<xsl:element name="td">
                                        
<xsl:attribute name="rowspan"><xsl:value-of select="$number-of-rows" /></xsl:attribute>
                                        
<xsl:attribute name="class"><xsl:text>paramformat</xsl:text></xsl:attribute>
                                        
<xsl:text>Enum</xsl:text>
                                        
<br />
                                        
<xsl:text>(</xsl:text>
                                        
<xsl:value-of select="@TotalByteLength|$default-enum-size[not(@TotalByteLength)]" />
                                        
<xsl:text> byte</xsl:text>
                                        
<xsl:if test="@TotalByteLength &gt; 1"><xsl:text>s</xsl:text></xsl:if>
                                        
<xsl:text>)</xsl:text>
                                
</xsl:element>
                                
<xsl:choose>
                                        
<xsl:when test="function-available('exslt:node-set')or function-available('exslt:nodeSet')">
                                                
<xsl:apply-templates mode="parameter-table-row-content" select="exslt:node-set($enum-and-reserved-sorted)/*[1]">
                                                        
<xsl:with-param name="required-hex-digits" select="$required-hex-digits" />
                                                
</xsl:apply-templates>
                                        
</xsl:when>
                                        
<xsl:when test="function-available('msxsl:node-set')">
                                                
<xsl:apply-templates mode="parameter-table-row-content" select="msxsl:node-set($enum-and-reserved-sorted)/*[1]">
                                                        
<xsl:with-param name="required-hex-digits" select="$required-hex-digits" />
                                                
</xsl:apply-templates>
                                        
</xsl:when>
                                        
<xsl:when test="function-available('xsl:node-set')">
                                                
<xsl:apply-templates mode="parameter-table-row-content" select="xsl:node-set($enum-and-reserved-sorted)/*[1]">
                                                        
<xsl:with-param name="required-hex-digits" select="$required-hex-digits" />
                                                
</xsl:apply-templates>
                                        
</xsl:when>
                                        
<xsl:otherwise>
                                                
<xsl:apply-templates mode="parameter-table-row-content" select="$enum-and-reserved-sorted/*[1]">
                                                        
<xsl:with-param name="required-hex-digits" select="$required-hex-digits" />
                                                
</xsl:apply-templates>
                                        
</xsl:otherwise>
                                
</xsl:choose>
                        
</tr>
                        
                        
<xsl:choose>
                                
<xsl:when test="function-available('exslt:node-set')or function-available('exslt:nodeSet')">
                                        
<xsl:apply-templates mode="parameter-table-row" select="exslt:node-set($enum-and-reserved-sorted)/*[position() &gt; 1]">
                                                
<xsl:with-param name="required-hex-digits" select="$required-hex-digits" />
                                        
</xsl:apply-templates>
                                
</xsl:when>
                                
<xsl:when test="function-available('msxsl:node-set')">
                                        
<xsl:apply-templates mode="parameter-table-row" select="msxsl:node-set($enum-and-reserved-sorted)/*[position() &gt; 1]">
                                                
<xsl:with-param name="required-hex-digits" select="$required-hex-digits" />
                                        
</xsl:apply-templates>
                                
</xsl:when>
                                
<xsl:when test="function-available('xsl:node-set')">
                                        
<xsl:apply-templates mode="parameter-table-row" select="xsl:node-set($enum-and-reserved-sorted)/*[position() &gt; 1]">
                                                
<xsl:with-param name="required-hex-digits" select="$required-hex-digits" />
                                        
</xsl:apply-templates>
                                
</xsl:when>
                                
<xsl:otherwise>
                                        
<xsl:apply-templates mode="parameter-table-row" select="$enum-and-reserved-sorted/*[position() &gt; 1]">
                                                
<xsl:with-param name="required-hex-digits" select="$required-hex-digits" />
                                        
</xsl:apply-templates>
                                
</xsl:otherwise>
                        
</xsl:choose>
                
</table>
        
</xsl:template>
        
<!-- Level 6: The bounding HTML tags for one row in the table for TEnumValue or TEnumReserved -->
        
<xsl:template mode="parameter-table-row" match="mostco:TEnumValue|mostco:TEnumReserved">
                
<xsl:param name="required-hex-digits" />
                
<tr>
                        
<xsl:apply-templates mode="parameter-table-row-content" select=".">
                                
<xsl:with-param name="required-hex-digits" select="$required-hex-digits" />
                        
</xsl:apply-templates>
                
</tr>
        
</xsl:template>
        
<!-- Level 7: One row of parameter table for TEnumValue -->
        
<xsl:template mode="parameter-table-row-content" match="mostco:TEnumValue">
                
<xsl:param name="required-hex-digits" />
                
<td class="paramcode2">
                        
<xsl:call-template name="dec-to-hex">
                                
<xsl:with-param name="value" select="@Code" />
                        
</xsl:call-template>
                
</td>
                
<td class="paramformat2">
                        
<xsl:value-of select="@Name" />
                
</td>
                
<td class="paramformat2">
                        
<!-- Disable output escaping for proper HTML display -->
                        
<xsl:value-of disable-output-escaping="yes" select="mostco:Description/text()" />
                
</td>
        
</xsl:template>
        
<!-- Level 7: One row of parameter table for TEnumReserved -->
        
<xsl:template mode="parameter-table-row-content" match="mostco:TEnumReserved">
                
<xsl:param name="required-hex-digits" />
                
<xsl:element name="td">
                        
<xsl:attribute name="class"><xsl:text>paramcode2</xsl:text></xsl:attribute>
                        
<xsl:call-template name="dec-to-hex">
                                
<xsl:with-param name="value" select="@StartCode" />
                        
</xsl:call-template>
                        
<xsl:text>...</xsl:text>
                        
<xsl:call-template name="dec-to-hex">
                                
<xsl:with-param name="value" select="@EndCode" />
                        
</xsl:call-template>
                
</xsl:element>
                
<td class="paramformat2">                        
                        
<xsl:if test="@DisplayName">
                                
<xsl:value-of disable-output-escaping="yes" select="@DisplayName" />
                        
</xsl:if>        
                
</td>
                
<td class="paramformat2">
                        
<xsl:text>Reserved range.</xsl:text>
                
</td>
        
</xsl:template>
        
<!-- Level 0: Ignore-all -->
        
<xsl:template match="*|@*|comment()|processing-instruction()|text()">
                
<xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()" />
        
</xsl:template>
</xsl:stylesheet>