<!-- 
    ART-DECOR® STANDARD COPYRIGHT AND LICENSE NOTE
    Copyright © ART-DECOR Expert Group and ART-DECOR Open Tools GmbH
    see https://docs.art-decor.org/copyright and https://docs.art-decor.org/licenses

    This file is part of the ART-DECOR® tools suite.    
-->
<!DOCTYPE stylesheet [
<!ENTITY omitted "&#xa0;">
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:uuid="java:java.util.UUID" xmlns:diff="http://art-decor.org/ns/decor/diff" xmlns:f="http://hl7.org/fhir" xmlns:local="http://art-decor.org/functions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" exclude-result-prefixes="#all">
    <!--
        This stylesheet converts the rule set from a DECOR file into an appropriate HTML representation
        Note: this file cannot be used alone, it's called by the schematron conversion stylesheet
    -->
    <xsl:include href="v3mXML2HTMLGenerator2.xsl"/>
    <!--
        This stylesheet renders transaction groups into SVG for the Scenarios tab
    -->
    <xsl:include href="DECOR2svg.xsl"/>
    <!-- This stylesheet renders structure definitions and other FHIR artefacts -->
    <xsl:include href="DECOR4fhir.xsl"/>
    <!-- make a list of tab names (keys for messages) and their corresponding file names -->
    <xsl:variable name="tabnameslist" as="element()">
        <tabs xmlns="">
            <tab key="tabFrontPage" filename="index.html"/>
            <tab key="tabProjectInformation" filename="project.html"/>
            <xsl:if test="//datasets/dataset/*">
                <tab key="tabDataSet" filename="dataset.html"/>
            </xsl:if>
            <xsl:if test="//scenarios/*">
                <tab key="tabScenarios" filename="scenarios.html"/>
            </xsl:if>
            <xsl:if test="//ids/id">
                <tab key="tabIdentifiers" filename="identifiers.html"/>
            </xsl:if>
            <xsl:if test="//terminology[valueSet[@id] | codeSystem[@id] | conceptMap[@id]]">
                <tab key="tabTerminology" filename="terminology.html"/>
            </xsl:if>
            <xsl:if test="//rules/template">
                <tab key="tabRules" filename="rules.html"/>
            </xsl:if>
            <xsl:if test="$allQuestionnaires">
                <tab key="tabQuestionnaires" filename="questionnaires.html"/>
            </xsl:if>
            <xsl:if test="//issues/issue">
                <tab key="tabIssues" filename="issues.html"/>
            </xsl:if>
            <tab key="tabCompileTime" filename="compiletime.html"/>
            <tab key="tabLegal" filename="legal.html"/>
        </tabs>
    </xsl:variable>
    <!-- Do SVG -->
    <xsl:variable name="allSvg">
        <xsl:if test="$switchCreateDocSVG = true()">
            <!-- Need at least 1 initial and 1 back for a webservice -->
            <xsl:for-each select="//scenarios/scenario//transaction[@type = 'group'][transaction[@type = ('initial', 'stationary')]]">
                <transaction xmlns="">
                    <xsl:copy-of select="@id | @effectiveDate"/>
                    <xsl:apply-templates select="self::node()" mode="transactionGroupToSVGFunctional"/>
                    <xsl:apply-templates select="self::node()" mode="transactionGroupToSVGTechnical"/>
                </transaction>
            </xsl:for-each>
        </xsl:if>
    </xsl:variable>
    <!-- Calculate missing issues/labels/label definitions. Needed on Issues and Compile tab -->
    <xsl:variable name="allMissingLabels">
        <wrap xmlns="">
            <xsl:for-each select="$allIssues/issue/(tracking | assignment)[@labels]">
                <xsl:variable name="issueId" select="parent::issue/@id"/>
                <xsl:variable name="issuename">
                    <xsl:choose>
                        <xsl:when test="string-length(parent::issue/@displayName) &gt; 0">
                            <xsl:value-of select="parent::issue/@displayName"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'notLabeled'"/>
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="labelCodes" select="@labels"/>
                <xsl:for-each select="distinct-values(tokenize($labelCodes, ' '))">
                    <xsl:variable name="labelCode" select="."/>
                    <xsl:if test="not($allIssues/labels/label[@code = $labelCode])">
                        <missingCode ref="{$issueId}" refName="{$issuename}" labelCode="{$labelCode}"/>
                    </xsl:if>
                </xsl:for-each>
            </xsl:for-each>
        </wrap>
    </xsl:variable>
    <xsl:template name="doTabs4ThisTab">
        <!-- the name of the actual tab to build tabs for, see variable tabnames -->
        <xsl:param name="actualtab"/>
        <!-- the actual content -->
        <xsl:param name="actualcontent"/>
        <xsl:result-document href="{$theHtmlDir}{local:doHtmlName($actualtab, (), (),'.html',true())}" format="xhtml">
            <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                    <title>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="$actualtab"/>
                        </xsl:call-template>
                        <xsl:text>: </xsl:text>
                        <xsl:value-of select="//project/@prefix"/>
                        <xsl:text> </xsl:text>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'decorTitleString'"/>
                        </xsl:call-template>
                    </title>
                    <xsl:call-template name="addAssetsHeader">
                        <xsl:with-param name="doTreeTable" select="$actualtab = ('tabDataSet', 'tabScenarios', 'tabRules', 'tabQuestionnaires', 'tabTerminology')"/>
                        <xsl:with-param name="treeTableColumnIndex" as="xs:integer">
                            <xsl:choose>
                                <xsl:when test="$actualtab = ('tabDataSet')">3</xsl:when>
                                <xsl:when test="$actualtab = ('tabScenarios') and $theV2Scenarios">5</xsl:when>
                                <xsl:when test="$actualtab = ('tabScenarios')">4</xsl:when>
                                <xsl:when test="$actualtab = ('tabRules')">1</xsl:when>
                                <xsl:when test="$actualtab = ('tabTerminology')">1</xsl:when>
                                <xsl:when test="$actualtab = ('tabQuestionnaires')">1</xsl:when>
                                <xsl:otherwise>0</xsl:otherwise>
                            </xsl:choose>
                        </xsl:with-param>
                    </xsl:call-template>
                </head>
                <body>
                    <table class="title">
                        <tr>
                            <td style="text-align: left;">
                                <h1 style="margin-left: 5px; margin-bottom: 0px;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'decorProjectInfoString'"/>
                                        <xsl:with-param name="p1">
                                            <xsl:choose>
                                                <xsl:when test="string-length(//project/name[@language = $defaultLanguage or not(@language)]) = 0">
                                                    <!-- fallback -->
                                                    <xsl:value-of select="(//project/name)[1]"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:value-of select="//project/name[@language = $defaultLanguage or not(@language)][1]"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:with-param>
                                        <xsl:with-param name="p2" select="//project/@prefix"/>
                                    </xsl:call-template>
                                </h1>
                                <table style="margin-left: 2px; margin-bottom: 10px;">
                                    <tr>
                                        <td style="font-weight: bold; color: #665a4e;">
                                            <xsl:if test="//project/(version | release)">
                                                <!-- is current publication a release or just a version? -->
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key">
                                                        <xsl:choose>
                                                            <xsl:when test="$publicationIsRelease">decorProjectReleaseAsOf</xsl:when>
                                                            <xsl:otherwise>decorProjectVersionAsOf</xsl:otherwise>
                                                        </xsl:choose>
                                                    </xsl:with-param>
                                                    <xsl:with-param name="p1">
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="$latestVersionOrRelease/@date"/>
                                                        </xsl:call-template>
                                                    </xsl:with-param>
                                                    <xsl:with-param name="p2" select="($latestVersionOrRelease/@versionLabel[not(. = '')], ' ')[1]"/>
                                                </xsl:call-template>
                                            </xsl:if>
                                        </td>
                                        <td>
                                            <xsl:text>|</xsl:text>
                                        </td>
                                        <td style="font-weight: bold; color: #665a4e;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'htmlExtractAsOf'"/>
                                            </xsl:call-template>
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$currentDateTime"/>
                                            </xsl:call-template>
                                        </td>
                                        <xsl:if test="$inDevelopment">
                                            <td>
                                                <xsl:text>|</xsl:text>
                                            </td>
                                            <td style="font-weight: bold; color: #665a4e;">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'developmentVersion'"/>
                                                </xsl:call-template>
                                            </td>
                                        </xsl:if>
                                    </tr>
                                </table>
                            </td>
                            <xsl:choose>
                                <xsl:when test="$useCustomLogo = true()">
                                    <td style="text-align: right;">
                                        <xsl:choose>
                                            <xsl:when test="string-length($useCustomLogoHREF) &gt; 0">
                                                <a href="{$useCustomLogoHREF}">
                                                    <img class="title" src="{$useCustomLogoSRC}" alt=""/>
                                                </a>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <img class="title" src="{$useCustomLogoSRC}" alt=""/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </td>
                                </xsl:when>
                                <xsl:otherwise>
                                    <!--<td style="text-align: right;">
                                        <img class="title" src="{$theAssetsDir}art-decor-logo-small.jpg" alt=""/>
                                    </td>-->
                                </xsl:otherwise>
                            </xsl:choose>
                        </tr>
                    </table>
                    <ul id="TabbedPanel">
                        <xsl:for-each select="$tabnameslist/tab">
                            <xsl:variable name="thistab" select="@key"/>
                            <xsl:variable name="thisfn" select="@filename"/>
                            <xsl:choose>
                                <xsl:when test="$actualtab = $thistab">
                                    <li class="TabbedPanelsTabSelected">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="$thistab"/>
                                        </xsl:call-template>
                                    </li>
                                </xsl:when>
                                <xsl:otherwise>
                                    <li class="TabbedPanelsTabNotSelected">
                                        <a href="{$thisfn}">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="$thistab"/>
                                            </xsl:call-template>
                                        </a>
                                    </li>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:for-each>
                    </ul>
                    <xsl:copy-of select="$actualcontent"/>
                    <p>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'decorFooterText'"/>
                        </xsl:call-template>
                    </p>
                    <xsl:call-template name="addAssetsBottom">
                        <xsl:with-param name="doTreeTable" select="$actualtab = ('tabDataSet', 'tabScenarios', 'tabRules', 'tabQuestionnaires', 'tabTerminology')"/>
                    </xsl:call-template>
                </body>
            </html>
        </xsl:result-document>
    </xsl:template>
    <xsl:template name="convertDECOR2HTML">
        <!-- 
            build html documentation, consists of
            - front page (index)
            - project information page (project)
            - datasets page (datasets)
            - scenarios page (scenarios)
            - identifiers page (identifiers)
            - terminology page (terminology)
            - rules page (rules)
            - issues page (issues)
            - compile time page (compiletime)
            - legal page (legal)
        -->
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Front Page Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <!-- RELEASE.txt or VERSION.txt
            This file helps publication on a website
        -->
        <xsl:variable name="releaseType" select="
                if ($publicationIsRelease = true()) then
                    ('RELEASE')
                else
                    ('VERSION')"/>
        <xsl:result-document href="{$theHtmlDir}{$releaseType}.txt" method="text">
            <xsl:value-of select="$latestVersionOrRelease/@versionLabel"/>
        </xsl:result-document>
        <!-- The index.php pulls this in without escaping so we escape this part -->
        <xsl:result-document href="{$theHtmlDir}aaacomments" method="xml" omit-xml-declaration="yes">
            <xsl:value-of select="$latestVersionOrRelease/@versionLabel"/>
        </xsl:result-document>
        
        <!-- Front Page
            ============
        -->
        <xsl:call-template name="doFrontPageTab"/>
        <!-- Project Information
            =====================
        -->
        <xsl:call-template name="doProjectTab"/>
        <!-- Datasets
            =========
        -->
        <xsl:if test="$tabnameslist//tab[@key = 'tabDataSet']">
            <xsl:call-template name="doDatasetsTab"/>
        </xsl:if>
        <!-- Scenarios
            ===========
        -->
        <xsl:if test="$tabnameslist//tab[@key = 'tabScenarios']">
            <xsl:call-template name="doScenarioTab"/>
        </xsl:if>
        <!-- Identifiers
            =============
        -->
        <xsl:if test="$tabnameslist//tab[@key = 'tabIdentifiers']">
            <xsl:call-template name="doIdentificationTab"/>
        </xsl:if>
        <!-- Terminology
            =============
        -->
        <xsl:if test="$tabnameslist//tab[@key = 'tabTerminology']">
            <xsl:call-template name="doTerminologyTab"/>
        </xsl:if>
        <!-- Rules
            =======
        -->
        <xsl:if test="$tabnameslist//tab[@key = 'tabRules']">
            <xsl:call-template name="doRulesTab"/>
        </xsl:if>
        <!-- Questionnaires
            =======
        -->
        <xsl:if test="$tabnameslist//tab[@key = 'tabQuestionnaires']">
            <xsl:call-template name="doQuestionnairesTab"/>
        </xsl:if>
        <!-- Issues
            ========
        -->
        <xsl:if test="$tabnameslist//tab[@key = 'tabIssues']">
            <xsl:call-template name="doIssuesTab"/>
        </xsl:if>
        <!-- Compile Time
            ==============
        -->
        <xsl:call-template name="doCompileTimeTab"/>
        <!-- Legal
            =======
        -->
        <xsl:call-template name="doLegalTab"/>
        <!-- 
            Filtered? Add the filtered file
        -->
        <xsl:if test="$filtersfileavailable = true()">
            <xsl:variable name="filterindf" select="concat($outputBaseUriPrefix, $projectPrefix, 'filter-', $theTimeStamp, '.txt')"/>
            <xsl:result-document href="{$filterindf}" method="text">
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'partialPublicationInfolist'"/>
                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                    <xsl:with-param name="p1" select="doc($filtersfile)/*/@label"/>
                </xsl:call-template>
            </xsl:result-document>
        </xsl:if>
    </xsl:template>
    <xsl:template name="doFrontPageTab">
        <xsl:variable name="content1">
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <!-- 
                    this is a table
                    two or more columns
                    left colum is 2 rows
                      top: logo 
                      bottom: project info + copyright
                    right column is n rows (as much as copyrights)
                -->
                <table cellspacing="3" cellpadding="15" style="width: 100%; border: 0; background-color: #FFFFFF;">
                    <tr style="vertical-align: top;">
                        <td style="max-width: 50%;">
                            <img src="{$theAssetsDir}3dartdecor2016.jpg" style="max-width: 200px;" alt="ART-DECOR logo"/>
                        </td>
                        <td rowspan="3">
                            <xsl:if test="//project/copyright[@logo | *]">
                                <table border="0" cellspacing="7" cellpadding="11" style="background-color: #FFFFFF;">
                                    <xsl:for-each select="//project/copyright[@logo | *]">
                                        <tr>
                                            <td style="width: 3px; background-color: #cecbc6;">
                                                <!-- place a grey line before each logo/address -->
                                            </td>
                                            <td style="width: 1%;">
                                                <!-- place a logo if specified, check projectprefix-logos/@logo -->
                                                <xsl:if test="@logo">
                                                    <xsl:variable name="theLogo">
                                                        <xsl:value-of select="$theLogosDir"/>
                                                        <xsl:value-of select="@logo"/>
                                                    </xsl:variable>
                                                    <img src="{$theLogo}" style="max-width:200px; max-height:70px;" alt="logo"/>
                                                </xsl:if>
                                            </td>
                                            <td style="vertical-align: top;">
                                                <!-- show all adrress lines -->
                                                <xsl:for-each select="addrLine">
                                                    <xsl:choose>
                                                        <xsl:when test="@type = 'uri'">
                                                            <a href="{.}">
                                                                <xsl:value-of select="."/>
                                                            </a>
                                                        </xsl:when>
                                                        <xsl:when test="@type = ('twitter', 'linkedin', 'facebook')">
                                                            <a href="{.}" title="{@type}">
                                                                <xsl:call-template name="showIcon">
                                                                    <xsl:with-param name="which" select="@type"/>
                                                                </xsl:call-template>
                                                            </a>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <xsl:value-of select="."/>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                    <br/>
                                                </xsl:for-each>
                                            </td>
                                        </tr>
                                    </xsl:for-each>
                                </table>
                            </xsl:if>
                        </td>
                    </tr>
                    <tr style="vertical-align: top;">
                        <td>
                            <h1>
                                <xsl:choose>
                                    <xsl:when test="string-length(//project/name[@language = $defaultLanguage or not(@language)]) = 0">
                                        <!-- fallback -->
                                        <xsl:value-of select="(//project/name)[1]"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="//project/name[@language = $defaultLanguage or not(@language)][1]"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </h1>
                        </td>
                    </tr>
                    <tr style="vertical-align: top;">
                        <td>
                            <h4>
                                <xsl:if test="//project/(version | release)">
                                    <!-- is current publication a release or just a version? -->
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key">
                                            <xsl:choose>
                                                <xsl:when test="$publicationIsRelease">decorProjectReleaseAsOf</xsl:when>
                                                <xsl:otherwise>decorProjectVersionAsOf</xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:with-param>
                                        <xsl:with-param name="p1">
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$latestVersionOrRelease/@date"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                        <xsl:with-param name="p2" select="($latestVersionOrRelease/@versionLabel[not(. = '')], ' ')[1]"/>
                                    </xsl:call-template>
                                    <br/>
                                </xsl:if>
                                <xsl:if test="$projectIsRepository or $projectIsPrivate">
                                    <xsl:call-template name="doPrivateRepositoryNotice"/>
                                    <br/>
                                </xsl:if>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'htmlExtractAsOf'"/>
                                </xsl:call-template>
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="$currentDateTime"/>
                                </xsl:call-template>
                                <xsl:if test="$inDevelopment">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'developmentVersion'"/>
                                    </xsl:call-template>
                                </xsl:if>
                            </h4>
                            <p/>
                            <a href="..">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'IndexOfAllPublications'"/>
                                </xsl:call-template>
                            </a>
                            <p/>
                            <xsl:if test="$filtersfileavailable = true()">
                                <div style="display:block; background-color: #f0fceb; padding: 10px;">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which">partialpublication</xsl:with-param>
                                    </xsl:call-template>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:text> </xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'partialPublication'"/>
                                    </xsl:call-template>
                                    <hr/>
                                    <xsl:value-of select="doc($filtersfile)/*/normalize-space(@label)"/>
                                </div>
                                <p/>
                            </xsl:if>
                            <xsl:for-each select="//project/license[string-length(@code) > 0]">
                                <xsl:variable name="licenseCode" select="@code"/>
                                <xsl:variable name="licenseDisplayName" select="@displayName[not(. = '')]"/>
                                <p>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'decorProjectLicense'"/>
                                        <xsl:with-param name="p1" select="@code"/>
                                        <xsl:with-param name="p2">
                                            <xsl:choose>
                                                <xsl:when test="$licenseDisplayName">
                                                    <xsl:value-of select="$licenseDisplayName"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getXFormsLabel">
                                                        <xsl:with-param name="simpleTypeKey" select="'LicenseTypes'"/>
                                                        <xsl:with-param name="simpleTypeValue" select="$licenseCode"/>
                                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </p>
                            </xsl:for-each>
                            
                            <xsl:variable name="nowyear" select="year-from-date(current-date())"/>
                            <xsl:variable name="copyrightClean" as="element(copyright)*">
                                <xsl:for-each select="//project/copyright[@by]">
                                    <xsl:copy copy-namespaces="no">
                                        <xsl:copy-of select="@*"/>
                                        <xsl:if test="@years">
                                            <xsl:attribute name="years">
                                                <xsl:for-each select="tokenize(@years, ' ')">
                                                    <xsl:sort select="."/>
                                                    <xsl:value-of select="."/>
                                                </xsl:for-each>
                                            </xsl:attribute>
                                        </xsl:if>
                                        <xsl:attribute name="type" select="(@type, 'author')[1]"/>
                                        <xsl:attribute name="active">
                                            <xsl:choose>
                                                <xsl:when test="tokenize(@years, ' ')[matches(., '-\d{4}$')][xs:integer(tokenize(., '-')[2]) le $nowyear]">false</xsl:when>
                                                <xsl:when test="tokenize(@years, ' ')[matches(., '^\d{4}$')][xs:integer(.) le $nowyear]">false</xsl:when>
                                                <xsl:otherwise>true</xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:attribute>
                                        <xsl:copy-of select="node()"/>
                                    </xsl:copy>
                                </xsl:for-each>
                            </xsl:variable>
                            
                            
                            <xsl:for-each select="$copyrightClean">
                                <xsl:sort select="@active" order="descending"/>
                                <xsl:sort select="@type"/>
                                <xsl:sort select="tokenize(@years, ' ')[1]"/>
                                <xsl:variable name="type" select="@type"/>
                                <p>
                                    <xsl:if test="@active = 'false'">
                                        <xsl:attribute name="style">color: grey;</xsl:attribute>
                                    </xsl:if>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'decorProjectCopyrightBy'"/>
                                        <xsl:with-param name="p1">
                                            <xsl:variable name="years" as="xs:string*">
                                                <xsl:for-each select="tokenize(@years, '\s')">
                                                    <xsl:choose>
                                                        <!-- thisYear- will be thisYear -->
                                                        <xsl:when test=". = concat($nowyear, '-')">
                                                            <xsl:value-of select="substring-before(., '-')"/>
                                                        </xsl:when>
                                                        <!-- 2012- will be 2012-thisYear -->
                                                        <xsl:when test="matches(., '^\d{4}-$')">
                                                            <xsl:value-of select="concat(., $nowyear)"/>
                                                        </xsl:when>
                                                        <!-- else leave as-is -->
                                                        <xsl:otherwise>
                                                            <xsl:value-of select="."/>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:for-each>
                                            </xsl:variable>
                                            <xsl:value-of select="string-join($years, ' ')"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="p2" select="@by"/>
                                        <xsl:with-param name="p3">
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'CopyrightType'"/>
                                                <xsl:with-param name="simpleTypeValue" select="(@type, 'author')[1]"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </p>
                            </xsl:for-each>
                        </td>
                    </tr>
                    <!-- 
                        PATCH ZONE KH 20220718
                        For the projects 'hl7itig' and 'demp5' the scenarios and transactions are listed if it is a scenario based filter.
                        Such a page acts as a "index" page summarizing the filtered artefacts with all descriptions displayed.
                        In the future this shall be a switch (most likely).
                     -->
                    <xsl:if test="$filtersfileavailable = true() and $projectPrefix = ('demo5-', 'hl7itig')">
                        <tr>
                            <td>
                                <h1>
                                    <xsl:choose>
                                        <xsl:when test="string-length(//project/name[@language = $defaultLanguage or not(@language)]) = 0">
                                            <!-- fallback -->
                                            <xsl:value-of select="(//project/name)[1]"/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="//project/name[@language = $defaultLanguage or not(@language)][1]"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text> – </xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'partialPublication'"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <i>
                                        <xsl:value-of select="doc($filtersfile)/*/normalize-space(@label)"/>
                                    </i>
                                </h1>
                                <xsl:for-each select="doc($filtersfile)/*/(scenario|transaction)">
                                    <xsl:variable name="refid" select="@ref"/>
                                    <xsl:variable name="refeff" select="@flexibility"/>
                                    <xsl:variable name="stobj" select="$allScenarios/scenarios/scenario[@id=$refid][@effectiveDate=$refeff] | $allScenarios//scenarios/scenario//transaction[@id=$refid][@effectiveDate=$refeff]"/>
                                    <xsl:variable name="objname" select="name(.)"/>
                                    <xsl:variable name="trgroup" select="$stobj/@type = 'group'"/>
                                    <!-- heading with a little bit of style tweaks towards our standards CSS here -->
                                    <xsl:choose>
                                        <xsl:when test="$objname = 'scenario'">
                                            <h2 style="background-color: inherit;">
                                                <xsl:value-of select="@name"/>
                                                <xsl:text> (</xsl:text>
                                                <xsl:value-of select="$objname"/>
                                                <xsl:text>)</xsl:text>
                                            </h2>
                                        </xsl:when>
                                        <xsl:when test="$trgroup">
                                            <h3 style="background-color: inherit; padding-left: 0; color: #665a4e;">
                                                <xsl:value-of select="@name"/>
                                                <xsl:text> (</xsl:text>
                                                <xsl:value-of select="$objname"/>
                                                <xsl:text> group)</xsl:text>
                                            </h3>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <h4 style="background-color: inherit; padding-left: 0; color: #9a9a9a;">
                                                <xsl:value-of select="@name"/>
                                                <xsl:text> (</xsl:text>
                                                <xsl:value-of select="$objname"/>
                                                <xsl:text>)</xsl:text>
                                            </h4>
                                            <xsl:for-each select="@*"><xsl:value-of select="name(.)"/></xsl:for-each>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Id'"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <xsl:value-of select="$refid"/>
                                    <xsl:text> (</xsl:text>
                                    <xsl:call-template name="showDate">
                                        <xsl:with-param name="date" select="$refeff"/>
                                    </xsl:call-template>
                                    <xsl:text>)</xsl:text>
                                    <xsl:if test="$objname = 'scenario'">
                                        <xsl:text> </xsl:text>
                                        <a href="{local:doHtmlName('SC', $projectPrefix, $refid, $refeff, $refid, $refeff, (), (), '.html', false())}" onclick="target='_blank';">
                                            <xsl:attribute name="title">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Details'"/>
                                                </xsl:call-template>
                                            </xsl:attribute>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Details'"/>
                                            </xsl:call-template>
                                        </a>
                                    </xsl:if>
                                    <p/>
                                    <xsl:call-template name="doDescription">
                                        <xsl:with-param name="ns" select="$stobj/desc"/>
                                    </xsl:call-template>
                                </xsl:for-each>
                            </td>
                        </tr>
                    </xsl:if>
                </table>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabFrontPage'"/>
            <xsl:with-param name="actualcontent" select="$content1"/>
        </xsl:call-template>
    </xsl:template>
    <xsl:template name="doProjectTab">
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Project Page Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:variable name="content2">
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <h2>
                    <a name="labelProject"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'tabProjectInfoTitleString'"/>
                    </xsl:call-template>
                </h2>
                <xsl:call-template name="doProjectInfo"/>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabProjectInformation'"/>
            <xsl:with-param name="actualcontent" select="$content2"/>
        </xsl:call-template>
    </xsl:template>
    <xsl:template name="doScenarioTab">
        <!-- certain columns are hidden initially by default when treetable is active.
            That doesn't work with classic so we don't hide them
        -->
        <xsl:variable name="coldisplay">
            <xsl:if test="$switchCreateTreeTableHtml = 'true'">'display: none;'</xsl:if>
        </xsl:variable>
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Scenarios Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:variable name="content4">
            <xsl:variable name="doDatasets" select="exists(//representingTemplate/@sourceDataset)" as="xs:boolean"/>
            <xsl:variable name="doTemplates" select="exists(//representingTemplate/@ref)" as="xs:boolean"/>
            <xsl:variable name="doModels" select="exists(//transaction[$doTemplates]/@model)" as="xs:boolean"/>
            <xsl:variable name="doQuestionnaires" select="exists(//representingTemplate/@representingQuestionnaire)" as="xs:boolean"/>
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <h2>
                    <a name="labelScenarios"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'tabScenariosTitleString'"/>
                    </xsl:call-template>
                </h2>
                <div class="tabtab">
                    <xsl:choose>
                        <xsl:when test="count(//scenarios/scenario) = 0">
                            <table style="border: 0;">
                                <xsl:call-template name="doMessage">
                                    <xsl:with-param name="level" select="'info'"/>
                                    <xsl:with-param name="msg">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueNoScenariosDefinedYet'"/>
                                        </xsl:call-template>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </table>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                <div>
                                    <button id="expandAll" type="button">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                        </xsl:call-template>
                                    </button>
                                    <button id="collapseAll" type="button">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                        </xsl:call-template>
                                    </button>
                                    <input id="nameSearch">
                                        <xsl:attribute name="placeholder">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'textSearch'"/>
                                            </xsl:call-template>
                                        </xsl:attribute>
                                    </input>
                                    <select id="hiddenColumns">
                                        <option value="title">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'showColumn'"/>
                                            </xsl:call-template>
                                        </option>
                                        <option value="columnDescription">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Description'"/>
                                            </xsl:call-template>
                                        </option>
                                        <option value="columnEffectiveDate">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'effectiveDate'"/>
                                            </xsl:call-template>
                                        </option>
                                        <xsl:if test="//scenarios/scenario[@expirationDate[not(. = '')]]">
                                            <option value="columnExpirationDate">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'expirationDate'"/>
                                                </xsl:call-template>
                                            </option>
                                        </xsl:if>
                                        <option value="columnVersionLabel" disabled="disabled">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnVersionLabel'"/>
                                            </xsl:call-template>
                                        </option>
                                        <option value="columnModel">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Model'"/>
                                            </xsl:call-template>
                                        </option>
                                        <option value="columnDataset" disabled="disabled">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnDataset'"/>
                                            </xsl:call-template>
                                        </option>
                                        <option value="columnTemplate" disabled="disabled">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'template'"/>
                                            </xsl:call-template>
                                        </option>
                                    </select>
                                </div>
                            </xsl:if>
                            <table id="transactionTable" class="treetable highlight" width="100%" border="0" cellspacing="0" cellpadding="5">
                                <thead>
                                    <tr>
                                        <th class="columnDiagram" style="width: 50px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Diagram'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th class="columnXML" style="width: 50px;">
                                            <xsl:text>XML</xsl:text>
                                        </th>
                                        <th class="columnAllView" style="width: 50px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnAllView'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th class="columnCareView" style="width: 50px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnCareView'"/>
                                            </xsl:call-template>
                                        </th>
                                        <xsl:if test="$theV2Scenarios">
                                            <th class="columnV2IGView" style="width: 50px;">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'columnV2IGView'"/>
                                                </xsl:call-template>
                                            </th>
                                        </xsl:if>
                                        <th style="min-width: 40%; max-width: 50%;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnName'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th class="columnDescription" style="{$coldisplay}">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Description'"/>
                                            </xsl:call-template>
                                            <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                                <xsl:text>&#160;</xsl:text>
                                                <span class="hideMe" type="button">[‑]</span>
                                            </xsl:if>
                                        </th>
                                        <th class="columnEffectiveDate" style="width: 150px; {$coldisplay}">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'effectiveDate'"/>
                                            </xsl:call-template>
                                            <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                                <xsl:text>&#160;</xsl:text>
                                                <span class="hideMe" type="button">[‑]</span>
                                            </xsl:if>
                                        </th>
                                        <xsl:if test="//scenarios/scenario[@expirationDate[not(. = '')]]">
                                            <th class="columnExpirationDate" style="width: 150px; {$coldisplay}">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'expirationDate'"/>
                                                </xsl:call-template>
                                                <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                                    <xsl:text>&#160;</xsl:text>
                                                    <span class="hideMe" type="button">[‑]</span>
                                                </xsl:if>
                                            </th>
                                        </xsl:if>
                                        <th class="columnVersionLabel" style="width: 150px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnVersionLabel'"/>
                                            </xsl:call-template>
                                            <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                                <xsl:text>&#160;</xsl:text>
                                                <span class="hideMe" type="button">[‑]</span>
                                            </xsl:if>
                                        </th>
                                        <xsl:if test="$doDatasets">
                                            <th class="columnDataset">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'columnDataset'"/>
                                                </xsl:call-template>
                                                <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                                    <xsl:text>&#160;</xsl:text>
                                                    <span class="hideMe" type="button">[‑]</span>
                                                </xsl:if>
                                            </th>
                                        </xsl:if>
                                        <xsl:if test="$doModels">
                                            <th class="columnModel" style="{$coldisplay}">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Model'"/>
                                                </xsl:call-template>
                                                <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                                    <xsl:text>&#160;</xsl:text>
                                                    <span class="hideMe" type="button">[‑]</span>
                                                </xsl:if>
                                            </th>
                                        </xsl:if>
                                        <xsl:if test="$doTemplates">
                                            <th class="columnTemplate">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'template'"/>
                                                </xsl:call-template>
                                                <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                                    <xsl:text>&#160;</xsl:text>
                                                    <span class="hideMe" type="button">[‑]</span>
                                                </xsl:if>
                                            </th>
                                        </xsl:if>
                                        <xsl:if test="$doQuestionnaires">
                                            <th class="columnQuestionnaire">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Questionnaire'"/>
                                                </xsl:call-template>
                                                <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                                    <xsl:text>&#160;</xsl:text>
                                                    <span class="hideMe" type="button">[‑]</span>
                                                </xsl:if>
                                            </th>
                                        </xsl:if>
                                    </tr>
                                </thead>
                                <tbody>
                                    <xsl:for-each select="//scenarios/scenario | //scenarios/scenario//transaction">
                                        <xsl:sort select="ancestor-or-self::scenario/@effectiveDate" order="descending"/>
                                        <xsl:variable name="level" select="count(ancestor::scenario | ancestor::transaction) + 1"/>
                                        <xsl:variable name="itemAnchor" select="local:doHtmlAnchor(@id, @effectiveDate)"/>
                                        <xsl:variable name="scid" select="ancestor-or-self::scenario/@id"/>
                                        <xsl:variable name="sceff" select="ancestor-or-self::scenario/@effectiveDate"/>
                                        <!-- cache transaction/@effectiveDate. This is relatively new so might not be present -->
                                        <xsl:variable name="trid" select="self::transaction/@id"/>
                                        <xsl:variable name="tred" select="self::transaction/@effectiveDate"/>
                                        <xsl:variable name="transactionAnchor">
                                            <xsl:if test="$trid">
                                                <xsl:text>#</xsl:text>
                                                <xsl:value-of select="local:doHtmlAnchor($trid, $tred)"/>
                                            </xsl:if>
                                        </xsl:variable>
                                        <xsl:variable name="node-id" select="generate-id(.)"/>
                                        <xsl:variable name="node-class" as="xs:string">
                                            <xsl:choose>
                                                <xsl:when test="self::scenario">scline</xsl:when>
                                                <xsl:when test="self::transaction[@type = 'group']">trgroupline</xsl:when>
                                                <xsl:otherwise>trline</xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:variable>
                                        <xsl:variable name="sc-style" select="
                                                if (self::scenario) then
                                                    'border-top: 6px solid white;'
                                                else
                                                    ()"/>
                                        <tr data-tt-id="{$node-id}" class="{$node-class}">
                                            <xsl:if test="parent::scenario | parent::transaction">
                                                <xsl:attribute name="data-tt-parent-id" select="generate-id(parent::*)"/>
                                            </xsl:if>
                                            <!-- Diagram -->
                                            <td class="columnDiagram" style="{$sc-style}">
                                                <xsl:if test="count(representingTemplate/concept) &gt; 0 and string-length($projectRestUriDSDiagram) &gt; 0">
                                                    <a href="{$projectRestUriDSDiagram}&amp;transactionId={@id}&amp;transactionEffectiveDate={encode-for-uri(@effectiveDate)}&amp;format=svg" onclick="target='_blank';">link</a>
                                                </xsl:if>
                                            </td>
                                            <!-- XML -->
                                            <td class="columnXML" style="{$sc-style}">
                                                <!-- Prevent link here so it saves the user pointless clicking into an HTML without content -->
                                                <xsl:if test="count(representingTemplate/concept) &gt; 0">
                                                    <xsl:if test="string-length($projectRestUriDS) &gt; 0">
                                                        <a href="{$projectRestUriDS}&amp;id={$trid}&amp;effectiveDate={encode-for-uri($tred)}&amp;format=xml" onclick="target='_blank';">xml</a>
                                                    </xsl:if>
                                                </xsl:if>
                                            </td>
                                            <!-- columnAllView -->
                                            <!-- FIXME? the ProjectIndex has a different understanding of "All" than this link has... -->
                                            <td class="columnAllView" style="{$sc-style}">
                                                <xsl:choose>
                                                    <xsl:when test="self::scenario | self::transaction[@type[. = 'group'] | transaction]">
                                                        <a href="{local:doHtmlName('SC', $projectPrefix, $scid, $sceff, $trid, $tred, (), (), '.html', false())}" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'Details'"/>
                                                                </xsl:call-template>
                                                            </xsl:attribute>
                                                            <xsl:text>html</xsl:text>
                                                        </a>
                                                    </xsl:when>
                                                    <!-- Prevent link here so it saves the user pointless clicking into an HTML without content -->
                                                    <xsl:when test="count(representingTemplate/concept) &gt; 0">
                                                        <a href="{local:doHtmlName('TR',$trid,$tred,'.html')}" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'columnAllView'"/>
                                                                </xsl:call-template>
                                                            </xsl:attribute>
                                                            <xsl:text>html</xsl:text>
                                                        </a>
                                                    </xsl:when>
                                                </xsl:choose>
                                            </td>
                                            <!-- columnCareViewView -->
                                            <!-- FIXME? the ProjectIndex offers 2 flavors of care view. We only offer one version here... -->
                                            <td class="columnCareView" style="{$sc-style}">
                                                <!-- Prevent link here so it saves the user pointless clicking into an HTML without content -->
                                                <xsl:if test="representingTemplate/concept">
                                                    <xsl:if test="string-length($projectRestUriDS) &gt; 0">
                                                        <a href="{$projectRestUriDS}&amp;id={$trid}&amp;effectiveDate={encode-for-uri($tred)}&amp;format=html" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'columnCareView'"/>
                                                                </xsl:call-template>
                                                            </xsl:attribute>
                                                            <xsl:text>html</xsl:text>
                                                        </a>
                                                    </xsl:if>
                                                </xsl:if>
                                            </td>
                                            <!-- HL7 V2 IG -->
                                            <xsl:if test="$theV2Scenarios">
                                                <td class="columnV2IGView" style="{$sc-style}">
                                                    <xsl:if test="self::scenario">
                                                        <xsl:variable name="thisScenarioIG" select="$theV2Scenarios[@id = $scid][@effectiveDate = $sceff]" as="element(scenario)*"/>
                                                        <xsl:for-each select="$thisScenarioIG">
                                                            <div>
                                                                <a href="{local:doHtmlName('SC', $projectPrefix, $scid, $sceff, (), (), (), (), '_HL7V2-IG.html', false())}" onclick="target='_blank';">
                                                                    <xsl:attribute name="title">
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'DetailsHL7V2IG'"/>
                                                                        </xsl:call-template>
                                                                    </xsl:attribute>
                                                                    <xsl:text>html</xsl:text>
                                                                </a>
                                                            </div>
                                                            <xsl:if test="$switchCreateSchematron">
                                                                <div>
                                                                    <a href="{local:doHtmlName('SC', $projectPrefix, $scid, $sceff, (), (), (), (), '_HL7V2-CP.xml', false())}" onclick="target='_blank';">
                                                                        <xsl:attribute name="title">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'DetailsHL7V2CP'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:attribute>
                                                                        <xsl:text>xml</xsl:text>
                                                                    </a>
                                                                </div>
                                                            </xsl:if>
                                                        </xsl:for-each>
                                                    </xsl:if>
                                                </td>
                                            </xsl:if>
                                            <!-- Name -->
                                            <td class="columnName" style="{$sc-style}">
                                                <a name="{$itemAnchor}"/>
                                                <xsl:variable name="columnName">
                                                    <xsl:call-template name="showStatusDot">
                                                        <xsl:with-param name="status" select="@statusCode"/>
                                                        <xsl:with-param name="title">
                                                            <xsl:call-template name="getXFormsLabel">
                                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                            </xsl:call-template>
                                                        </xsl:with-param>
                                                    </xsl:call-template>
                                                    <xsl:text>&#160;</xsl:text>
                                                    <xsl:choose>
                                                        <xsl:when test="self::scenario"/>
                                                        <xsl:when test="self::transaction[@type[. = 'group'] | transaction]">
                                                            <xsl:call-template name="showIcon">
                                                                <xsl:with-param name="which">doublearrow</xsl:with-param>
                                                                <xsl:with-param name="tooltip">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'Group'"/>
                                                                    </xsl:call-template>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                            <xsl:text>&#160;</xsl:text>
                                                        </xsl:when>
                                                        <xsl:when test="self::transaction">
                                                            <xsl:call-template name="showDirection">
                                                                <xsl:with-param name="dir" select="@type"/>
                                                            </xsl:call-template>
                                                            <xsl:text>&#160;</xsl:text>
                                                        </xsl:when>
                                                    </xsl:choose>
                                                    <xsl:call-template name="doName">
                                                        <xsl:with-param name="ns" select="name"/>
                                                    </xsl:call-template>
                                                </xsl:variable>
                                                <xsl:choose>
                                                    <xsl:when test="not($switchCreateTreeTableHtml = 'true')">
                                                        <table>
                                                            <tr>
                                                                <xsl:call-template name="doIndentLevel">
                                                                    <xsl:with-param name="level" select="$level"/>
                                                                    <xsl:with-param name="icon" select="false()"/>
                                                                </xsl:call-template>
                                                                <td>
                                                                    <xsl:copy-of select="$columnName"/>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:copy-of select="$columnName"/>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </td>
                                            <!-- Desc -->
                                            <td class="columnDescription" style="{$sc-style} {$coldisplay}">
                                                <xsl:call-template name="doDescription">
                                                    <xsl:with-param name="ns" select="desc"/>
                                                    <xsl:with-param name="shortDesc" select="true()"/>
                                                </xsl:call-template>
                                            </td>
                                            <!-- effectiveDate -->
                                            <td class="columnEffectiveDate" style="{$sc-style} {$coldisplay}">
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="@effectiveDate"/>
                                                </xsl:call-template>
                                            </td>
                                            <!-- expirationDate -->
                                            <xsl:if test="//scenarios/scenario[@expirationDate[not(. = '')]]">
                                                <td class="columnExpirationDate" style="{$coldisplay} {$sc-style}">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="@expirationDate"/>
                                                    </xsl:call-template>
                                                </td>
                                            </xsl:if>
                                            <!-- versionLabel -->
                                            <td class="columnVersionLabel" style="{$sc-style}">
                                                <xsl:value-of select="@versionLabel"/>
                                            </td>
                                            <!-- Dataset -->
                                            <xsl:if test="$doDatasets">
                                                <td class="columnDataset" style="{$sc-style}">
                                                    <xsl:for-each select="representingTemplate[@sourceDataset]">
                                                        <xsl:variable name="dsid" select="@sourceDataset"/>
                                                        <xsl:variable name="dsed" select="@sourceDatasetFlexibility"/>
                                                        <xsl:variable name="dataset" select="
                                                                if ($dsid) then
                                                                    local:getDataset($dsid, $dsed)
                                                                else
                                                                    ()" as="element()?"/>
                                                        <xsl:if test="$dsid and not($dataset)">
                                                            <xsl:call-template name="logMessage">
                                                                <xsl:with-param name="level" select="$logERROR"/>
                                                                <xsl:with-param name="msg">
                                                                    <xsl:text>+++ Could not find referenced dataset id='</xsl:text>
                                                                    <xsl:value-of select="$dsid"/>
                                                                    <xsl:text>' referenced from transaction '</xsl:text>
                                                                    <xsl:call-template name="doDescription">
                                                                        <xsl:with-param name="ns" select="../name"/>
                                                                    </xsl:call-template>
                                                                    <xsl:text>' (</xsl:text>
                                                                    <xsl:value-of select="../@id"/>
                                                                    <xsl:text> - </xsl:text>
                                                                    <xsl:value-of select="../@effectiveDate"/>
                                                                    <xsl:text>). This might be due to it being in a different project/BBR or because the sourceDataset/sourceDatasetFlexibility is broken.</xsl:text>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                        </xsl:if>
                                                        <a href="{local:doHtmlName('TR',$trid,$tred,'.html')}" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="$dataset/name"/>
                                                                </xsl:call-template>
                                                                <xsl:if test="$dataset[@versionLabel]">
                                                                    <xsl:text> </xsl:text>
                                                                    <xsl:value-of select="$dataset/@versionLabel"/>
                                                                </xsl:if>
                                                                <xsl:text> </xsl:text>
                                                                <i>
                                                                    <xsl:text>(</xsl:text>
                                                                    <xsl:value-of select="$dsid"/>
                                                                    <xsl:text> / </xsl:text>
                                                                    <xsl:choose>
                                                                        <xsl:when test="$dsed castable as xs:dateTime">
                                                                            <xsl:call-template name="showDate">
                                                                                <xsl:with-param name="date" select="$dsed"/>
                                                                            </xsl:call-template>
                                                                        </xsl:when>
                                                                        <xsl:otherwise>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:otherwise>
                                                                    </xsl:choose>
                                                                    <xsl:text>)</xsl:text>
                                                                </i>
                                                            </xsl:attribute>
                                                            <xsl:call-template name="doName">
                                                                <xsl:with-param name="ns" select="$dataset/name"/>
                                                            </xsl:call-template>
                                                            <xsl:if test="$dataset[@versionLabel]">
                                                                <xsl:text> </xsl:text>
                                                                <xsl:value-of select="$dataset/@versionLabel"/>
                                                            </xsl:if>
                                                        </a>
                                                    </xsl:for-each>
                                                </td>
                                            </xsl:if>
                                            <!-- Model -->
                                            <xsl:if test="$doModels">
                                                <td class="columnModel" style="{$sc-style} {$coldisplay}">
                                                    <xsl:value-of select="@model"/>
                                                </td>
                                            </xsl:if>
                                            <!-- Template -->
                                            <xsl:if test="$doTemplates">
                                                <td class="columnTemplate" style="{$sc-style}">
                                                    <xsl:for-each select="representingTemplate[@ref]">
                                                        <xsl:variable name="tmid" select="@ref"/>
                                                        <xsl:variable name="tmed" select="
                                                                if (@flexibility castable as xs:dateTime) then
                                                                    @flexibility
                                                                else
                                                                    ('dynamic')"/>
                                                        <xsl:variable name="rccontent" as="element()?">
                                                            <xsl:call-template name="getRulesetContent">
                                                                <xsl:with-param name="ruleset" select="$tmid"/>
                                                                <xsl:with-param name="flexibility" select="$tmed"/>
                                                                <xsl:with-param name="sofar" select="()"/>
                                                            </xsl:call-template>
                                                        </xsl:variable>
                                                        <xsl:variable name="tmname">
                                                            <xsl:choose>
                                                                <xsl:when test="$rccontent[@displayName]">
                                                                    <xsl:value-of select="$rccontent/@displayName"/>
                                                                </xsl:when>
                                                                <xsl:when test="$rccontent[@name]">
                                                                    <xsl:value-of select="$rccontent/@name"/>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:value-of select="$tmid"/>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </xsl:variable>
                                                        <a href="{local:doHtmlName('TM',$rccontent/@id,$tmed,'.html')}" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:value-of select="$tmname"/>
                                                                <xsl:text> </xsl:text>
                                                                <i>
                                                                    <xsl:text>(</xsl:text>
                                                                    <xsl:if test="$rccontent">
                                                                        <xsl:value-of select="$rccontent/(@id | @ref)"/>
                                                                        <xsl:text> / </xsl:text>
                                                                    </xsl:if>
                                                                    <xsl:choose>
                                                                        <xsl:when test="$tmed castable as xs:dateTime">
                                                                            <xsl:call-template name="showDate">
                                                                                <xsl:with-param name="date" select="$tmed"/>
                                                                            </xsl:call-template>
                                                                        </xsl:when>
                                                                        <xsl:otherwise>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:otherwise>
                                                                    </xsl:choose>
                                                                    <xsl:text>)</xsl:text>
                                                                </i>
                                                            </xsl:attribute>
                                                            <xsl:value-of select="$tmname"/>
                                                        </a>
                                                    </xsl:for-each>
                                                </td>
                                            </xsl:if>
                                            <!-- Questionnaire -->
                                            <xsl:if test="$doQuestionnaires">
                                                <td class="columnQuestionnaire" style="{$sc-style}">
                                                    <xsl:for-each select="representingTemplate[@representingQuestionnaire]">
                                                        <xsl:variable name="qqid" select="@representingQuestionnaire"/>
                                                        <xsl:variable name="qqed" select="@representingQuestionnaireFlexibility"/>
                                                        <xsl:variable name="qq" as="element()?">
                                                            <xsl:call-template name="getQuestionnaireContent">
                                                                <xsl:with-param name="qqid" select="$qqid"/>
                                                                <xsl:with-param name="qqed" select="$qqed"/>
                                                            </xsl:call-template>
                                                        </xsl:variable>
                                                        <xsl:variable name="qqname">
                                                            <xsl:call-template name="doName">
                                                                <xsl:with-param name="ns" select="$qq/name"/>
                                                            </xsl:call-template>
                                                        </xsl:variable>
                                                        <a href="{local:doHtmlName('QQ',$qq/@id,$qqed,'.html')}" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:value-of select="$qqname[1]"/>
                                                                <xsl:text> </xsl:text>
                                                                <i>
                                                                    <xsl:text>(</xsl:text>
                                                                    <xsl:if test="$qq">
                                                                        <xsl:value-of select="$qq/(@id | @ref)"/>
                                                                        <xsl:text> / </xsl:text>
                                                                    </xsl:if>
                                                                    <xsl:choose>
                                                                        <xsl:when test="$qqed castable as xs:dateTime">
                                                                            <xsl:call-template name="showDate">
                                                                                <xsl:with-param name="date" select="$qqed"/>
                                                                            </xsl:call-template>
                                                                        </xsl:when>
                                                                        <xsl:otherwise>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:otherwise>
                                                                    </xsl:choose>
                                                                    <xsl:text>)</xsl:text>
                                                                </i>
                                                            </xsl:attribute>
                                                            <xsl:copy-of select="$qqname"/>
                                                        </a>
                                                    </xsl:for-each>
                                                </td>
                                            </xsl:if>
                                        </tr>
                                    </xsl:for-each>
                                </tbody>
                            </table>
                        </xsl:otherwise>
                    </xsl:choose>
                </div>
                <!--  then show a summary of scenario table -->
                <h2>
                    <a name="labelScenarios"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'scenarioSummary'"/>
                    </xsl:call-template>
                </h2>
                <table width="50%" border="0" cellspacing="2" cellpadding="2">
                    <tr style="vertical-align: top;">
                        <td class="tabtab">
                            <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                <tr style="background-color: #CCFFCC;">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'scenarios'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td colspan="2">
                                        <xsl:value-of select="count($allScenarios/scenarios/scenario)"/>
                                    </td>
                                </tr>
                                <tr style="background-color: #CCFFCC;">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'transactionGroups'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td colspan="2">
                                        <xsl:value-of select="count($allScenarios/scenarios/scenario//transaction[@type = 'group'])"/>
                                    </td>
                                </tr>
                                <tr style="background-color: #CCFFCC;">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'transactions'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td colspan="2">
                                        <xsl:value-of select="count($allScenarios/scenarios/scenario//transaction[not(@type = 'group')])"/>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <!-- create rule lists per scenario x -->
                <h2>
                    <a name="labelActors"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'transactionsPerActor'"/>
                    </xsl:call-template>
                </h2>
                <xsl:if test="count($allActors//actor) > 1">
                    <ol>
                        <xsl:for-each select="$allActors//actor">
                            <li>
                                <a href="#{local:doHtmlAnchor(@id, ())}">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="concat('actorType-', @type)"/>
                                    </xsl:call-template>
                                    <xsl:text>:&#160;</xsl:text>
                                    <xsl:call-template name="doName">
                                        <xsl:with-param name="ns" select="name"/>
                                    </xsl:call-template>
                                </a>
                            </li>
                        </xsl:for-each>
                    </ol>
                </xsl:if>
                <xsl:for-each select="$allActors//actor[@id]">
                    <xsl:variable name="actorid" select="@id"/>
                    <xsl:variable name="actorname">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="concat('actorType-', @type)"/>
                        </xsl:call-template>
                        <xsl:text>:&#160;</xsl:text>
                        <xsl:call-template name="doName">
                            <xsl:with-param name="ns" select="name"/>
                        </xsl:call-template>
                    </xsl:variable>
                    <a name="{local:doHtmlAnchor(@id, ())}"/>
                    <h3>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'transactionsForActor'"/>
                        </xsl:call-template>
                        <xsl:text> </xsl:text>
                        <i>
                            <xsl:value-of select="$actorname"/>
                        </i>
                    </h3>
                    <div class="tabtab">
                        <table class="highlight" width="100%" border="0" cellspacing="3" cellpadding="2">
                            <thead>
                                <tr>
                                    <th style="width: 10%;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'actorRole'"/>
                                        </xsl:call-template>
                                    </th>
                                    <th style="width: 30%;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Transaction'"/>
                                        </xsl:call-template>
                                    </th>
                                    <xsl:if test="$doModels">
                                        <th style="width: 150px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Model'"/>
                                            </xsl:call-template>
                                        </th>
                                    </xsl:if>
                                    <xsl:if test="$doTemplates">
                                        <th style="width: 20%;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Template'"/>
                                            </xsl:call-template>
                                        </th>
                                    </xsl:if>
                                    <xsl:if test="$doQuestionnaires">
                                        <th style="width: 20%;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Questionnaire'"/>
                                            </xsl:call-template>
                                        </th>
                                    </xsl:if>
                                    <th style="width: 2%;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Diagram'"/>
                                        </xsl:call-template>
                                    </th>
                                    <th style="width: 2%">
                                        <xsl:text>XML</xsl:text>
                                    </th>
                                    <th style="width: 2%;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'columnAllView'"/>
                                        </xsl:call-template>
                                    </th>
                                    <th style="width: 2%;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'columnCareView'"/>
                                        </xsl:call-template>
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <xsl:for-each select="$allScenarios/scenarios/scenario//transaction[@type = 'group'][transaction/actors/actor/@id = $actorid]">
                                    <tr class="trgroupline">
                                        <!-- Role -->
                                        <td style="text-align: left;">&#160;</td>
                                        <!-- Transaction name -->
                                        <td style="text-align: left;">
                                            <xsl:call-template name="showStatusDot">
                                                <xsl:with-param name="status" select="@statusCode"/>
                                                <xsl:with-param name="title">
                                                    <xsl:call-template name="getXFormsLabel">
                                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                    </xsl:call-template>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                            <xsl:text>&#160;</xsl:text>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">doublearrow</xsl:with-param>
                                                <xsl:with-param name="tooltip">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'Group'"/>
                                                    </xsl:call-template>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                            <xsl:text>&#160;</xsl:text>
                                            <i>
                                                <xsl:call-template name="doName">
                                                    <xsl:with-param name="ns" select="name"/>
                                                </xsl:call-template>
                                            </i>
                                        </td>
                                        <!-- Model -->
                                        <xsl:if test="$doModels">
                                            <td style="text-align: left;">&#160;</td>
                                        </xsl:if>
                                        <!-- Template -->
                                        <xsl:if test="$doTemplates">
                                            <td style="text-align: left;">&#160;</td>
                                        </xsl:if>
                                        <!-- Questionnaire -->
                                        <xsl:if test="$doQuestionnaires">
                                            <td style="text-align: left;">&#160;</td>
                                        </xsl:if>
                                        <!-- Diagram -->
                                        <td style="text-align: left;">&#160;</td>
                                        <!-- XML -->
                                        <td style="text-align: left;">&#160;</td>
                                        <!-- columnAllView -->
                                        <td style="text-align: left;">&#160;</td>
                                        <!-- columnCareViewView -->
                                        <td style="text-align: left;">&#160;</td>
                                    </tr>
                                    <xsl:for-each select="transaction[actors/actor/@id = $actorid]">
                                        <xsl:variable name="scid" select="ancestor::scenario/@id"/>
                                        <xsl:variable name="sced" select="ancestor::scenario/@effectiveDate"/>
                                        <xsl:variable name="trid" select="@id"/>
                                        <xsl:variable name="tred" select="@effectiveDate"/>
                                        <xsl:variable name="transactionAnchor" select="local:doHtmlAnchor($trid, $tred)"/>
                                        <tr class="trline">
                                            <!-- Role -->
                                            <td style="text-align: left;">
                                                <xsl:for-each select="actors/actor[@id = $actorid]">
                                                    <xsl:choose>
                                                        <xsl:when test="@role = 'sender' or @role = 'receiver'">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="concat('actorRole-', @role)"/>
                                                            </xsl:call-template>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <xsl:value-of select="@role"/>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                    <xsl:if test="position() != last()">
                                                        <xsl:text> / </xsl:text>
                                                    </xsl:if>
                                                </xsl:for-each>
                                            </td>
                                            <!-- Transaction name -->
                                            <td style="text-align: left;">
                                                <span style=" margin-left: 20px;"/>
                                                <xsl:call-template name="showStatusDot">
                                                    <xsl:with-param name="status" select="@statusCode"/>
                                                    <xsl:with-param name="title">
                                                        <xsl:call-template name="getXFormsLabel">
                                                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                        </xsl:call-template>
                                                    </xsl:with-param>
                                                </xsl:call-template>
                                                <xsl:text>&#160;</xsl:text>
                                                <xsl:call-template name="showDirection">
                                                    <xsl:with-param name="dir" select="@type"/>
                                                </xsl:call-template>
                                                <xsl:text>&#160;</xsl:text>
                                                <xsl:call-template name="doName">
                                                    <xsl:with-param name="ns" select="name"/>
                                                </xsl:call-template>
                                            </td>
                                            <!-- Model -->
                                            <xsl:if test="$doModels">
                                                <td style="text-align: left;">
                                                    <xsl:value-of select="@model"/>
                                                </td>
                                            </xsl:if>
                                            <!-- Template -->
                                            <xsl:if test="$doTemplates">
                                                <td>
                                                    <xsl:for-each select="representingTemplate[@ref]">
                                                        <xsl:variable name="tmid" select="@ref"/>
                                                        <xsl:variable name="tmed" select="
                                                                if (@flexibility castable as xs:dateTime) then
                                                                    @flexibility
                                                                else
                                                                    ('dynamic')"/>
                                                        <xsl:variable name="rccontent" as="element()?">
                                                            <xsl:call-template name="getRulesetContent">
                                                                <xsl:with-param name="ruleset" select="$tmid"/>
                                                                <xsl:with-param name="flexibility" select="$tmed"/>
                                                                <xsl:with-param name="sofar" select="()"/>
                                                            </xsl:call-template>
                                                        </xsl:variable>
                                                        <xsl:variable name="tmname">
                                                            <xsl:choose>
                                                                <xsl:when test="$rccontent[@displayName]">
                                                                    <xsl:value-of select="$rccontent/@displayName"/>
                                                                </xsl:when>
                                                                <xsl:when test="$rccontent[@name]">
                                                                    <xsl:value-of select="$rccontent/@name"/>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:value-of select="$tmid"/>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </xsl:variable>
                                                        <a href="{local:doHtmlName('TM',$rccontent/@id,$tmed,'.html')}" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:value-of select="$tmname"/>
                                                                <xsl:text> </xsl:text>
                                                                <i>
                                                                    <xsl:text>(</xsl:text>
                                                                    <xsl:if test="$rccontent">
                                                                        <xsl:value-of select="$rccontent/(@id | @ref)"/>
                                                                        <xsl:text> / </xsl:text>
                                                                    </xsl:if>
                                                                    <xsl:choose>
                                                                        <xsl:when test="$tmed castable as xs:dateTime">
                                                                            <xsl:call-template name="showDate">
                                                                                <xsl:with-param name="date" select="$tmed"/>
                                                                            </xsl:call-template>
                                                                        </xsl:when>
                                                                        <xsl:otherwise>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:otherwise>
                                                                    </xsl:choose>
                                                                    <xsl:text>)</xsl:text>
                                                                </i>
                                                            </xsl:attribute>
                                                            <xsl:value-of select="$tmname"/>
                                                        </a>
                                                    </xsl:for-each>
                                                </td>
                                            </xsl:if>
                                            <!-- Questionnaire -->
                                            <xsl:if test="$doQuestionnaires">
                                                <td>
                                                    <xsl:for-each select="representingTemplate[@representingQuestionnaire]">
                                                        <xsl:variable name="qqid" select="@representingQuestionnaire"/>
                                                        <xsl:variable name="qqed" select="@representingQuestionnaireFlexibility"/>
                                                        <xsl:variable name="qq" as="element()?">
                                                            <xsl:call-template name="getQuestionnaireContent">
                                                                <xsl:with-param name="qqid" select="$qqid"/>
                                                                <xsl:with-param name="qqed" select="$qqed"/>
                                                            </xsl:call-template>
                                                        </xsl:variable>
                                                        <xsl:variable name="qqname">
                                                            <xsl:call-template name="doName">
                                                                <xsl:with-param name="ns" select="$qq/name"/>
                                                            </xsl:call-template>
                                                        </xsl:variable>
                                                        <a href="{local:doHtmlName('QQ',$qq/@id,$qqed,'.html')}" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:value-of select="$qqname"/>
                                                                <xsl:text> </xsl:text>
                                                                <i>
                                                                    <xsl:text>(</xsl:text>
                                                                    <xsl:if test="$qq">
                                                                        <xsl:value-of select="$qq/(@id | @ref)"/>
                                                                        <xsl:text> / </xsl:text>
                                                                    </xsl:if>
                                                                    <xsl:choose>
                                                                        <xsl:when test="$qqed castable as xs:dateTime">
                                                                            <xsl:call-template name="showDate">
                                                                                <xsl:with-param name="date" select="$qqed"/>
                                                                            </xsl:call-template>
                                                                        </xsl:when>
                                                                        <xsl:otherwise>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:otherwise>
                                                                    </xsl:choose>
                                                                    <xsl:text>)</xsl:text>
                                                                </i>
                                                            </xsl:attribute>
                                                            <xsl:copy-of select="$qqname"/>
                                                        </a>
                                                    </xsl:for-each>
                                                </td>
                                            </xsl:if>
                                            <!-- Diagram -->
                                            <td>
                                                <xsl:if test="representingTemplate/concept and string-length($projectRestUriDSDiagram) &gt; 0">
                                                    <a href="{$projectRestUriDSDiagram}&amp;transactionId={$trid}&amp;transactionEffectiveDate={encode-for-uri($tred)}&amp;format=svg" onclick="target='_blank';">link</a>
                                                </xsl:if>
                                            </td>
                                            <!-- XML -->
                                            <td>
                                                <!-- Prevent link here so it saves the user pointless clicking into an HTML without content -->
                                                <xsl:if test="representingTemplate/concept">
                                                    <xsl:if test="string-length($projectRestUriDS) &gt; 0">
                                                        <a href="{$projectRestUriDS}&amp;id={$trid}&amp;effectiveDate={encode-for-uri($tred)}&amp;format=xml" onclick="target='_blank';">xml</a>
                                                    </xsl:if>
                                                </xsl:if>
                                            </td>
                                            <!-- columnAllView -->
                                            <!-- FIXME? the ProjectIndex has a different understanding of "All" than this link has... -->
                                            <td>
                                                <xsl:choose>
                                                    <xsl:when test="self::scenario | self::transaction[@type[. = 'group'] | transaction]">
                                                        <a href="{local:doHtmlName('SC', $projectPrefix, $scid, $sced, $trid, $tred, (), (), '.html', false())}" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'Details'"/>
                                                                </xsl:call-template>
                                                            </xsl:attribute>
                                                            <xsl:text>html</xsl:text>
                                                        </a>
                                                    </xsl:when>
                                                    <!-- Prevent link here so it saves the user pointless clicking into an HTML without content -->
                                                    <xsl:when test="representingTemplate/concept">
                                                        <a href="{local:doHtmlName('TR',$trid,$tred,'.html')}" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'columnAllView'"/>
                                                                </xsl:call-template>
                                                            </xsl:attribute>
                                                            <xsl:text>html</xsl:text>
                                                        </a>
                                                    </xsl:when>
                                                </xsl:choose>
                                            </td>
                                            <!-- columnCareViewView -->
                                            <!-- FIXME? the ProjectIndex offers 2 flavors of care view. We only offer one version here... -->
                                            <td>
                                                <!-- Prevent link here so it saves the user pointless clicking into an HTML without content -->
                                                <xsl:if test="representingTemplate/concept">
                                                    <xsl:if test="string-length($projectRestUriDS) &gt; 0">
                                                        <a href="{$projectRestUriDS}&amp;id={$trid}&amp;effectiveDate={encode-for-uri($tred)}&amp;format=html" onclick="target='_blank';">
                                                            <xsl:attribute name="title">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'columnCareView'"/>
                                                                </xsl:call-template>
                                                            </xsl:attribute>
                                                            <xsl:text>html</xsl:text>
                                                        </a>
                                                    </xsl:if>
                                                </xsl:if>
                                                <xsl:text> </xsl:text>
                                            </td>
                                        </tr>
                                    </xsl:for-each>
                                </xsl:for-each>
                            </tbody>
                        </table>
                    </div>
                </xsl:for-each>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabScenarios'"/>
            <xsl:with-param name="actualcontent" select="$content4"/>
        </xsl:call-template>
        <xsl:for-each select="//scenarios/scenario">
            <xsl:variable name="scid" select="ancestor-or-self::scenario/@id"/>
            <xsl:variable name="sced" select="ancestor-or-self::scenario/@effectiveDate"/>
            <xsl:call-template name="logMessage">
                <xsl:with-param name="level" select="$logDEBUG"/>
                <xsl:with-param name="msg">
                    <xsl:text>*** Creating HTML For Scenario "</xsl:text>
                    <xsl:call-template name="doName">
                        <xsl:with-param name="ns" select="name"/>
                    </xsl:call-template>
                    <xsl:text>" </xsl:text>
                    <xsl:value-of select="local:doHtmlName('SC', $scid, $sced, '.html')"/>
                </xsl:with-param>
            </xsl:call-template>
            <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('SC',$scid,$sced,'.html',true())}" format="xhtml">
                <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                        <title>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'columnScenario'"/>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <xsl:call-template name="doName">
                                <xsl:with-param name="ns" select="name"/>
                            </xsl:call-template>
                            <xsl:text> - </xsl:text>
                            <xsl:value-of select="$scid"/>
                            <xsl:text> - </xsl:text>
                            <xsl:value-of select="$sced"/>
                        </title>
                        <xsl:call-template name="addAssetsHeader">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                    </head>
                    <body>
                        <div class="indexline">
                            <a href="{local:doHtmlName('tabFrontPage',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToIndex'"/>
                                </xsl:call-template>
                            </a>
                            <xsl:text> &#160;&lt;&lt;&#160; </xsl:text>
                            <a href="{local:doHtmlName('tabScenarios', $projectPrefix, (), (), $scid, $sced, (), (), '.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToScenarios'"/>
                                </xsl:call-template>
                            </a>
                        </div>
                        <h1>
                            <xsl:call-template name="showStatusDot">
                                <xsl:with-param name="status" select="@statusCode"/>
                                <xsl:with-param name="title">
                                    <xsl:call-template name="getXFormsLabel">
                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                    </xsl:call-template>
                                </xsl:with-param>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'columnScenario'"/>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <i>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="name"/>
                                </xsl:call-template>
                            </i>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:value-of select="$scid"/>
                        </h1>
                        <div class="tabtab">
                            <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                <div>
                                    <button id="expandAll" type="button">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                        </xsl:call-template>
                                    </button>
                                    <button id="collapseAll" type="button">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                        </xsl:call-template>
                                    </button>
                                    <input id="nameSearch">
                                        <xsl:attribute name="placeholder">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'textSearch'"/>
                                            </xsl:call-template>
                                        </xsl:attribute>
                                    </input>
                                    <select id="hiddenColumns">
                                        <option value="title">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'showColumn'"/>
                                            </xsl:call-template>
                                        </option>
                                        <option value="columnDetails" disabled="disabled">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Details'"/>
                                            </xsl:call-template>
                                        </option>
                                    </select>
                                </div>
                            </xsl:if>
                            <table id="transactionTable" class="treetable" width="100%" border="0" cellspacing="0" cellpadding="5">
                                <tr>
                                    <th class="columnName">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Name'"/>
                                        </xsl:call-template>
                                    </th>
                                    <th class="columnDetails" colspan="2">
                                        <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Details'"/>
                                            </xsl:call-template>
                                            <xsl:text>&#160;</xsl:text>
                                            <span class="hideMe" type="button">[‑]</span>
                                        </xsl:if>
                                    </th>
                                </tr>
                                <xsl:call-template name="doScenarios"/>
                            </table>
                        </div>
                        <xsl:call-template name="addAssetsBottom">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                    </body>
                </html>
            </xsl:result-document>
        </xsl:for-each>
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logDEBUG"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating SVG</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <!-- Write functional and technical SVGs. Could not do this inside the variable because older versions of
            Saxon do not support switching output from within a variable -->
        <xsl:for-each select="$allSvg/transaction">
            <xsl:if test="*[1]">
                <xsl:result-document format="xml" href="{$theHtmlDir}{local:doHtmlName('TR',@id,@effectiveDate,'_functional.svg',true())}">
                    <xsl:copy-of select="*[1]" copy-namespaces="no"/>
                </xsl:result-document>
            </xsl:if>
            <xsl:if test="*[2]">
                <xsl:result-document format="xml" href="{$theHtmlDir}{local:doHtmlName('TR',@id,@effectiveDate,'_technical.svg',true())}">
                    <xsl:copy-of select="*[2]" copy-namespaces="no"/>
                </xsl:result-document>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="doDatasetsTab">
        <xsl:variable name="sc-style" select="'border-top: 6px solid white;'"/>
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Datasets Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:variable name="content3">
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <h2>
                    <a name="labelDataSets"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'tabDataSetsTitleString'"/>
                    </xsl:call-template>
                </h2>
                <xsl:choose>
                    <xsl:when test="count(//datasets/dataset) = 0">
                        <table style="border: 0;">
                            <xsl:call-template name="doMessage">
                                <xsl:with-param name="level" select="'info'"/>
                                <xsl:with-param name="msg">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'issueNoDataSetsDefinedYet'"/>
                                    </xsl:call-template>
                                </xsl:with-param>
                            </xsl:call-template>
                        </table>
                    </xsl:when>
                    <xsl:otherwise>
                        <div class="tabtab">
                            <table class="highlight" width="100%" cellspacing="0" cellpadding="5">
                                <thead>
                                    <tr>
                                        <th style="width: 50px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Diagram'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th style="width: 50px;">XML</th>
                                        <th style="width: 50px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnAllView'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th style="width: 50px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnCareView'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnName'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'effectiveDate'"/>
                                            </xsl:call-template>
                                        </th>
                                        <xsl:if test="//datasets/dataset[@expirationDate[not(. = '')]]">
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'expirationDate'"/>
                                                </xsl:call-template>
                                            </th>
                                        </xsl:if>
                                        <th>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnVersionLabel'"/>
                                            </xsl:call-template>
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <xsl:for-each-group select="//datasets/dataset" group-by="string(@ident)">
                                        <xsl:sort select="current-grouping-key()" order="ascending"/>
                                        
                                        <xsl:for-each select="current-group()">
                                            <xsl:sort select="@effectiveDate" order="descending"/>
                                            <xsl:sort select="(name[@language = $defaultLanguage], name)[1]" order="ascending"/>
                                            <tr class="dsline">
                                                <td style="{$sc-style}">
                                                    <xsl:if test="string-length($projectRestUriDSDiagram) &gt; 0">
                                                        <a href="{$projectRestUriDSDiagram}&amp;datasetId={@id}&amp;datasetEffectiveDate={encode-for-uri(@effectiveDate)}&amp;format=svg" onclick="target='_blank';">link</a>
                                                    </xsl:if>
                                                </td>
                                                <td style="{$sc-style}">
                                                    <xsl:if test="string-length($projectRestUriDS) &gt; 0">
                                                        <a href="{$projectRestUriDS}&amp;id={@id}&amp;effectiveDate={encode-for-uri(@effectiveDate)}&amp;format=xml" onclick="target='_blank';">xml</a>
                                                    </xsl:if>
                                                </td>
                                                <td style="{$sc-style}">
                                                    <a href="{local:doHtmlName('DS',@id,@effectiveDate,'.html')}" onclick="target='_blank';">html</a>
                                                </td>
                                                <td style="{$sc-style}">
                                                    <xsl:if test="string-length($projectRestUriDS) &gt; 0">
                                                        <a href="{$projectRestUriDS}&amp;id={@id}&amp;effectiveDate={encode-for-uri(@effectiveDate)}&amp;format=html" onclick="target='_blank';">html</a>
                                                    </xsl:if>
                                                </td>
                                                <td style="{$sc-style}">
                                                    <xsl:variable name="theStatus">
                                                        <xsl:choose>
                                                            <!--<xsl:when test="@ident[not(. = $projectPrefix)]">
                                                                <xsl:value-of select="'ref'"/>
                                                            </xsl:when>-->
                                                            <xsl:when test="@statusCode">
                                                                <xsl:value-of select="@statusCode"/>
                                                            </xsl:when>
                                                            <xsl:otherwise>
                                                                <!-- 
                                                                    if any item is new draft - > dataset is draft
                                                                    if any item is rejected cancelled deprecated - > dataset is final
                                                                    otherwise the dataset is final
                                                                -->
                                                                <xsl:variable name="ndcount" select="count(.//concept[@statusCode = 'new' or @statusCode = 'draft'])"/>
                                                                <xsl:choose>
                                                                    <xsl:when test="$ndcount &gt; 0">
                                                                        <xsl:text>draft</xsl:text>
                                                                    </xsl:when>
                                                                    <xsl:otherwise>
                                                                        <xsl:text>final</xsl:text>
                                                                    </xsl:otherwise>
                                                                </xsl:choose>
                                                            </xsl:otherwise>
                                                        </xsl:choose>
                                                    </xsl:variable>
                                                    <xsl:call-template name="showStatusDot">
                                                        <xsl:with-param name="status" select="$theStatus"/>
                                                        <xsl:with-param name="title">
                                                            <xsl:call-template name="getXFormsLabel">
                                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                <xsl:with-param name="simpleTypeValue" select="$theStatus"/>
                                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                            </xsl:call-template>
                                                        </xsl:with-param>
                                                    </xsl:call-template>
                                                    <xsl:text>&#160;</xsl:text>
                                                    <xsl:call-template name="doName">
                                                        <xsl:with-param name="ns" select="name"/>
                                                    </xsl:call-template>
                                                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                                </td>
                                                <td style="{$sc-style}">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="@effectiveDate"/>
                                                    </xsl:call-template>
                                                </td>
                                                <xsl:if test="ancestor::datasets/dataset[@expirationDate[not(. = '')]]">
                                                    <td style="{$sc-style}">
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="@expirationDate"/>
                                                        </xsl:call-template>
                                                    </td>
                                                </xsl:if>
                                                <td style="{$sc-style}">
                                                    <xsl:value-of select="@versionLabel"/>
                                                </td>
                                            </tr>
                                        </xsl:for-each>
                                    </xsl:for-each-group>
                                </tbody>
                            </table>
                        </div>
                    </xsl:otherwise>
                </xsl:choose>
                <h2>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'dataSetDataSetsPerTransaction'"/>
                    </xsl:call-template>
                </h2>
                <xsl:choose>
                    <xsl:when test="count(//scenarios/scenario//transaction/representingTemplate[@sourceDataset]) = 0">
                        <table style="border: 0;">
                            <xsl:call-template name="doMessage">
                                <xsl:with-param name="level" select="'info'"/>
                                <xsl:with-param name="msg">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'issueNoTransactionsWithAnUnderlyingModelDefinedYet'"/>
                                    </xsl:call-template>
                                </xsl:with-param>
                            </xsl:call-template>
                        </table>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:variable name="doExpirationDate" select="exists(//scenarios/scenario//transaction[representingTemplate/@sourceDataset][@expirationDate])"/>
                        <div class="tabtab">
                            <table class="highlight" width="100%" cellspacing="0" cellpadding="5">
                                <thead>
                                    <tr>
                                        <th style="width: 50px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Diagram'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th style="width: 50px;">XML</th>
                                        <th style="width: 50px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnAllView'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th style="width: 50px;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnCareView'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnName'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'effectiveDate'"/>
                                            </xsl:call-template>
                                        </th>
                                        <xsl:if test="$doExpirationDate">
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'expirationDate'"/>
                                                </xsl:call-template>
                                            </th>
                                        </xsl:if>
                                        <th>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnVersionLabel'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnScenario'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'columnDataset'"/>
                                            </xsl:call-template>
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <xsl:for-each select="//scenarios/scenario[.//transaction[representingTemplate/@sourceDataset]]">
                                        <xsl:sort select="@effectiveDate" order="descending"/>
                                        <xsl:variable name="scid" select="@id"/>
                                        <xsl:variable name="sced" select="@effectiveDate"/>
                                        <xsl:variable name="scenarioAnchor" select="local:doHtmlAnchor($scid, $sced)"/>
                                        <xsl:variable name="scstatus" select="@statusCode"/>
                                        <xsl:for-each select=".//transaction[representingTemplate/@sourceDataset]">
                                            <xsl:variable name="trid" select="@id"/>
                                            <!-- cache transaction/@effectiveDate. This is relatively new so might not be present -->
                                            <xsl:variable name="tred" select="@effectiveDate"/>
                                            <xsl:variable name="trsts" select="ancestor-or-self::*[1]/@statusCode"/>
                                            <xsl:variable name="dsid" select="representingTemplate/@sourceDataset"/>
                                            <xsl:variable name="dsed" select="representingTemplate/@sourceDatasetFlexibility"/>
                                            <xsl:variable name="reptc" select="representingTemplate"/>
                                            <xsl:variable name="dataset" select="if ($dsid) then local:getDataset($dsid, $dsed) else ()" as="element()?"/>
                                            <tr class="scline">
                                                <td style="{$sc-style}">
                                                    <xsl:if test="representingTemplate/concept and string-length($projectRestUriDSDiagram) &gt; 0">
                                                        <a href="{$projectRestUriDSDiagram}&amp;transactionId={@id}&amp;transactionEffectiveDate={encode-for-uri(@effectiveDate)}&amp;format=svg" onclick="target='_blank';">link</a>
                                                    </xsl:if>
                                                </td>
                                                <td style="{$sc-style}">
                                                    <!-- Prevent link here so it saves the user pointless clicking into an HTML without content -->
                                                    <xsl:if test="representingTemplate/concept">
                                                        <xsl:if test="string-length($projectRestUriDS) &gt; 0">
                                                            <a href="{$projectRestUriDS}&amp;id={@id}&amp;effectiveDate={encode-for-uri(@effectiveDate)}&amp;format=xml" onclick="target='_blank';">xml</a>
                                                        </xsl:if>
                                                    </xsl:if>
                                                </td>
                                                <!-- FIXME? the ProjectIndex has a different understanding of "All" than this link has... -->
                                                <td style="{$sc-style}">
                                                    <!-- Prevent link here so it saves the user pointless clicking into an HTML without content -->
                                                    <xsl:if test="representingTemplate/concept">
                                                        <a href="{local:doHtmlName('TR',$trid,$tred,'.html')}" onclick="target='_blank';">html</a>
                                                    </xsl:if>
                                                </td>
                                                <!-- FIXME? the ProjectIndex offers 2 flavors of care view. We only offer one version here... -->
                                                <td style="{$sc-style}">
                                                    <!-- Prevent link here so it saves the user pointless clicking into an HTML without content -->
                                                    <xsl:if test="representingTemplate/concept">
                                                        <xsl:if test="string-length($projectRestUriDS) &gt; 0">
                                                            <a href="{$projectRestUriDS}&amp;id={$trid}&amp;effectiveDate={encode-for-uri($tred)}&amp;format=html" onclick="target='_blank';">html</a>
                                                        </xsl:if>
                                                    </xsl:if>
                                                </td>
                                                <!-- Transaction -->
                                                <td style="{$sc-style}">
                                                    <xsl:call-template name="showStatusDot">
                                                        <xsl:with-param name="status" select="$trsts"/>
                                                        <xsl:with-param name="title">
                                                            <xsl:call-template name="getXFormsLabel">
                                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                <xsl:with-param name="simpleTypeValue" select="$trsts"/>
                                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                            </xsl:call-template>
                                                        </xsl:with-param>
                                                    </xsl:call-template>
                                                    <xsl:text> </xsl:text>
                                                    <xsl:call-template name="doName">
                                                        <xsl:with-param name="ns" select="name"/>
                                                    </xsl:call-template>
                                                    <!-- Add this here so it saves the user pointless clicking into an HTML with the same notice -->
                                                    <xsl:if test="not(representingTemplate/concept)">
                                                        <table style="border: 0; padding-left: 20px;">
                                                            <xsl:call-template name="doMessage">
                                                                <xsl:with-param name="level" select="'info'"/>
                                                                <xsl:with-param name="msg">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'issueNoUnderlyingModelWithThisScenarioTransactionDefinedYet'"/>
                                                                    </xsl:call-template>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                        </table>
                                                    </xsl:if>
                                                </td>
                                                <!-- effectiveDate -->
                                                <td style="{$sc-style}">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="@effectiveDate"/>
                                                    </xsl:call-template>
                                                </td>
                                                <!-- expirationDate -->
                                                <xsl:if test="$doExpirationDate">
                                                    <td style="{$sc-style}">
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="@expirationDate"/>
                                                        </xsl:call-template>
                                                    </td>
                                                </xsl:if>
                                                <!-- versionLabel -->
                                                <td style="{$sc-style}">
                                                    <xsl:value-of select="@versionLabel"/>
                                                </td>
                                                <!-- Scenario -->
                                                <td style="{$sc-style}">
                                                    <xsl:call-template name="showStatusDot">
                                                        <xsl:with-param name="status" select="$scstatus"/>
                                                        <xsl:with-param name="title">
                                                            <xsl:call-template name="getXFormsLabel">
                                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                <xsl:with-param name="simpleTypeValue" select="$scstatus"/>
                                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                            </xsl:call-template>
                                                        </xsl:with-param>
                                                    </xsl:call-template>
                                                    <xsl:text> </xsl:text>
                                                    <a href="{local:doHtmlName('tabScenarios',$projectPrefix,(),(),$scid,$sced,(),(),'.html',false())}" onclick="target='_blank';">
                                                        <xsl:call-template name="doName">
                                                            <xsl:with-param name="ns" select="ancestor::scenario[1]/name"/>
                                                        </xsl:call-template>
                                                    </a>
                                                </td>
                                                <!-- Dataset -->
                                                <td style="{$sc-style}">
                                                    <xsl:if test="$dataset">
                                                        <xsl:variable name="dsStatus">
                                                            <xsl:choose>
                                                                <!--<xsl:when test="$dataset/@ident[not(. = $projectPrefix)]">
                                                                    <xsl:value-of select="'ref'"/>
                                                                </xsl:when>-->
                                                                <xsl:when test="$dataset/@statusCode">
                                                                    <xsl:value-of select="$dataset/@statusCode"/>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <!-- 
                                                                        if any item is new draft - > dataset is draft
                                                                        if any item is rejected cancelled deprecated - > dataset is final
                                                                        otherwise the dataset is final
                                                                    -->
                                                                    <xsl:variable name="ndcount" select="count($dataset//concept[@statusCode = 'new' or @statusCode = 'draft'])"/>
                                                                    <xsl:choose>
                                                                        <xsl:when test="$ndcount &gt; 0">
                                                                            <xsl:text>draft</xsl:text>
                                                                        </xsl:when>
                                                                        <xsl:otherwise>
                                                                            <xsl:text>final</xsl:text>
                                                                        </xsl:otherwise>
                                                                    </xsl:choose>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </xsl:variable>
                                                        <xsl:call-template name="showStatusDot">
                                                            <xsl:with-param name="status" select="$dsStatus"/>
                                                            <xsl:with-param name="title">
                                                                <xsl:call-template name="getXFormsLabel">
                                                                    <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                    <xsl:with-param name="simpleTypeValue" select="$dsStatus"/>
                                                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                </xsl:call-template>
                                                            </xsl:with-param>
                                                        </xsl:call-template>
                                                        <xsl:text> </xsl:text>
                                                        <xsl:call-template name="doName">
                                                            <xsl:with-param name="ns" select="$dataset/name"/>
                                                        </xsl:call-template>
                                                        <xsl:if test="$dataset[@versionLabel]">
                                                            <xsl:text> </xsl:text>
                                                            <xsl:value-of select="$dataset/@versionLabel"/>
                                                        </xsl:if>
                                                    </xsl:if>
                                                </td>
                                            </tr>
                                        </xsl:for-each>
                                    </xsl:for-each>
                                </tbody>
                            </table>
                        </div>
                    </xsl:otherwise>
                </xsl:choose>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabDataSet'"/>
            <xsl:with-param name="actualcontent" select="$content3"/>
        </xsl:call-template>
        <!-- create all dataset html representations -->
        <xsl:for-each select="//datasets/dataset">
            <xsl:sort select="@effectiveDate" order="descending"/>
            <xsl:variable name="dsid" select="@id"/>
            <xsl:variable name="dsed" select="@effectiveDate"/>
            <xsl:variable name="isNewest" select="$dsed = max($allDatasets/dataset[(@id | @ref) = $dsid]/xs:dateTime(@effectiveDate))"/>
            <xsl:call-template name="logMessage">
                <xsl:with-param name="level" select="$logDEBUG"/>
                <xsl:with-param name="msg">
                    <xsl:text>*** HTML for dataset: name='</xsl:text>
                    <xsl:value-of select="name[1]"/>
                    <xsl:text>' id='</xsl:text>
                    <xsl:value-of select="$dsid"/>
                    <xsl:text>' effectiveDate='</xsl:text>
                    <xsl:value-of select="$dsed"/>
                    <xsl:text>'</xsl:text>
                </xsl:with-param>
            </xsl:call-template>
            <!-- Write the static variant for include/contains with static flexibility -->
            <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('DS',$dsid,$dsed,'.html',true())}" format="xhtml">
                <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                        <title>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Dataset'"/>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <xsl:call-template name="doName">
                                <xsl:with-param name="ns" select="name"/>
                                <!--<xsl:with-param name="lang" select="$defaultLanguage"/>-->
                            </xsl:call-template>
                            <xsl:text> - </xsl:text>
                            <xsl:value-of select="$dsid"/>
                            <xsl:text> - </xsl:text>
                            <xsl:value-of select="$dsed"/>
                        </title>
                        <xsl:call-template name="addAssetsHeader">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                    </head>
                    <body>
                        <div class="indexline">
                            <a href="{local:doHtmlName('tabFrontPage',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToIndex'"/>
                                </xsl:call-template>
                            </a>
                            <xsl:text> &#160;&lt;&lt;&#160; </xsl:text>
                            <a href="{local:doHtmlName('tabDataSet',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToDatasets'"/>
                                </xsl:call-template>
                            </a>
                        </div>
                        <h1>
                            <xsl:variable name="dsStatus">
                                <xsl:choose>
                                    <!--<xsl:when test="@ident[not(. = $projectPrefix)]">
                                        <xsl:value-of select="'ref'"/>
                                    </xsl:when>-->
                                    <xsl:when test="@statusCode">
                                        <xsl:value-of select="@statusCode"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <!-- 
                                            if any item is new draft - > dataset is draft
                                            if any item is rejected cancelled deprecated - > dataset is final
                                            otherwise the dataset is final
                                        -->
                                        <xsl:variable name="ndcount" select="count(.//concept[@statusCode = 'new' or @statusCode = 'draft'])"/>
                                        <xsl:choose>
                                            <xsl:when test="$ndcount &gt; 0">
                                                <xsl:text>draft</xsl:text>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:text>final</xsl:text>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:variable>
                            <xsl:call-template name="showStatusDot">
                                <xsl:with-param name="status" select="$dsStatus"/>
                                <xsl:with-param name="title">
                                    <xsl:call-template name="getXFormsLabel">
                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                        <xsl:with-param name="simpleTypeValue" select="$dsStatus"/>
                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                    </xsl:call-template>
                                </xsl:with-param>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Dataset'"/>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <i>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="name"/>
                                    <!--<xsl:with-param name="lang" select="$defaultLanguage"/>-->
                                </xsl:call-template>
                            </i>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:value-of select="$dsid"/>
                        </h1>
                        <table border="0" cellspacing="2" cellpadding="2" width="100%">
                            <tr style="vertical-align: top;">
                                <td class="tabtab">
                                    <xsl:call-template name="doDataset">
                                        <xsl:with-param name="nestingWithTables" select="true()"/>
                                        <xsl:with-param name="dsid" select="$dsid"/>
                                        <xsl:with-param name="dsed" select="$dsed"/>
                                    </xsl:call-template>
                                </td>
                            </tr>
                        </table>
                        <xsl:call-template name="addAssetsBottom">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                    </body>
                </html>
            </xsl:result-document>
            <xsl:if test="$isNewest = true()">
                <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('DS',$dsid,'dynamic','.html',true())}" format="xhtml">
                    <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                            <meta http-equiv="refresh" content="0; URL={local:doHtmlName('DS',$dsid,$dsed,'.html',true())}"/>
                            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                            <meta name="robots" content="noindex, nofollow"/>
                            <meta http-equiv="expires" content="0"/>
                            <!-- xhtml requirement -->
                            <title>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Dataset'"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="name"/>
                                </xsl:call-template>
                            </title>
                        </head>
                        <!-- xhtml requirement -->
                        <body/>
                    </html>
                </xsl:result-document>
            </xsl:if>
        </xsl:for-each>
        <!-- create all scenario html representations from a dataset view -->
        <xsl:for-each select="//scenarios/scenario[.//transaction[representingTemplate]]">
            <xsl:sort select="@effectiveDate" order="descending"/>
            <xsl:variable name="scstatus" select="@statusCode"/>
            <xsl:for-each select=".//transaction[representingTemplate]">
                <xsl:variable name="scid" select="ancestor::scenario/@id"/>
                <xsl:variable name="sced" select="ancestor::scenario/@effectiveDate"/>
                <xsl:variable name="trid" select="@id"/>
                <!-- cache transaction/@effectiveDate. This is relatively new so might not be present -->
                <xsl:variable name="tred" select="@effectiveDate"/>
                <xsl:variable name="dsid" select="representingTemplate/@sourceDataset"/>
                <xsl:variable name="dsed" select="representingTemplate/@sourceDatasetFlexibility"/>
                <xsl:variable name="reptc" select="representingTemplate"/>
                <xsl:variable name="dataset" select="if ($dsid) then local:getDataset($dsid, $dsed) else ()" as="element()?"/>
                <xsl:variable name="dsname" select="$dataset/name"/>
                <!-- create the dataset filtered with concept mentioned in the representingTemplate only -->
                <xsl:variable name="filtereddataset" as="element()">
                    <xsl:variable name="tmp1" as="element()">
                        <tmp xmlns="">
                            <xsl:apply-templates select="$dataset/concept" mode="filter">
                                <xsl:with-param name="representingTemplate" select="$reptc"/>
                            </xsl:apply-templates>
                        </tmp>
                    </xsl:variable>
                    <filtereddataset xmlns="">
                        <xsl:copy-of select="@*"/>
                        <xsl:copy-of select="* except concept"/>
                        <xsl:apply-templates select="$tmp1/concept" mode="eliminatedHiddenConcepts"/>
                    </filtereddataset>
                </xsl:variable>
                <xsl:call-template name="logMessage">
                    <xsl:with-param name="level" select="$logDEBUG"/>
                    <xsl:with-param name="msg">
                        <xsl:text>*** HTML for dataset based on transaction: name='</xsl:text>
                        <xsl:value-of select="name[1]"/>
                        <xsl:text>' id='</xsl:text>
                        <xsl:value-of select="$trid"/>
                        <xsl:text>' effectiveDate='</xsl:text>
                        <xsl:value-of select="$tred"/>
                        <xsl:text>' dataset name='</xsl:text>
                        <xsl:value-of select="$dsname"/>
                        <xsl:if test="$dataset[@versionLabel]">
                            <xsl:text>' versionLabel='</xsl:text>
                            <xsl:value-of select="$dataset/@versionLabel"/>
                        </xsl:if>
                        <xsl:text>' id='</xsl:text>
                        <xsl:value-of select="$dsid"/>
                        <xsl:text>'</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>
                <xsl:variable name="transactionAnchor" select="local:doHtmlAnchor($trid, $tred)"/>
                <!-- Write the static variant for include/contains with static flexibility -->
                <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('TR',$trid,$tred,'.html',true())}" format="xhtml">
                    <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                            <title>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'dataSetDataSetForTransaction'"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="@id"/>
                                <xsl:text> - </xsl:text>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="name"/>
                                    <!--<xsl:with-param name="lang" select="$defaultLanguage"/>-->
                                </xsl:call-template>
                            </title>
                            <xsl:call-template name="addAssetsHeader">
                                <xsl:with-param name="doTreeTable" select="true()"/>
                            </xsl:call-template>
                        </head>
                        <body>
                            <div class="indexline">
                                <a href="{local:doHtmlName('tabFrontPage',(),(),'.html', true())}">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'backToIndex'"/>
                                    </xsl:call-template>
                                </a>
                                <xsl:text> &#160;&lt;&lt;&#160; </xsl:text>
                                <a href="{local:doHtmlName('tabScenarios', $projectPrefix, (), (), $trid, $tred, (), (), '.html', true())}">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'backToScenarios'"/>
                                    </xsl:call-template>
                                </a>
                                <xsl:text> &#160;&lt;&lt;&#160; </xsl:text>
                                <a href="{local:doHtmlName('SC', $projectPrefix, $scid, $sced, $trid, $tred, (), (), '.html', false())}" onclick="target='_blank';">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'backToScenarioTransaction'"/>
                                    </xsl:call-template>
                                </a>
                            </div>
                            <h1>
                                <xsl:call-template name="showStatusDot">
                                    <xsl:with-param name="status" select="@statusCode"/>
                                    <xsl:with-param name="title">
                                        <xsl:call-template name="getXFormsLabel">
                                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                        </xsl:call-template>
                                    </xsl:with-param>
                                </xsl:call-template>
                                <xsl:text>&#160;</xsl:text>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Transaction'"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <i>
                                    <xsl:call-template name="doName">
                                        <xsl:with-param name="ns" select="name"/>
                                        <!--<xsl:with-param name="lang" select="$defaultLanguage"/>-->
                                    </xsl:call-template>
                                </i>
                                <xsl:text>&#160;</xsl:text>
                                <xsl:value-of select="$trid"/>
                            </h1>
                            <h2>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Dataset'"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <i>
                                    <xsl:call-template name="doName">
                                        <xsl:with-param name="ns" select="$dsname"/>
                                        <!--<xsl:with-param name="lang" select="$defaultLanguage"/>-->
                                    </xsl:call-template>
                                </i>
                                <xsl:text>&#160;</xsl:text>
                                <xsl:value-of select="$dsid"/>
                            </h2>
                            <table border="0" cellspacing="2" cellpadding="2" width="100%">
                                <tr style="vertical-align: top;">
                                    <td class="tabtab">
                                        <xsl:for-each select="$filtereddataset">
                                            <xsl:call-template name="doDataset">
                                                <xsl:with-param name="nestingWithTables" select="true()"/>
                                                <xsl:with-param name="trid" select="$trid"/>
                                                <xsl:with-param name="tred" select="$tred"/>
                                            </xsl:call-template>
                                        </xsl:for-each>
                                    </td>
                                </tr>
                            </table>
                            <xsl:call-template name="addAssetsBottom">
                                <xsl:with-param name="doTreeTable" select="true()"/>
                            </xsl:call-template>
                        </body>
                    </html>
                </xsl:result-document>
            </xsl:for-each>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="doIdentificationTab">
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Identifiers Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:variable name="content4b">
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <xsl:call-template name="doIdentifiers"/>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabIdentifiers'"/>
            <xsl:with-param name="actualcontent" select="$content4b"/>
        </xsl:call-template>
    </xsl:template>
    <xsl:template name="doTerminologyTab">
        <xsl:variable name="sc-style" select="'border-top: 6px solid white;'"/>
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Terminology Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:variable name="content5">
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <h2>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'tabTerminologyTitleString'"/>
                    </xsl:call-template>
                </h2>
                <div id="Accordionvs" class="Accordion">
                    <xsl:choose>
                        <xsl:when test="(count($allValueSets/*/valueSet[@id]) + count($allCodeSystems/*/codeSystem[@id]) + count($allConceptMaps/*/conceptMap[@id])) = 0">
                            <table style="border: 0;">
                                <xsl:call-template name="doMessage">
                                    <xsl:with-param name="level" select="'info'"/>
                                    <xsl:with-param name="msg">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueNoCodesValueSetsDefinedYet'"/>
                                        </xsl:call-template>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </table>
                        </xsl:when>
                        <xsl:otherwise>
                            <h3>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'valueSets'"/>
                                </xsl:call-template>
                            </h3>
                            <xsl:variable name="doExpirationDateVS" select="$allValueSets/*/valueSet[@id][@expirationDate[not(. = '')]]"/>
                            <div class="tabtab">
                                <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                    <div>
                                        <button id="expandAll" type="button">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                            </xsl:call-template>
                                        </button>
                                        <button id="collapseAll" type="button">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                            </xsl:call-template>
                                        </button>
                                        <input id="nameSearch">
                                            <xsl:attribute name="placeholder">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'textSearch'"/>
                                                </xsl:call-template>
                                            </xsl:attribute>
                                        </input>
                                    </div>
                                </xsl:if>
                                <table id="valuesetTable" class="treetable highlight" width="100%" border="0" cellspacing="0" cellpadding="5">
                                    <thead>
                                        <tr>
                                            <th class="columnAllView" style="width: 50px;">HTML</th>
                                            <th class="columnName">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'columnName'"/>
                                                </xsl:call-template>
                                            </th>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'effectiveDate'"/>
                                                </xsl:call-template>
                                            </th>
                                            <xsl:if test="$doExpirationDateVS">
                                                <th>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'expirationDate'"/>
                                                    </xsl:call-template>
                                                </th>
                                            </xsl:if>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'columnVersionLabel'"/>
                                                </xsl:call-template>
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <!-- only first value set of most recent version -->
                                        <xsl:for-each-group select="$allValueSets/*/valueSet[@id]" group-by="@id">
                                            <xsl:sort select="lower-case(normalize-space((current-group()[1]/@displayName, current-group()[1]/@name)[1]))"/>
                                            <xsl:variable name="groupCount" select="count(current-group())"/>
                                            <xsl:for-each select="current-group()">
                                                <xsl:sort select="@effectiveDate" order="descending"/>
                                                <xsl:variable name="vsid" select="@id"/>
                                                <xsl:variable name="vsed" select="@effectiveDate"/>
                                                <xsl:variable name="pos" select="position()"/>
                                                <xsl:variable name="valuesetAnchor">
                                                    <xsl:text>#</xsl:text>
                                                    <xsl:value-of select="local:doHtmlAnchor($vsid, $vsed)"/>
                                                </xsl:variable>
                                                <xsl:variable name="node-id" select="generate-id(.)"/>
                                                <!-- if we have multiple versions of a template, group them under their name/id -->
                                                <xsl:if test="$pos = 1 and $groupCount gt 1">
                                                    <tr data-tt-id="{$node-id}-group" class="vsline">
                                                        <td style="{$sc-style}" class="columnAllView">
                                                            <xsl:text>&#160;</xsl:text>
                                                        </td>
                                                        <td style="{$sc-style}" class="columnName">
                                                            <xsl:call-template name="showStatusDot">
                                                                <xsl:with-param name="status" select="'ref'"/>
                                                                <xsl:with-param name="title">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'Group'"/>
                                                                    </xsl:call-template>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                            <xsl:text>&#160;</xsl:text>
                                                            <xsl:value-of select="current-group()[1]/(@displayName, @name)[1]"/>
                                                            <xsl:text>&#160;</xsl:text>
                                                            <xsl:value-of select="$vsid"/>
                                                        </td>
                                                        <td style="{$sc-style}">
                                                            <i>
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'Multiple'"/>
                                                                </xsl:call-template>
                                                                <xsl:text> (</xsl:text>
                                                                <xsl:value-of select="$groupCount"/>
                                                                <xsl:text>)</xsl:text>
                                                            </i>
                                                        </td>
                                                        <xsl:if test="$doExpirationDateVS">
                                                            <td style="{$sc-style}">
                                                                <xsl:text>&#160;</xsl:text>
                                                            </td>
                                                        </xsl:if>
                                                        <td style="{$sc-style}">
                                                            <xsl:text>&#160;</xsl:text>
                                                        </td>
                                                    </tr>
                                                    <xsl:if test="current-group()[1]/desc[.//text()[string-length(normalize-space()) gt 0]]">
                                                        <tr data-tt-id="{$node-id}-desc" data-tt-parent-id="{$node-id}-group">
                                                            <td class="columnAllView"/>
                                                            <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDateVS) then 4 else 3}">
                                                                <xsl:value-of>
                                                                    <xsl:call-template name="doDescription">
                                                                        <xsl:with-param name="ns" select="current-group()[1]/desc"/>
                                                                        <xsl:with-param name="shortDesc" select="true()"/>
                                                                    </xsl:call-template>
                                                                </xsl:value-of>
                                                            </td>
                                                        </tr>
                                                    </xsl:if>
                                                </xsl:if>
                                                <tr data-tt-id="{$node-id}" class="vsline">
                                                    <xsl:if test="$groupCount gt 1">
                                                        <xsl:attribute name="data-tt-parent-id" select="concat(generate-id(current-group()[1]), '-group')"/>
                                                    </xsl:if>
                                                    <td style="{$sc-style}" class="columnAllView">
                                                        <a href="{local:doHtmlName('VS',@id,@effectiveDate,'.html')}" onclick="target='_blank';">html</a>
                                                    </td>
                                                    <td style="{$sc-style}" class="columnName">
                                                        <xsl:call-template name="showStatusDot">
                                                            <xsl:with-param name="status" select="@statusCode"/>
                                                            <xsl:with-param name="title">
                                                                <xsl:call-template name="getXFormsLabel">
                                                                    <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                    <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                </xsl:call-template>
                                                            </xsl:with-param>
                                                        </xsl:call-template>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <xsl:value-of select="(@displayName, @name)[1]"/>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <xsl:value-of select="$vsid"/>
                                                        <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                                    </td>
                                                    <td style="{$sc-style}">
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="$vsed"/>
                                                        </xsl:call-template>
                                                    </td>
                                                    <xsl:if test="$doExpirationDateVS">
                                                        <td style="{$sc-style}">
                                                            <xsl:call-template name="showDate">
                                                                <xsl:with-param name="date" select="@expirationDate"/>
                                                            </xsl:call-template>
                                                        </td>
                                                    </xsl:if>
                                                    <td style="{$sc-style}">
                                                        <xsl:value-of select="@versionLabel"/>
                                                    </td>
                                                </tr>
                                                <xsl:if test="$groupCount = 1 and $pos = 1 and desc[.//text()[string-length(normalize-space()) gt 0]]">
                                                    <tr data-tt-id="{$node-id}-desc" data-tt-parent-id="{$node-id}">
                                                        <td class="columnAllView"/>
                                                        <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDateVS) then 4 else 3}">
                                                            <xsl:value-of>
                                                                <xsl:call-template name="doDescription">
                                                                    <xsl:with-param name="ns" select="desc"/>
                                                                    <xsl:with-param name="shortDesc" select="true()"/>
                                                                </xsl:call-template>
                                                            </xsl:value-of>
                                                        </td>
                                                    </tr>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </xsl:for-each-group>
                                    </tbody>
                                </table>
                            </div>
                            <h3>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'CodeSystems'"/>
                                </xsl:call-template>
                            </h3>
                            <xsl:variable name="doExpirationDateCS" select="$allCodeSystems/*/codeSystem[@id][@expirationDate[not(. = '')]]"/>
                            <div class="tabtab">
                                <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                    <div>
                                        <button id="expandAll" type="button">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                            </xsl:call-template>
                                        </button>
                                        <button id="collapseAll" type="button">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                            </xsl:call-template>
                                        </button>
                                        <input id="nameSearch">
                                            <xsl:attribute name="placeholder">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'textSearch'"/>
                                                </xsl:call-template>
                                            </xsl:attribute>
                                        </input>
                                    </div>
                                </xsl:if>
                                <table id="codesystemTable" class="treetable highlight" width="100%" border="0" cellspacing="0" cellpadding="5">
                                    <thead>
                                        <tr>
                                            <th class="columnAllView" style="width: 50px;">HTML</th>
                                            <th class="columnName">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'columnName'"/>
                                                </xsl:call-template>
                                            </th>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'effectiveDate'"/>
                                                </xsl:call-template>
                                            </th>
                                            <xsl:if test="$doExpirationDateCS">
                                                <th>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'expirationDate'"/>
                                                    </xsl:call-template>
                                                </th>
                                            </xsl:if>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'columnVersionLabel'"/>
                                                </xsl:call-template>
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <!-- only first value set of most recent version -->
                                        <xsl:for-each-group select="$allCodeSystems/*/codeSystem[@id]" group-by="@id">
                                            <xsl:sort select="lower-case(normalize-space((current-group()[1]/@displayName, current-group()[1]/@name)[1]))"/>
                                            <xsl:variable name="groupCount" select="count(current-group())"/>
                                            <xsl:for-each select="current-group()">
                                                <xsl:sort select="@effectiveDate" order="descending"/>
                                                <xsl:variable name="csid" select="@id"/>
                                                <xsl:variable name="csed" select="@effectiveDate"/>
                                                <xsl:variable name="pos" select="position()"/>
                                                <xsl:variable name="codesystemAnchor">
                                                    <xsl:text>#</xsl:text>
                                                    <xsl:value-of select="local:doHtmlAnchor($csid, $csed)"/>
                                                </xsl:variable>
                                                <xsl:variable name="node-id" select="generate-id(.)"/>
                                                <!-- if we have multiple versions of a template, group them under their name/id -->
                                                <xsl:if test="$pos = 1 and $groupCount gt 1">
                                                    <tr data-tt-id="{$node-id}-group" class="vsline">
                                                        <td style="{$sc-style}" class="columnAllView">
                                                            <xsl:text>&#160;</xsl:text>
                                                        </td>
                                                        <td style="{$sc-style}" class="columnName">
                                                            <xsl:call-template name="showStatusDot">
                                                                <xsl:with-param name="status" select="'ref'"/>
                                                                <xsl:with-param name="title">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'Group'"/>
                                                                    </xsl:call-template>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                            <xsl:text>&#160;</xsl:text>
                                                            <xsl:value-of select="current-group()[1]/(@displayName, @name)[1]"/>
                                                            <xsl:text>&#160;</xsl:text>
                                                            <xsl:value-of select="$csid"/>
                                                        </td>
                                                        <td style="{$sc-style}">
                                                            <i>
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'Multiple'"/>
                                                                </xsl:call-template>
                                                                <xsl:text> (</xsl:text>
                                                                <xsl:value-of select="$groupCount"/>
                                                                <xsl:text>)</xsl:text>
                                                            </i>
                                                        </td>
                                                        <xsl:if test="$doExpirationDateCS">
                                                            <td style="{$sc-style}">
                                                                <xsl:text>&#160;</xsl:text>
                                                            </td>
                                                        </xsl:if>
                                                        <td style="{$sc-style}">
                                                            <xsl:text>&#160;</xsl:text>
                                                        </td>
                                                    </tr>
                                                    <xsl:if test="current-group()[1]/desc[.//text()[string-length(normalize-space()) gt 0]]">
                                                        <tr data-tt-id="{$node-id}-desc" data-tt-parent-id="{$node-id}-group">
                                                            <td class="columnAllView"/>
                                                            <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDateCS) then 4 else 3}">
                                                                <xsl:value-of>
                                                                    <xsl:call-template name="doDescription">
                                                                        <xsl:with-param name="ns" select="current-group()[1]/desc"/>
                                                                        <xsl:with-param name="shortDesc" select="true()"/>
                                                                    </xsl:call-template>
                                                                </xsl:value-of>
                                                            </td>
                                                        </tr>
                                                    </xsl:if>
                                                </xsl:if>
                                                <tr data-tt-id="{$node-id}" class="vsline">
                                                    <xsl:if test="$groupCount gt 1">
                                                        <xsl:attribute name="data-tt-parent-id" select="concat(generate-id(current-group()[1]), '-group')"/>
                                                    </xsl:if>
                                                    <td style="{$sc-style}" class="columnAllView">
                                                        <a href="{local:doHtmlName('CS',@id,@effectiveDate,'.html')}" onclick="target='_blank';">html</a>
                                                    </td>
                                                    <td style="{$sc-style}" class="columnName">
                                                        <xsl:call-template name="showStatusDot">
                                                            <xsl:with-param name="status" select="@statusCode"/>
                                                            <xsl:with-param name="title">
                                                                <xsl:call-template name="getXFormsLabel">
                                                                    <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                    <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                </xsl:call-template>
                                                            </xsl:with-param>
                                                        </xsl:call-template>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <xsl:value-of select="(@displayName, @name)[1]"/>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <xsl:value-of select="$csid"/>
                                                        <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                                    </td>
                                                    <td style="{$sc-style}">
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="$csed"/>
                                                        </xsl:call-template>
                                                    </td>
                                                    <xsl:if test="$doExpirationDateCS">
                                                        <td style="{$sc-style}">
                                                            <xsl:call-template name="showDate">
                                                                <xsl:with-param name="date" select="@expirationDate"/>
                                                            </xsl:call-template>
                                                        </td>
                                                    </xsl:if>
                                                    <td style="{$sc-style}">
                                                        <xsl:value-of select="@versionLabel"/>
                                                    </td>
                                                </tr>
                                                <xsl:if test="$groupCount = 1 and $pos = 1 and desc[.//text()[string-length(normalize-space()) gt 0]]">
                                                    <tr data-tt-id="{$node-id}-desc" data-tt-parent-id="{$node-id}">
                                                        <td class="columnAllView"/>
                                                        <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDateCS) then 4 else 3}">
                                                            <xsl:value-of>
                                                                <xsl:call-template name="doDescription">
                                                                    <xsl:with-param name="ns" select="desc"/>
                                                                    <xsl:with-param name="shortDesc" select="true()"/>
                                                                </xsl:call-template>
                                                            </xsl:value-of>
                                                        </td>
                                                    </tr>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </xsl:for-each-group>
                                    </tbody>
                                </table>
                            </div>
                            <h3>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'ConceptMaps'"/>
                                </xsl:call-template>
                            </h3>
                            <xsl:variable name="doExpirationDateMP" select="$allConceptMaps[@id][@expirationDate[not(. = '')]]"/>
                            <div class="tabtab">
                                <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                    <div>
                                        <button id="expandAll" type="button">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                            </xsl:call-template>
                                        </button>
                                        <button id="collapseAll" type="button">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                            </xsl:call-template>
                                        </button>
                                        <input id="nameSearch">
                                            <xsl:attribute name="placeholder">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'textSearch'"/>
                                                </xsl:call-template>
                                            </xsl:attribute>
                                        </input>
                                    </div>
                                </xsl:if>
                                <table id="conceptmapTable" class="treetable highlight" width="100%" border="0" cellspacing="0" cellpadding="5">
                                    <thead>
                                        <tr>
                                            <th class="columnAllView" style="width: 50px;">HTML</th>
                                            <th class="columnName">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'columnName'"/>
                                                </xsl:call-template>
                                            </th>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'effectiveDate'"/>
                                                </xsl:call-template>
                                            </th>
                                            <xsl:if test="$doExpirationDateMP">
                                                <th>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'expirationDate'"/>
                                                    </xsl:call-template>
                                                </th>
                                            </xsl:if>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'columnVersionLabel'"/>
                                                </xsl:call-template>
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <!-- only first value set of most recent version -->
                                        <xsl:for-each-group select="$allConceptMaps[@id]" group-by="@id">
                                            <xsl:sort select="lower-case(normalize-space((current-group()[1]/@displayName, current-group()[1]/@name)[1]))"/>
                                            <xsl:variable name="groupCount" select="count(current-group())"/>
                                            <xsl:for-each select="current-group()">
                                                <xsl:sort select="@effectiveDate" order="descending"/>
                                                <xsl:variable name="mpid" select="@id"/>
                                                <xsl:variable name="mped" select="@effectiveDate"/>
                                                <xsl:variable name="pos" select="position()"/>
                                                <xsl:variable name="conceptmapAnchor">
                                                    <xsl:text>#</xsl:text>
                                                    <xsl:value-of select="local:doHtmlAnchor($mpid, $mped)"/>
                                                </xsl:variable>
                                                <xsl:variable name="node-id" select="generate-id(.)"/>
                                                <!-- if we have multiple versions of a template, group them under their name/id -->
                                                <xsl:if test="$pos = 1 and $groupCount gt 1">
                                                    <tr data-tt-id="{$node-id}-group" class="vsline">
                                                        <td style="{$sc-style}" class="columnAllView">
                                                            <xsl:text>&#160;</xsl:text>
                                                        </td>
                                                        <td style="{$sc-style}" class="columnName">
                                                            <xsl:call-template name="showStatusDot">
                                                                <xsl:with-param name="status" select="'ref'"/>
                                                                <xsl:with-param name="title">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'Group'"/>
                                                                    </xsl:call-template>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                            <xsl:text>&#160;</xsl:text>
                                                            <xsl:value-of select="current-group()[1]/(@displayName, @name)[1]"/>
                                                            <xsl:text>&#160;</xsl:text>
                                                            <xsl:value-of select="$mpid"/>
                                                        </td>
                                                        <td style="{$sc-style}">
                                                            <i>
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'Multiple'"/>
                                                                </xsl:call-template>
                                                                <xsl:text> (</xsl:text>
                                                                <xsl:value-of select="$groupCount"/>
                                                                <xsl:text>)</xsl:text>
                                                            </i>
                                                        </td>
                                                        <xsl:if test="$doExpirationDateMP">
                                                            <td style="{$sc-style}">
                                                                <xsl:text>&#160;</xsl:text>
                                                            </td>
                                                        </xsl:if>
                                                        <td style="{$sc-style}">
                                                            <xsl:text>&#160;</xsl:text>
                                                        </td>
                                                    </tr>
                                                    <xsl:if test="current-group()[1]/desc[.//text()[string-length(normalize-space()) gt 0]]">
                                                        <tr data-tt-id="{$node-id}-desc" data-tt-parent-id="{$node-id}-group">
                                                            <td class="columnAllView"/>
                                                            <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDateCS) then 4 else 3}">
                                                                <xsl:value-of>
                                                                    <xsl:call-template name="doDescription">
                                                                        <xsl:with-param name="ns" select="current-group()[1]/desc"/>
                                                                        <xsl:with-param name="shortDesc" select="true()"/>
                                                                    </xsl:call-template>
                                                                </xsl:value-of>
                                                            </td>
                                                        </tr>
                                                    </xsl:if>
                                                </xsl:if>
                                                <tr data-tt-id="{$node-id}" class="vsline">
                                                    <xsl:if test="$groupCount gt 1">
                                                        <xsl:attribute name="data-tt-parent-id" select="concat(generate-id(current-group()[1]), '-group')"/>
                                                    </xsl:if>
                                                    <td style="{$sc-style}" class="columnAllView">
                                                        <a href="{local:doHtmlName('MP',@id,@effectiveDate,'.html')}" onclick="target='_blank';">html</a>
                                                    </td>
                                                    <td style="{$sc-style}" class="columnName">
                                                        <xsl:call-template name="showStatusDot">
                                                            <xsl:with-param name="status" select="@statusCode"/>
                                                            <xsl:with-param name="title">
                                                                <xsl:call-template name="getXFormsLabel">
                                                                    <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                    <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                </xsl:call-template>
                                                            </xsl:with-param>
                                                        </xsl:call-template>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <xsl:value-of select="(@displayName, @name)[1]"/>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <xsl:value-of select="$mpid"/>
                                                        <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                                    </td>
                                                    <td style="{$sc-style}">
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="$mped"/>
                                                        </xsl:call-template>
                                                    </td>
                                                    <xsl:if test="$doExpirationDateMP">
                                                        <td style="{$sc-style}">
                                                            <xsl:call-template name="showDate">
                                                                <xsl:with-param name="date" select="@expirationDate"/>
                                                            </xsl:call-template>
                                                        </td>
                                                    </xsl:if>
                                                    <td style="{$sc-style}">
                                                        <xsl:value-of select="@versionLabel"/>
                                                    </td>
                                                </tr>
                                                <xsl:if test="$groupCount = 1 and $pos = 1 and desc[.//text()[string-length(normalize-space()) gt 0]]">
                                                    <tr data-tt-id="{$node-id}-desc" data-tt-parent-id="{$node-id}">
                                                        <td class="columnAllView"/>
                                                        <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDateMP) then 4 else 3}">
                                                            <xsl:value-of>
                                                                <xsl:call-template name="doDescription">
                                                                    <xsl:with-param name="ns" select="desc"/>
                                                                    <xsl:with-param name="shortDesc" select="true()"/>
                                                                </xsl:call-template>
                                                            </xsl:value-of>
                                                        </td>
                                                    </tr>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </xsl:for-each-group>
                                    </tbody>
                                </table>
                            </div>
                        </xsl:otherwise>
                    </xsl:choose>
                </div>
                <!-- 
                    then show a summary of scenario table
                -->
                <h2>
                    <a name="labelTerminology"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'terminologySummary'"/>
                    </xsl:call-template>
                </h2>
                <xsl:text>

</xsl:text>
                <table width="50%" border="0" cellspacing="2" cellpadding="2">
                    <tr style="vertical-align: top;">
                        <td class="tabtab">
                            <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                <tr style="background-color: #CCFFCC;">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'valueSets'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td colspan="2">
                                        <xsl:value-of select="count($allValueSets/*/valueSet[@id])"/>
                                    </td>
                                </tr>
                                <tr style="background-color: #CCFFCC;">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'CodeSystems'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td colspan="2">
                                        <xsl:value-of select="count($allCodeSystems/*/codeSystem[@id])"/>
                                    </td>
                                </tr>
                                <tr style="background-color: #CCFFCC;">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'ConceptMaps'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td colspan="2">
                                        <xsl:value-of select="count($allConceptMaps[@id])"/>
                                    </td>
                                </tr>
                                <tr style="background-color: #CCFFCC;">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'terminologyAssociations'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td colspan="2">
                                        <xsl:value-of select="count($allTerminologyAssociations/*/terminologyAssociation)"/>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabTerminology'"/>
            <xsl:with-param name="actualcontent" select="$content5"/>
        </xsl:call-template>
        <!-- create all value set html representations -->
        <xsl:for-each-group select="$allValueSets/*/valueSet" group-by="concat((@id | @ref), '#', @effectiveDate)">
            <xsl:variable name="vsid" select="(@id | @ref)"/>
            <xsl:variable name="vsnm" select="@name"/>
            <xsl:variable name="vsed" select="@effectiveDate"/>
            <xsl:variable name="vsIsNewest" select="$vsed = max($allValueSets/*/valueSet[(@id | @ref) = $vsid]/xs:dateTime(@effectiveDate))"/>
            <xsl:call-template name="logMessage">
                <xsl:with-param name="level" select="$logDEBUG"/>
                <xsl:with-param name="msg">
                    <xsl:text>*** HTML for value set: name='</xsl:text>
                    <xsl:value-of select="$vsnm"/>
                    <xsl:text>' id='</xsl:text>
                    <xsl:value-of select="$vsid"/>
                    <xsl:text>' effectiveDate='</xsl:text>
                    <xsl:value-of select="$vsed"/>
                    <xsl:text>'</xsl:text>
                </xsl:with-param>
            </xsl:call-template>
            <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('VS',$vsid,$vsed,'.html',true())}" format="xhtml">
                <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                        <title>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'terminologyValueSetHeader'"/>
                                <xsl:with-param name="p1" select="$vsnm"/>
                            </xsl:call-template>
                        </title>
                        <!--<link href="{$theAssetsDir}decor.css" rel="stylesheet" type="text/css"/>
                            <link href="{$theAssetsDir}favicon.ico" rel="shortcut icon" type="image/x-icon"/>-->
                        <xsl:call-template name="addAssetsHeader">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                    </head>
                    <body>
                        <div class="indexline">
                            <a href="{local:doHtmlName('tabFrontPage',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToIndex'"/>
                                </xsl:call-template>
                            </a>
                            <xsl:text> &#160;&lt;&lt;&#160; </xsl:text>
                            <a href="{local:doHtmlName('tabTerminology',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToTerminology'"/>
                                </xsl:call-template>
                            </a>
                        </div>
                        <h1>
                            <xsl:call-template name="showStatusDot">
                                <xsl:with-param name="status" select="@statusCode"/>
                                <xsl:with-param name="title">
                                    <xsl:call-template name="getXFormsLabel">
                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                    </xsl:call-template>
                                </xsl:with-param>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'valueSet'"/>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <i>
                                <xsl:value-of select="
                                        if (@displayName) then
                                            @displayName
                                        else
                                            @name"/>
                            </i>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="showDate">
                                <xsl:with-param name="date" select="@effectiveDate"/>
                            </xsl:call-template>
                        </h1>
                        <!--<table style="border: 0;">
                                <tr>
                                    <td class="comment">
                                        <xsl:call-template name="doDescription">
                                            <xsl:with-param name="ns" select="desc"/>
                                            <xsl:with-param name="shortDesc" select="true()"/>
                                        </xsl:call-template>
                                    </td>
                                </tr>
                            </table>-->
                        <table width="100%" border="0">
                            <tr>
                                <td class="tabtab">
                                    <xsl:apply-templates select="."/>
                                </td>
                            </tr>
                        </table>
                    </body>
                </html>
            </xsl:result-document>
            <xsl:if test="$vsIsNewest = true()">
                <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('VS',$vsid,'dynamic','.html',true())}" format="xhtml">
                    <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                            <meta http-equiv="refresh" content="0; URL={local:doHtmlName('VS',$vsid,$vsed,'.html',true())}"/>
                            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                            <meta name="robots" content="noindex, nofollow"/>
                            <meta http-equiv="expires" content="0"/>
                            <!-- xhtml requirement -->
                            <title>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'terminologyValueSetHeader'"/>
                                    <xsl:with-param name="p1" select="$vsnm"/>
                                </xsl:call-template>
                            </title>
                        </head>
                        <!-- xhtml requirement -->
                        <body/>
                    </html>
                </xsl:result-document>
            </xsl:if>
        </xsl:for-each-group>
        <!-- create all code system html representations -->
        <xsl:for-each-group select="$allCodeSystems/*/codeSystem" group-by="concat((@id | @ref), '#', @effectiveDate)">
            <xsl:variable name="csid" select="(@id | @ref)"/>
            <xsl:variable name="csnm" select="@name"/>
            <xsl:variable name="csed" select="@effectiveDate"/>
            <xsl:variable name="csIsNewest" select="$csed = max($allCodeSystems/*/codeSystem[(@id | @ref) = $csid]/xs:dateTime(@effectiveDate))"/>
            <xsl:variable name="theStatusLabel">
                <xsl:variable name="t">
                    <xsl:call-template name="getXFormsLabel">
                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                    </xsl:call-template>
                </xsl:variable>
                <xsl:choose>
                    <xsl:when test="empty($t) or $t = @statusCode">
                        <xsl:call-template name="getXFormsLabel">
                            <xsl:with-param name="simpleTypeKey" select="'ReleaseStatusCodeLifeCycle'"/>
                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:copy-of select="$t"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:call-template name="logMessage">
                <xsl:with-param name="level" select="$logDEBUG"/>
                <xsl:with-param name="msg">
                    <xsl:text>*** HTML for code system: name='</xsl:text>
                    <xsl:value-of select="$csnm"/>
                    <xsl:text>' id='</xsl:text>
                    <xsl:value-of select="$csid"/>
                    <xsl:text>' effectiveDate='</xsl:text>
                    <xsl:value-of select="$csed"/>
                    <xsl:text>'</xsl:text>
                </xsl:with-param>
            </xsl:call-template>
            <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('CS',$csid,$csed,'.html',true())}" format="xhtml">
                <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                        <title>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'terminologyCodeSystemHeader'"/>
                                <xsl:with-param name="p1" select="$csnm"/>
                            </xsl:call-template>
                        </title>
                        <!--<link href="{$theAssetsDir}decor.css" rel="stylesheet" type="text/css"/>
                            <link href="{$theAssetsDir}favicon.ico" rel="shortcut icon" type="image/x-icon"/>-->
                        <xsl:call-template name="addAssetsHeader">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                    </head>
                    <body>
                        <div class="indexline">
                            <a href="{local:doHtmlName('tabFrontPage',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToIndex'"/>
                                </xsl:call-template>
                            </a>
                            <xsl:text> &#160;&lt;&lt;&#160; </xsl:text>
                            <a href="{local:doHtmlName('tabTerminology',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToTerminology'"/>
                                </xsl:call-template>
                            </a>
                        </div>
                        <h1>
                            <xsl:call-template name="showStatusDot">
                                <xsl:with-param name="status" select="@statusCode"/>
                                <xsl:with-param name="title" select="$theStatusLabel"/>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'CodeSystem'"/>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <i>
                                <xsl:value-of select="(@displayName, @name)[1]"/>
                            </i>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="showDate">
                                <xsl:with-param name="date" select="@effectiveDate"/>
                            </xsl:call-template>
                        </h1>
                        <!--<table style="border: 0;">
                                <tr>
                                    <td class="comment">
                                        <xsl:call-template name="doDescription">
                                            <xsl:with-param name="ns" select="desc"/>
                                            <xsl:with-param name="shortDesc" select="true()"/>
                                        </xsl:call-template>
                                    </td>
                                </tr>
                            </table>-->
                        <table width="100%" border="0">
                            <tr>
                                <td class="tabtab">
                                    <xsl:apply-templates select="."/>
                                </td>
                            </tr>
                        </table>
                    </body>
                </html>
            </xsl:result-document>
            <xsl:if test="$csIsNewest = true()">
                <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('CS',$csid,'dynamic','.html',true())}" format="xhtml">
                    <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                            <meta http-equiv="refresh" content="0; URL={local:doHtmlName('CS',$csid,$csed,'.html',true())}"/>
                            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                            <meta name="robots" content="noindex, nofollow"/>
                            <meta http-equiv="expires" content="0"/>
                            <!-- xhtml requirement -->
                            <title>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'terminologyCodeSystemHeader'"/>
                                    <xsl:with-param name="p1" select="$csnm"/>
                                </xsl:call-template>
                            </title>
                        </head>
                        <!-- xhtml requirement -->
                        <body/>
                    </html>
                </xsl:result-document>
            </xsl:if>
        </xsl:for-each-group>
        <!-- create all concept map html representations -->
        <xsl:for-each-group select="$allConceptMaps" group-by="concat((@id | @ref), '#', @effectiveDate)">
            <xsl:variable name="mpid" select="(@id | @ref)"/>
            <xsl:variable name="mpnm" select="@displayName"/>
            <xsl:variable name="mped" select="@effectiveDate"/>
            <xsl:variable name="csIsNewest" select="$mped = max($allConceptMaps[(@id | @ref) = $mpid]/xs:dateTime(@effectiveDate))"/>
            <xsl:variable name="theStatusLabel">
                <xsl:variable name="t">
                    <xsl:call-template name="getXFormsLabel">
                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                    </xsl:call-template>
                </xsl:variable>
                <xsl:choose>
                    <xsl:when test="empty($t) or $t = @statusCode">
                        <xsl:call-template name="getXFormsLabel">
                            <xsl:with-param name="simpleTypeKey" select="'ReleaseStatusCodeLifeCycle'"/>
                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:copy-of select="$t"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:call-template name="logMessage">
                <xsl:with-param name="level" select="$logDEBUG"/>
                <xsl:with-param name="msg">
                    <xsl:text>*** HTML for concept map: name='</xsl:text>
                    <xsl:value-of select="$mpnm"/>
                    <xsl:text>' id='</xsl:text>
                    <xsl:value-of select="$mpid"/>
                    <xsl:text>' effectiveDate='</xsl:text>
                    <xsl:value-of select="$mped"/>
                    <xsl:text>'</xsl:text>
                </xsl:with-param>
            </xsl:call-template>
            <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('MP',$mpid,$mped,'.html',true())}" format="xhtml">
                <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                        <title>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'terminologyConceptMapHeader'"/>
                                <xsl:with-param name="p1" select="$mpnm"/>
                            </xsl:call-template>
                        </title>
                        <!--<link href="{$theAssetsDir}decor.css" rel="stylesheet" type="text/css"/>
                            <link href="{$theAssetsDir}favicon.ico" rel="shortcut icon" type="image/x-icon"/>-->
                        <xsl:call-template name="addAssetsHeader">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                    </head>
                    <body>
                        <div class="indexline">
                            <a href="{local:doHtmlName('tabFrontPage',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToIndex'"/>
                                </xsl:call-template>
                            </a>
                            <xsl:text> &#160;&lt;&lt;&#160; </xsl:text>
                            <a href="{local:doHtmlName('tabTerminology',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToTerminology'"/>
                                </xsl:call-template>
                            </a>
                        </div>
                        <h1>
                            <xsl:call-template name="showStatusDot">
                                <xsl:with-param name="status" select="@statusCode"/>
                                <xsl:with-param name="title" select="$theStatusLabel"/>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'ConceptMap'"/>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <i>
                                <xsl:value-of select="(@displayName, @name)[1]"/>
                            </i>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="showDate">
                                <xsl:with-param name="date" select="@effectiveDate"/>
                            </xsl:call-template>
                        </h1>
                        <!--<table style="border: 0;">
                                <tr>
                                    <td class="comment">
                                        <xsl:call-template name="doDescription">
                                            <xsl:with-param name="ns" select="desc"/>
                                            <xsl:with-param name="shortDesc" select="true()"/>
                                        </xsl:call-template>
                                    </td>
                                </tr>
                            </table>-->
                        <table width="100%" border="0">
                            <tr>
                                <td class="tabtab">
                                    <xsl:apply-templates select="."/>
                                </td>
                            </tr>
                        </table>
                    </body>
                </html>
            </xsl:result-document>
            <xsl:if test="$csIsNewest = true()">
                <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('MP',$mpid,'dynamic','.html',true())}" format="xhtml">
                    <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                            <meta http-equiv="refresh" content="0; URL={local:doHtmlName('MP',$mpid,$mped,'.html',true())}"/>
                            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                            <meta name="robots" content="noindex, nofollow"/>
                            <meta http-equiv="expires" content="0"/>
                            <!-- xhtml requirement -->
                            <title>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'terminologyConceptMapHeader'"/>
                                    <xsl:with-param name="p1" select="$mpnm"/>
                                </xsl:call-template>
                            </title>
                        </head>
                        <!-- xhtml requirement -->
                        <body/>
                    </html>
                </xsl:result-document>
            </xsl:if>
        </xsl:for-each-group>
    </xsl:template>
    <xsl:template name="doRulesTab">
        <xsl:variable name="sc-style" select="'border-top: 6px solid white;'"/>
        <!-- certain columns are hidden initially by default when treetable is active.
            That doesn't work with classic so we don't hide them
        -->
        <xsl:variable name="coldisplay">
            <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                <xsl:text>display: none;</xsl:text>
            </xsl:if>
        </xsl:variable>
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Rules/Templates Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:variable name="representingTemplates" as="element()*">
            <xsl:for-each select="$allScenarios//representingTemplate[@ref]">
                <xsl:variable name="theTransaction" select="parent::transaction"/>
                <xsl:variable name="tmref" select="@ref"/>
                <!-- concat for backward compatibility -->
                <xsl:variable name="theTemplate">
                    <xsl:call-template name="getRulesetContent">
                        <xsl:with-param name="ruleset" select="$tmref"/>
                        <xsl:with-param name="flexibility" select="@flexibility"/>
                        <xsl:with-param name="sofar" select="()"/>
                    </xsl:call-template>
                </xsl:variable>
                <transaction xmlns="">
                    <xsl:copy-of select="$theTransaction/@*"/>
                    <xsl:copy-of select="$theTransaction/name"/>
                    <template>
                        <xsl:copy-of select="$theTemplate/template/@*"/>
                    </template>
                </transaction>
            </xsl:for-each>
        </xsl:variable>
        <xsl:variable name="content6">
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <h2>
                    <a id="labelRules"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'tabRulesTitleString'"/>
                    </xsl:call-template>
                </h2>
                <div class="tabtab">
                    <xsl:variable name="doExpirationDate" select="$allTemplates/*/ref/template[@expirationDate[not(. = '')]]"/>
                    <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                        <div>
                            <button id="expandAll" type="button">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                </xsl:call-template>
                            </button>
                            <button id="collapseAll" type="button">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                </xsl:call-template>
                            </button>
                            <input id="nameSearch">
                                <xsl:attribute name="placeholder">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'textSearch'"/>
                                    </xsl:call-template>
                                </xsl:attribute>
                            </input>
                        </div>
                    </xsl:if>
                    <table id="transactionTable" class="treetable highlight" width="100%" border="0" cellspacing="0" cellpadding="5">
                        <thead>
                            <tr>
                                <!-- HTML -->
                                <th class="columnAllView" style="width: 50px;">HTML</th>
                                <!-- Name -->
                                <th>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'columnName'"/>
                                    </xsl:call-template>
                                </th>
                                <th style="width: 15em;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'effectiveDate'"/>
                                    </xsl:call-template>
                                </th>
                                <xsl:if test="$doExpirationDate">
                                    <th style="width: 15em;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'expirationDate'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                                <th style="width: 10em;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'columnVersionLabel'"/>
                                    </xsl:call-template>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <xsl:variable name="node-id" select="'doclevel-templates'"/>
                            <!-- first show all document/transaction level templates -->
                            <!-- classification type row -->
                            <tr data-tt-id="{$node-id}" class="tmclassline">
                                <td class="columnName" style="border-top: 6px solid white;"/>
                                <td class="columnName" colspan="{if ($doExpirationDate) then 5 else 4}" style="border-top: 6px solid white;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'tabRepresentingTemplatesString'"/>
                                    </xsl:call-template>
                                </td>
                            </tr>
                            <xsl:for-each select="$allTemplates/*/ref/template">
                                <xsl:sort select="if (@displayName) then lower-case(@displayName) else lower-case(@name)"/>
                                <xsl:variable name="tmid" select="@id"/>
                                <xsl:variable name="tmed" select="@effectiveDate"/>
                                <xsl:if test="$representingTemplates/template[@id = $tmid][@effectiveDate = $tmed]">
                                    <xsl:variable name="templateAnchor" select="local:doHtmlAnchor($tmid, $tmed)"/>
                                    <xsl:variable name="node-id-tm" select="generate-id(.)"/>
                                    <xsl:variable name="node-color" select="'#fff7f2'"/>
                                    <tr data-tt-id="{$node-id-tm}-reptemp" data-tt-parent-id="{$node-id}" class="tmtrline">
                                        <!-- HTML -->
                                        <td style="{$sc-style}">
                                            <a id="{$templateAnchor}"/>
                                            <a href="{local:doHtmlName('TM',$tmid,$tmed,'.html')}" onclick="target='_blank';">html</a>
                                        </td>
                                        <td class="columnName" style="{$sc-style}">
                                            <xsl:variable name="columnName">
                                                <xsl:call-template name="showStatusDot">
                                                    <xsl:with-param name="status" select="@statusCode"/>
                                                    <xsl:with-param name="title">
                                                        <xsl:call-template name="getXFormsLabel">
                                                            <xsl:with-param name="simpleTypeKey" select="'TemplateStatusCodeLifeCycle'"/>
                                                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                        </xsl:call-template>
                                                    </xsl:with-param>
                                                </xsl:call-template>
                                                <xsl:text>&#160;</xsl:text>
                                                <xsl:value-of select="if (@displayName) then @displayName else @name"/>
                                                <xsl:text>&#160;</xsl:text>
                                                <xsl:value-of select="@id"/>
                                                <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                            </xsl:variable>
                                            <xsl:choose>
                                                <xsl:when test="not($switchCreateTreeTableHtml = 'true')">
                                                    <table>
                                                        <tr>
                                                            <xsl:call-template name="doIndentLevel">
                                                                <xsl:with-param name="level" select="2"/>
                                                                <xsl:with-param name="icon" select="false()"/>
                                                            </xsl:call-template>
                                                            <td>
                                                                <xsl:copy-of select="$columnName"/>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:copy-of select="$columnName"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </td>
                                        <td style="{$sc-style}">
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="@effectiveDate"/>
                                            </xsl:call-template>
                                        </td>
                                        <xsl:if test="$doExpirationDate">
                                            <td style="{$sc-style}">
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="@expirationDate"/>
                                                </xsl:call-template>
                                            </td>
                                        </xsl:if>
                                        <td style="{$sc-style}">
                                            <xsl:value-of select="@versionLabel"/>
                                        </td>
                                    </tr>
                                    <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
                                        <tr data-tt-id="{$node-id}-desc" data-tt-parent-id="{$node-id-tm}-reptemp">
                                            <td class="columnAllView"/>
                                            <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDate) then 4 else 3}">
                                                <xsl:value-of>
                                                    <xsl:call-template name="doDescription">
                                                        <xsl:with-param name="ns" select="desc"/>
                                                        <xsl:with-param name="shortDesc" select="true()"/>
                                                    </xsl:call-template>
                                                </xsl:value-of>
                                            </td>
                                        </tr>
                                    </xsl:if>
                                    <!-- Transaction details -->
                                    <tr data-tt-id="{$node-id-tm}-reptemp-{position()}" data-tt-parent-id="{$node-id-tm}-reptemp">
                                        <td class="columnDescription"/>
                                        <td class="columnDescription" colspan="{if ($doExpirationDate) then 5 else 4}" style="padding-left: 5em;">
                                            <xsl:variable name="doUnderlyingModel" select="$representingTemplates/template[@id = $tmid][@effectiveDate = $tmed][parent::transaction/@model]"/>
                                            <table class="tabtab" cellspacing="2" cellpadding="5">
                                                <tr class="headinglable">
                                                    <th>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'Transaction'"/>
                                                        </xsl:call-template>
                                                    </th>
                                                    <th style="width: 160px;" colspan="2">
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'Direction'"/>
                                                        </xsl:call-template>
                                                    </th>
                                                    <xsl:if test="$doUnderlyingModel">
                                                        <th style="width: 160px;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'UnderlyingModel'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                    </xsl:if>
                                                    <!--<th style="width: 160px;">
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'RuleName'"/>
                                                        </xsl:call-template>
                                                    </th>-->
                                                    <th>Schematron</th>
                                                </tr>
                                                <xsl:for-each select="$representingTemplates/template[@id = $tmid][@effectiveDate = $tmed]">
                                                    <tr>
                                                        <td>
                                                            <a href="{local:doHtmlName('tabScenarios',$projectPrefix,(),(),parent::transaction/@id, parent::transaction/@effectiveDate,(),(),'.html',false())}">
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="parent::transaction/name"/>
                                                                </xsl:call-template>
                                                            </a>
                                                        </td>
                                                        <td>
                                                            <xsl:call-template name="showDirection">
                                                                <xsl:with-param name="dir" select="parent::transaction/@type"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="concat('transactionDirection', parent::transaction/@type)"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <xsl:if test="$doUnderlyingModel">
                                                            <td>
                                                                <xsl:value-of select="parent::transaction/@model"/>
                                                            </td>
                                                        </xsl:if>
                                                        <!--<td>
                                                            <xsl:value-of select="parent::transaction/normalize-space(@label)"/>
                                                        </td>-->
                                                        <td>
                                                            <xsl:value-of select="concat($projectPrefix, parent::transaction/normalize-space(@label), '.sch')"/>
                                                        </td>
                                                    </tr>
                                                </xsl:for-each>
                                            </table>
                                        </td>
                                    </tr>
                                </xsl:if>
                            </xsl:for-each>
                            <!-- now show the rest of the templates -->
                            <xsl:variable name="classifications" select="$simpleTypes[@name = 'TemplateTypes']/*/xs:enumeration" as="element()+"/>
                            <xsl:for-each-group select="$allTemplates/*/ref/template" group-by="
                                    (if (classification/@type) then (
                                        count($classifications[@value = (current()/classification/@type)[1]]/preceding-sibling::*)
                                    ) else (
                                        count($classifications[@value = 'notype']/preceding-sibling::*)
                                    )) + 1">
                                <xsl:sort select="current-grouping-key()"/>
                                <xsl:variable name="classification" select="$classifications[position() = current-grouping-key()]/@value"/>
                                <xsl:variable name="node-id" select="concat('type-', $classification)"/>
                                <xsl:variable name="row-content" as="element()*">
                                    <xsl:for-each-group select="current-group()" group-by="@id">
                                        <xsl:sort select="lower-case(normalize-space((current-group()[1]/@displayName, current-group()[1]/@name)[1]))"/>
                                        <xsl:variable name="groupCount" select="count(current-group())"/>
                                        <xsl:for-each select="current-group()">
                                            <xsl:sort select="@effectiveDate" order="descending"/>
                                            <xsl:variable name="tmid" select="@id"/>
                                            <xsl:variable name="tmed" select="@effectiveDate"/>
                                            <xsl:variable name="pos" select="position()"/>
                                            
                                            <!--<xsl:if test="not($representingTemplates/template[@id = $tmid][@effectiveDate = $tmed])">-->
                                            <xsl:variable name="templateAnchor" select="local:doHtmlAnchor($tmid, $tmed)"/>
                                            <xsl:variable name="node-id-tm" select="generate-id(.)"/>
                                            <xsl:variable name="node-color" select="'#fff7f2'"/>
                                            <!-- if we have multiple versions of a template, group them under their name/id -->
                                            <xsl:if test="$pos = 1 and $groupCount gt 1">
                                                <tr data-tt-id="{$node-id-tm}-group" class="tmclassline">
                                                    <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                                                    
                                                    <td style="{$sc-style}" class="columnAllView">
                                                        <xsl:text>&#160;</xsl:text>
                                                    </td>
                                                    <td style="{$sc-style}" class="columnName">
                                                        <xsl:call-template name="showStatusDot">
                                                            <xsl:with-param name="status" select="'ref'"/>
                                                            <xsl:with-param name="title">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'Group'"/>
                                                                </xsl:call-template>
                                                            </xsl:with-param>
                                                        </xsl:call-template>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <xsl:value-of select="current-group()[1]/(@displayName, @name)[1]"/>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <xsl:value-of select="$tmid"/>
                                                    </td>
                                                    <td style="{$sc-style}">
                                                        <i>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'Multiple'"/>
                                                            </xsl:call-template>
                                                            <xsl:text> (</xsl:text>
                                                            <xsl:value-of select="$groupCount"/>
                                                            <xsl:text>)</xsl:text>
                                                        </i>
                                                    </td>
                                                    <xsl:if test="$doExpirationDate">
                                                        <td style="{$sc-style}">
                                                            <xsl:text>&#160;</xsl:text>
                                                        </td>
                                                    </xsl:if>
                                                    <td style="{$sc-style}">
                                                        <xsl:text>&#160;</xsl:text>
                                                    </td>
                                                </tr>
                                                <xsl:if test="current-group()[1]/desc[.//text()[string-length(normalize-space()) gt 0]]">
                                                    <tr data-tt-id="{$node-id-tm}-desc" data-tt-parent-id="{$node-id-tm}-group">
                                                        <td class="columnAllView"/>
                                                        <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDate) then 4 else 3}">
                                                            <xsl:value-of>
                                                                <xsl:call-template name="doDescription">
                                                                    <xsl:with-param name="ns" select="current-group()[1]/desc"/>
                                                                    <xsl:with-param name="shortDesc" select="true()"/>
                                                                </xsl:call-template>
                                                            </xsl:value-of>
                                                        </td>
                                                    </tr>
                                                </xsl:if>
                                            </xsl:if>
                                            <tr data-tt-id="{$node-id-tm}" class="tmline">
                                                <xsl:choose>
                                                    <xsl:when test="$groupCount gt 1">
                                                        <xsl:attribute name="data-tt-parent-id" select="concat(generate-id(current-group()[1]), '-group')"/>
                                                    </xsl:when>
                                                    <xsl:when test="$pos = 1">
                                                        <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                                                    </xsl:when>
                                                    <xsl:when test="$pos > 1">
                                                        <xsl:attribute name="data-tt-parent-id" select="generate-id(current-group()[1])"/>
                                                    </xsl:when>
                                                </xsl:choose>
                                                <td style="{$sc-style}" class="columnAllView">
                                                    <a href="{local:doHtmlName('TM',@id,@effectiveDate,'.html')}" onclick="target='_blank';">html</a>
                                                </td>
                                                <td style="{$sc-style}" class="columnName">
                                                    <xsl:call-template name="showStatusDot">
                                                        <xsl:with-param name="status" select="@statusCode"/>
                                                        <xsl:with-param name="title">
                                                            <xsl:call-template name="getXFormsLabel">
                                                                <xsl:with-param name="simpleTypeKey" select="'TemplateStatusCodeLifeCycle'"/>
                                                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                            </xsl:call-template>
                                                        </xsl:with-param>
                                                    </xsl:call-template>
                                                    <xsl:text>&#160;</xsl:text>
                                                    <xsl:value-of select="(@displayName, @name)[1]"/>
                                                    <xsl:text>&#160;</xsl:text>
                                                    <xsl:value-of select="$tmid"/>
                                                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                                </td>
                                                <td style="{$sc-style}">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="$tmed"/>
                                                    </xsl:call-template>
                                                </td>
                                                <xsl:if test="$doExpirationDate">
                                                    <td style="{$sc-style}">
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="@expirationDate"/>
                                                        </xsl:call-template>
                                                    </td>
                                                </xsl:if>
                                                <td style="{$sc-style}">
                                                    <xsl:value-of select="@versionLabel"/>
                                                </td>
                                            </tr>
                                            <xsl:if test="$groupCount = 1 and $pos = 1 and desc[.//text()[string-length(normalize-space()) gt 0]]">
                                                <tr data-tt-id="{$node-id-tm}-desc" data-tt-parent-id="{$node-id-tm}">
                                                    <td class="columnAllView"/>
                                                    <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDate) then 4 else 3}">
                                                        <xsl:value-of>
                                                            <xsl:call-template name="doDescription">
                                                                <xsl:with-param name="ns" select="desc"/>
                                                                <xsl:with-param name="shortDesc" select="true()"/>
                                                            </xsl:call-template>
                                                        </xsl:value-of>
                                                    </td>
                                                </tr>
                                            </xsl:if>
                                            <!--</xsl:if>-->
                                        </xsl:for-each>
                                    </xsl:for-each-group>
                                </xsl:variable>
                                <!-- classification type row -->
                                <xsl:if test="$row-content">
                                    <tr data-tt-id="{$node-id}" class="tmline">
                                        <td class="columnName" style="{$sc-style}"/>
                                        <td class="columnName" style="{$sc-style}" colspan="{if ($doExpirationDate) then 4 else 3}">
                                            <a id="{$classification}"/>
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'TemplateTypes'"/>
                                                <xsl:with-param name="simpleTypeValue" select="$classification"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                    <xsl:copy-of select="$row-content"/>
                                </xsl:if>
                            </xsl:for-each-group>
                        </tbody>
                    </table>
                </div>
                <!-- then show a summary of rules table -->
                <h2>
                    <a name="labelRulesSummary"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'templateSummary'"/>
                    </xsl:call-template>
                </h2>
                <table class="tabtab" style="width: 750px;" border="0" cellspacing="3" cellpadding="2">
                    <tr style="background-color: #CCFFCC;">
                        <td>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'templates'"/>
                            </xsl:call-template>
                        </td>
                        <td colspan="2">
                            <xsl:value-of select="count($allTemplates/*/ref/template)"/>
                        </td>
                    </tr>
                </table>
                <!-- create rule lists per scenario x -->
                <h2>
                    <a name="labelRulesPerScenario"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'templatesPerScenario'"/>
                    </xsl:call-template>
                </h2>
                <xsl:for-each select="$allScenarios/scenarios/scenario">
                    <xsl:variable name="scid" select="ancestor-or-self::scenario/@id"/>
                    <xsl:variable name="sced" select="ancestor-or-self::scenario/@effectiveDate"/>
                    <xsl:variable name="scenarioname">
                        <a href="{local:doHtmlName('tabScenarios', $projectPrefix, (), (), $scid, $sced, (), (),'.html', false())}">
                            <i>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="name"/>
                                </xsl:call-template>
                            </i>
                        </a>
                        <xsl:text> </xsl:text>
                        <xsl:call-template name="doShorthandId">
                            <xsl:with-param name="id" select="$scid"/>
                        </xsl:call-template>
                        <xsl:text> </xsl:text>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'xAsOfy'"/>
                        </xsl:call-template>
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="$sced"/>
                        </xsl:call-template>
                    </xsl:variable>
                    <h3>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'templatesForScenario'"/>
                        </xsl:call-template>
                        <xsl:copy-of select="$scenarioname"/>
                    </h3>
                    <table class="tabtab" style="width: 750px;" border="0" cellspacing="3" cellpadding="2">
                        <tr>
                            <th style="width: 200px;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Transaction'"/>
                                </xsl:call-template>
                            </th>
                            <th style="width: 200px;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'representingTemplate'"/>
                                </xsl:call-template>
                            </th>
                            <th style="width: 200px;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Link'"/>
                                </xsl:call-template>
                            </th>
                            <th style="width: 150px;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'xAsOfy'"/>
                                </xsl:call-template>
                            </th>
                        </tr>
                        <xsl:choose>
                            <xsl:when test=".//representingTemplate[string-length(@ref) > 0]">
                                <xsl:for-each select=".//representingTemplate[string-length(@ref) > 0]">
                                    <xsl:variable name="trid" select="parent::transaction/@id"/>
                                    <xsl:variable name="tred" select="parent::transaction/@effectiveDate"/>
                                    <xsl:variable name="tmid" select="@ref"/>
                                    <xsl:variable name="tmflex" select="
                                            if (@flexibility) then
                                                (@flexibility)
                                            else
                                                ('dynamic')"/>
                                    <xsl:variable name="rccontent" as="element()*">
                                        <xsl:call-template name="getRulesetContent">
                                            <xsl:with-param name="ruleset" select="$tmid"/>
                                            <xsl:with-param name="flexibility" select="$tmflex"/>
                                            <xsl:with-param name="sofar" select="()"/>
                                        </xsl:call-template>
                                    </xsl:variable>
                                    <xsl:variable name="tmnm">
                                        <xsl:choose>
                                            <xsl:when test="string-length($rccontent/@displayName) &gt; 0">
                                                <xsl:value-of select="$rccontent/@displayName"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="$rccontent/@name"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <xsl:variable name="tmed" select="$rccontent/@effectiveDate"/>
                                    <tr>
                                        <td style="text-align: left;">
                                            <a href="{local:doHtmlName('tabScenarios', $projectPrefix, (), (), $trid, $tred, (), (), '.html', false())}">
                                                <xsl:call-template name="doName">
                                                    <xsl:with-param name="ns" select="parent::transaction/name"/>
                                                </xsl:call-template>
                                            </a>
                                        </td>
                                        <td style="text-align: left;">
                                            <xsl:call-template name="doShorthandId">
                                                <xsl:with-param name="id" select="$tmid"/>
                                            </xsl:call-template>
                                        </td>
                                        <td style="text-align: left;">
                                            <a href="{local:doHtmlName('TM', $rccontent/@id, $tmflex, '.html')}" onclick="target='_blank';">
                                                <xsl:value-of select="$tmnm"/>
                                            </a>
                                        </td>
                                        <td style="text-align: left;">
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$tmed"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                            </xsl:when>
                            <xsl:otherwise>
                                <tr>
                                    <td style="text-align: left;" colspan="4">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'ruleNotDefinedYet'"/>
                                        </xsl:call-template>
                                    </td>
                                </tr>
                            </xsl:otherwise>
                        </xsl:choose>
                    </table>
                </xsl:for-each>
                <!-- create list of item labels in templates -->
                <h2>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'itemLabelsPerTemplate'"/>
                    </xsl:call-template>
                </h2>
                <!-- get all item labels in all registered templates and cache them -->
                <xsl:variable name="allitemlabels">
                    <labels xmlns="">
                        <xsl:for-each select="$allTemplates/*/ref/template">
                            <xsl:variable name="tid" select="@id"/>
                            <xsl:variable name="ted" select="@effectiveDate"/>
                            <xsl:variable name="tdn">
                                <xsl:choose>
                                    <xsl:when test="string-length(@displayName) &gt; 0">
                                        <xsl:value-of select="@displayName"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="@name"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:variable>
                            <xsl:for-each select=".//item[@label]">
                                <label>
                                    <xsl:attribute name="label">
                                        <xsl:value-of select="@label"/>
                                    </xsl:attribute>
                                    <xsl:attribute name="tid">
                                        <xsl:value-of select="$tid"/>
                                    </xsl:attribute>
                                    <xsl:attribute name="ted">
                                        <xsl:value-of select="$ted"/>
                                    </xsl:attribute>
                                    <xsl:attribute name="tdn">
                                        <xsl:value-of select="$tdn"/>
                                    </xsl:attribute>
                                </label>
                            </xsl:for-each>
                        </xsl:for-each>
                    </labels>
                </xsl:variable>
                <table class="tabtab" style="width: 750px;" border="0" cellspacing="3" cellpadding="2">
                    <tr>
                        <th>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'itemReference'"/>
                            </xsl:call-template>
                        </th>
                        <th colspan="2">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'templateId'"/>
                            </xsl:call-template>
                        </th>
                        <th>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'RuleName'"/>
                            </xsl:call-template>
                        </th>
                        <th>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Link'"/>
                            </xsl:call-template>
                        </th>
                        <th>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'xAsOfy'"/>
                            </xsl:call-template>
                        </th>
                    </tr>
                    <xsl:for-each select="$allitemlabels/*/label">
                        <xsl:sort select="@label"/>
                        <tr>
                            <td style="text-align: left;">
                                <xsl:value-of select="replace(string(@label), '-', '‑')"/>
                            </td>
                            <td style="text-align: left;">
                                <xsl:call-template name="showIcon">
                                    <xsl:with-param name="which">link11</xsl:with-param>
                                </xsl:call-template>
                            </td>
                            <td style="text-align: left;">
                                <xsl:call-template name="doShorthandId">
                                    <xsl:with-param name="id" select="@tid"/>
                                </xsl:call-template>
                            </td>
                            <td style="text-align: left;">
                                <i>
                                    <xsl:value-of select="@tdn"/>
                                </i>
                            </td>
                            <td style="text-align: left;">
                                <a href="{local:doHtmlName('TM',@tid,'dynamic','.html')}" onclick="target='_blank';">
                                    <xsl:value-of select="@tid"/>
                                </a>
                            </td>
                            <td style="text-align: left;">
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="@ted"/>
                                </xsl:call-template>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabRules'"/>
            <xsl:with-param name="actualcontent" select="$content6"/>
        </xsl:call-template>
        <!-- create all template html representations, all have the exact same contents, they are just written for referencing -->
        <xsl:for-each select="$allTemplates/*/ref/template">
            <xsl:variable name="tid" select="@id"/>
            <xsl:variable name="tnm" select="@name"/>
            <xsl:variable name="ted" select="@effectiveDate"/>
            <xsl:call-template name="logMessage">
                <xsl:with-param name="level" select="$logDEBUG"/>
                <xsl:with-param name="msg">
                    <xsl:text>*** HTML for template: name='</xsl:text>
                    <xsl:value-of select="$tnm"/>
                    <xsl:text>' id='</xsl:text>
                    <xsl:value-of select="$tid"/>
                    <xsl:text>' effectiveDate='</xsl:text>
                    <xsl:value-of select="$ted"/>
                    <xsl:text>'</xsl:text>
                </xsl:with-param>
            </xsl:call-template>
            <!-- Write the static variant for include/contains with static flexibility -->
            <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('TM',$tid,$ted,'.html',true())}" format="xhtml">
                <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                        <title>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Template'"/>
                            </xsl:call-template>
                            <xsl:value-of select="concat(@id, ' - ', @name)"/>
                        </title>
                        <xsl:call-template name="addAssetsHeader">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                        <!--link href="{$theAssetsDir}decor.css" rel="stylesheet" type="text/css"/-->
                    </head>
                    <body>
                        <div class="indexline">
                            <a href="{local:doHtmlName('tabFrontPage',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToIndex'"/>
                                </xsl:call-template>
                            </a>
                            <xsl:text> &#160;&lt;&lt;&#160; </xsl:text>
                            <a href="{local:doHtmlName('tabRules',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToRules'"/>
                                </xsl:call-template>
                            </a>
                        </div>
                        <h1>
                            <xsl:call-template name="showStatusDot">
                                <xsl:with-param name="status" select="@statusCode"/>
                                <xsl:with-param name="title">
                                    <xsl:choose>
                                        <xsl:when test="@ident[not(. = $projectPrefix)]">
                                            <xsl:value-of select="'ref'"/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'TemplateStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:with-param>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Template'"/>
                            </xsl:call-template>
                            <!--xsl:value-of select="$tid"/-->
                            <!--xsl:if test="string-length(@displayName)>0 and (@name != @displayName)"-->
                            <xsl:text>&#160;</xsl:text>
                            <i>
                                <xsl:value-of select="
                                        if (string-length(@displayName) &gt; 0) then
                                            (@displayName)
                                        else
                                            (@name)"/>
                            </i>
                            <!--/xsl:if-->
                        </h1>
                        <!--h2>
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="@effectiveDate"/>
                                </xsl:call-template>
                            </h2-->
                        <table width="100%" border="0">
                            <tr>
                                <td class="tabtab">
                                    <xsl:apply-templates select=".">
                                        <xsl:with-param name="templatename" select="concat(@id, ' - ', @name)"/>
                                    </xsl:apply-templates>
                                </td>
                            </tr>
                        </table>
                        <xsl:call-template name="addAssetsBottom">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                    </body>
                </html>
            </xsl:result-document>
            <!-- Write the whole thing again in a 'DYNAMIC' file for references in include/contains -->
            <xsl:if test="../@newestForId = true()">
                <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('TM',$tid,'dynamic','.html',true())}" format="xhtml">
                    <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                            <meta http-equiv="refresh" content="0; URL={local:doHtmlName('TM',$tid,$ted,'.html',true())}"/>
                            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                            <meta name="robots" content="noindex, nofollow"/>
                            <meta http-equiv="expires" content="0"/>
                            <!-- xhtml requirement -->
                            <title>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Template'"/>
                                </xsl:call-template>
                                <xsl:value-of select="concat(@id, ' - ', @name)"/>
                            </title>
                        </head>
                        <!-- xhtml requirement -->
                        <body/>
                    </html>
                </xsl:result-document>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="doQuestionnairesTab">
        <xsl:variable name="sc-style" select="'border-top: 6px solid white;'"/>
        <!-- certain columns are hidden initially by default when treetable is active.
            That doesn't work with classic so we don't hide them
        -->
        <xsl:variable name="coldisplay">
            <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                <xsl:text>display: none;</xsl:text>
            </xsl:if>
        </xsl:variable>
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Questionnaires Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:variable name="representingTemplates" as="element()*">
            <xsl:for-each select="$allScenarios//representingTemplate[@representingQuestionnaire]">
                <xsl:variable name="theTransaction" select="parent::transaction"/>
                <!-- concat for backward compatibility -->
                <xsl:variable name="qq" as="element()?">
                    <xsl:call-template name="getQuestionnaireContent">
                        <xsl:with-param name="qqid" select="@representingQuestionnaire"/>
                        <xsl:with-param name="qqed" select="@representingQuestionnaireFlexibility"/>
                    </xsl:call-template>
                </xsl:variable>
                <transaction xmlns="">
                    <xsl:copy-of select="$theTransaction/@*"/>
                    <xsl:copy-of select="$theTransaction/name"/>
                    <questionnaire>
                        <xsl:copy-of select="$qq/@*"/>
                    </questionnaire>
                </transaction>
            </xsl:for-each>
        </xsl:variable>
        <xsl:variable name="content6">
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <h2>
                    <a id="labelRules"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'tabQuestionnairesTitleString'"/>
                    </xsl:call-template>
                </h2>
                <div class="tabtab">
                    <xsl:variable name="doExpirationDate" select="$allQuestionnaires[@expirationDate[not(. = '')]]"/>
                    <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                        <div>
                            <button id="expandAll" type="button">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                </xsl:call-template>
                            </button>
                            <button id="collapseAll" type="button">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                </xsl:call-template>
                            </button>
                            <input id="nameSearch">
                                <xsl:attribute name="placeholder">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'textSearch'"/>
                                    </xsl:call-template>
                                </xsl:attribute>
                            </input>
                        </div>
                    </xsl:if>
                    <table id="transactionTable" class="treetable highlight" width="100%" border="0" cellspacing="0" cellpadding="5">
                        <thead>
                            <tr>
                                <!-- HTML -->
                                <th class="columnAllView" style="width: 50px;">HTML</th>
                                <!-- Name -->
                                <th>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'columnName'"/>
                                    </xsl:call-template>
                                </th>
                                <th style="width: 15em;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'effectiveDate'"/>
                                    </xsl:call-template>
                                </th>
                                <xsl:if test="$doExpirationDate">
                                    <th style="width: 15em;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'expirationDate'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                                <th style="width: 10em;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'columnVersionLabel'"/>
                                    </xsl:call-template>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <xsl:variable name="node-id" select="'doclevel-templates'"/>
                            <!-- first show all document/transaction level templates -->
                            <!-- classification type row -->
                            <tr data-tt-id="{$node-id}" class="tmclassline">
                                <td class="columnName" style="border-top: 6px solid white;"/>
                                <td class="columnName" colspan="{if ($doExpirationDate) then 5 else 4}" style="border-top: 6px solid white;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'tabRepresentingQuestionnairesString'"/>
                                    </xsl:call-template>
                                </td>
                            </tr>
                            <xsl:for-each select="$allQuestionnaires">
                                <xsl:sort select="name[1]"/>
                                <xsl:variable name="qqid" select="@id"/>
                                <xsl:variable name="qqed" select="@effectiveDate"/>
                                <xsl:if test="$representingTemplates/questionnaire[@id = $qqid][@effectiveDate = $qqed]">
                                    <xsl:variable name="templateAnchor" select="local:doHtmlAnchor($qqid, $qqed)"/>
                                    <xsl:variable name="node-id-tm" select="generate-id(.)"/>
                                    <xsl:variable name="node-color" select="'#fff7f2'"/>
                                    <tr data-tt-id="{$node-id-tm}-reptemp" data-tt-parent-id="{$node-id}" class="tmtrline">
                                        <!-- HTML -->
                                        <td style="{$sc-style}">
                                            <a id="{$templateAnchor}"/>
                                            <a href="{local:doHtmlName('QQ',$qqid,$qqed,'.html')}" onclick="target='_blank';">html</a>
                                        </td>
                                        <td class="columnName" style="{$sc-style}">
                                            <xsl:variable name="columnName">
                                                <xsl:call-template name="showStatusDot">
                                                    <xsl:with-param name="status" select="@statusCode"/>
                                                    <xsl:with-param name="title">
                                                        <xsl:call-template name="getXFormsLabel">
                                                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                        </xsl:call-template>
                                                    </xsl:with-param>
                                                </xsl:call-template>
                                                <xsl:text>&#160;</xsl:text>
                                                <xsl:value-of select="name[1]"/>
                                                <xsl:text>&#160;</xsl:text>
                                                <xsl:value-of select="@id"/>
                                                <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                            </xsl:variable>
                                            <xsl:choose>
                                                <xsl:when test="not($switchCreateTreeTableHtml = 'true')">
                                                    <table>
                                                        <tr>
                                                            <xsl:call-template name="doIndentLevel">
                                                                <xsl:with-param name="level" select="2"/>
                                                                <xsl:with-param name="icon" select="false()"/>
                                                            </xsl:call-template>
                                                            <td>
                                                                <xsl:copy-of select="$columnName"/>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:copy-of select="$columnName"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </td>
                                        <td style="{$sc-style}">
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="@effectiveDate"/>
                                            </xsl:call-template>
                                        </td>
                                        <xsl:if test="$doExpirationDate">
                                            <td style="{$sc-style}">
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="@expirationDate"/>
                                                </xsl:call-template>
                                            </td>
                                        </xsl:if>
                                        <td style="{$sc-style}">
                                            <xsl:value-of select="@versionLabel"/>
                                        </td>
                                    </tr>
                                    <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
                                        <tr data-tt-id="{$node-id}-desc" data-tt-parent-id="{$node-id-tm}-reptemp">
                                            <td class="columnAllView"/>
                                            <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDate) then 4 else 3}">
                                                <xsl:value-of>
                                                    <xsl:call-template name="doDescription">
                                                        <xsl:with-param name="ns" select="desc"/>
                                                        <xsl:with-param name="shortDesc" select="true()"/>
                                                    </xsl:call-template>
                                                </xsl:value-of>
                                            </td>
                                        </tr>
                                    </xsl:if>
                                    <!-- Transaction details -->
                                    <tr data-tt-id="{$node-id-tm}-reptemp-{position()}" data-tt-parent-id="{$node-id-tm}-reptemp">
                                        <td class="columnDescription"/>
                                        <td class="columnDescription" colspan="{if ($doExpirationDate) then 5 else 4}" style="padding-left: 5em;">
                                            <xsl:variable name="doUnderlyingModel" select="$representingTemplates/questionnaire[@id = $qqid][@effectiveDate = $qqed][parent::transaction/@model]"/>
                                            <table class="tabtab" cellspacing="2" cellpadding="5">
                                                <tr class="headinglable">
                                                    <th>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'Transaction'"/>
                                                        </xsl:call-template>
                                                    </th>
                                                    <th style="width: 160px;" colspan="2">
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'Direction'"/>
                                                        </xsl:call-template>
                                                    </th>
                                                    <xsl:if test="$doUnderlyingModel">
                                                        <th style="width: 160px;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'UnderlyingModel'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                    </xsl:if>
                                                    <!--<th style="width: 160px;">
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'RuleName'"/>
                                                        </xsl:call-template>
                                                    </th>-->
                                                    <!--<th>Schematron</th>-->
                                                </tr>
                                                <xsl:for-each select="$representingTemplates/questionnaire[@id = $qqid][@effectiveDate = $qqed]">
                                                    <tr>
                                                        <td>
                                                            <a href="{local:doHtmlName('tabScenarios',$projectPrefix,(),(),parent::transaction/@id, parent::transaction/@effectiveDate,(),(),'.html',false())}">
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="parent::transaction/name"/>
                                                                </xsl:call-template>
                                                            </a>
                                                        </td>
                                                        <td>
                                                            <xsl:call-template name="showDirection">
                                                                <xsl:with-param name="dir" select="parent::transaction/@type"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="concat('transactionDirection', parent::transaction/@type)"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <xsl:if test="$doUnderlyingModel">
                                                            <td>
                                                                <xsl:value-of select="parent::transaction/@model"/>
                                                            </td>
                                                        </xsl:if>
                                                        <!--<td>
                                                            <xsl:value-of select="parent::transaction/normalize-space(@label)"/>
                                                        </td>-->
                                                        <!--<td>
                                                            <xsl:value-of select="concat($projectPrefix, parent::transaction/normalize-space(@label), '.sch')"/>
                                                        </td>-->
                                                    </tr>
                                                </xsl:for-each>
                                            </table>
                                        </td>
                                    </tr>
                                </xsl:if>
                            </xsl:for-each>
                            <!-- now show the rest of the templates -->
                            <xsl:variable name="classifications" select="($allQuestionnaires/classification/tag, 'notype')" as="xs:string+"/>
                            <xsl:for-each-group select="$allQuestionnaires" group-by="
                                    (if (classification/tag) then (
                                        index-of($classifications, (current()/classification/tag)[1])[1]
                                    ) else (
                                        index-of($classifications, 'notype')[1]
                                    ))">
                                <xsl:sort select="current-grouping-key()"/>
                                <xsl:variable name="classification" select="$classifications[position() = current-grouping-key()]"/>
                                <xsl:variable name="node-id" select="concat('type-', $classification)"/>
                                <xsl:variable name="row-content" as="element()*">
                                    <xsl:for-each-group select="current-group()" group-by="@id">
                                        <xsl:sort select="lower-case(normalize-space((current-group()/name)[1]))"/>
                                        <xsl:variable name="groupCount" select="count(current-group())"/>
                                        <xsl:for-each select="current-group()">
                                            <xsl:sort select="@effectiveDate" order="descending"/>
                                            <xsl:variable name="tmid" select="@id"/>
                                            <xsl:variable name="tmed" select="@effectiveDate"/>
                                            <xsl:variable name="pos" select="position()"/>
                                            
                                            <!--<xsl:if test="not($representingTemplates/template[@id = $tmid][@effectiveDate = $tmed])">-->
                                            <xsl:variable name="templateAnchor" select="local:doHtmlAnchor($tmid, $tmed)"/>
                                            <xsl:variable name="node-id-tm" select="generate-id(.)"/>
                                            <xsl:variable name="node-color" select="'#fff7f2'"/>
                                            <!-- if we have multiple versions of a template, group them under their name/id -->
                                            <xsl:if test="$pos = 1 and $groupCount gt 1">
                                                <tr data-tt-id="{$node-id-tm}-group" class="tmclassline">
                                                    <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                                                    
                                                    <td style="{$sc-style}" class="columnAllView">
                                                        <xsl:text>&#160;</xsl:text>
                                                    </td>
                                                    <td style="{$sc-style}" class="columnName">
                                                        <xsl:call-template name="showStatusDot">
                                                            <xsl:with-param name="status" select="'ref'"/>
                                                            <xsl:with-param name="title">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'Group'"/>
                                                                </xsl:call-template>
                                                            </xsl:with-param>
                                                        </xsl:call-template>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <xsl:value-of select="current-group()[1]/name[1]"/>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <xsl:value-of select="$tmid"/>
                                                    </td>
                                                    <td style="{$sc-style}">
                                                        <i>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'Multiple'"/>
                                                            </xsl:call-template>
                                                            <xsl:text> (</xsl:text>
                                                            <xsl:value-of select="$groupCount"/>
                                                            <xsl:text>)</xsl:text>
                                                        </i>
                                                    </td>
                                                    <xsl:if test="$doExpirationDate">
                                                        <td style="{$sc-style}">
                                                            <xsl:text>&#160;</xsl:text>
                                                        </td>
                                                    </xsl:if>
                                                    <td style="{$sc-style}">
                                                        <xsl:text>&#160;</xsl:text>
                                                    </td>
                                                </tr>
                                                <xsl:if test="current-group()[1]/desc[.//text()[string-length(normalize-space()) gt 0]]">
                                                    <tr data-tt-id="{$node-id-tm}-desc" data-tt-parent-id="{$node-id-tm}-group">
                                                        <td class="columnAllView"/>
                                                        <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDate) then 4 else 3}">
                                                            <xsl:value-of>
                                                                <xsl:call-template name="doDescription">
                                                                    <xsl:with-param name="ns" select="current-group()[1]/desc"/>
                                                                    <xsl:with-param name="shortDesc" select="true()"/>
                                                                </xsl:call-template>
                                                            </xsl:value-of>
                                                        </td>
                                                    </tr>
                                                </xsl:if>
                                            </xsl:if>
                                            <tr data-tt-id="{$node-id-tm}" class="tmline">
                                                <xsl:choose>
                                                    <xsl:when test="$groupCount gt 1">
                                                        <xsl:attribute name="data-tt-parent-id" select="concat(generate-id(current-group()[1]), '-group')"/>
                                                    </xsl:when>
                                                    <xsl:when test="$pos = 1">
                                                        <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                                                    </xsl:when>
                                                    <xsl:when test="$pos > 1">
                                                        <xsl:attribute name="data-tt-parent-id" select="generate-id(current-group()[1])"/>
                                                    </xsl:when>
                                                </xsl:choose>
                                                <td style="{$sc-style}" class="columnAllView">
                                                    <a href="{local:doHtmlName('QQ',@id,@effectiveDate,'.html')}" onclick="target='_blank';">html</a>
                                                </td>
                                                <td style="{$sc-style}" class="columnName">
                                                    <xsl:call-template name="showStatusDot">
                                                        <xsl:with-param name="status" select="@statusCode"/>
                                                        <xsl:with-param name="title">
                                                            <xsl:call-template name="getXFormsLabel">
                                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                            </xsl:call-template>
                                                        </xsl:with-param>
                                                    </xsl:call-template>
                                                    <xsl:text>&#160;</xsl:text>
                                                    <xsl:value-of select="name[1]"/>
                                                    <xsl:text>&#160;</xsl:text>
                                                    <xsl:value-of select="$tmid"/>
                                                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                                </td>
                                                <td style="{$sc-style}">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="$tmed"/>
                                                    </xsl:call-template>
                                                </td>
                                                <xsl:if test="$doExpirationDate">
                                                    <td style="{$sc-style}">
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="@expirationDate"/>
                                                        </xsl:call-template>
                                                    </td>
                                                </xsl:if>
                                                <td style="{$sc-style}">
                                                    <xsl:value-of select="@versionLabel"/>
                                                </td>
                                            </tr>
                                            <xsl:if test="$groupCount = 1 and $pos = 1 and desc[.//text()[string-length(normalize-space()) gt 0]]">
                                                <tr data-tt-id="{$node-id-tm}-desc" data-tt-parent-id="{$node-id-tm}">
                                                    <td class="columnAllView"/>
                                                    <td style="'padding-left: 2em;')" class="columnDesc comment" colspan="{if ($doExpirationDate) then 4 else 3}">
                                                        <xsl:value-of>
                                                            <xsl:call-template name="doDescription">
                                                                <xsl:with-param name="ns" select="desc"/>
                                                                <xsl:with-param name="shortDesc" select="true()"/>
                                                            </xsl:call-template>
                                                        </xsl:value-of>
                                                    </td>
                                                </tr>
                                            </xsl:if>
                                            <!--</xsl:if>-->
                                        </xsl:for-each>
                                    </xsl:for-each-group>
                                </xsl:variable>
                                <!-- classification type row -->
                                <xsl:if test="$row-content">
                                    <tr data-tt-id="{$node-id}" class="tmline">
                                        <td class="columnName" style="{$sc-style}"/>
                                        <td class="columnName" style="{$sc-style}" colspan="{if ($doExpirationDate) then 4 else 3}">
                                            <a id="{$classification}"/>
                                            <xsl:choose>
                                                <xsl:when test="$classification = 'notype'">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'questionnaireTypeNotSpecified'"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:value-of select="$classification"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </td>
                                    </tr>
                                    <xsl:copy-of select="$row-content"/>
                                </xsl:if>
                            </xsl:for-each-group>
                        </tbody>
                    </table>
                </div>
                <!-- then show a summary of rules table -->
                <h2>
                    <a name="labelRulesSummary"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'questionnaireSummary'"/>
                    </xsl:call-template>
                </h2>
                <table class="tabtab" style="width: 750px;" border="0" cellspacing="3" cellpadding="2">
                    <tr style="background-color: #CCFFCC;">
                        <td>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Questionnaires'"/>
                            </xsl:call-template>
                        </td>
                        <td colspan="2">
                            <xsl:value-of select="count($allQuestionnaires)"/>
                        </td>
                    </tr>
                </table>
                <!-- create rule lists per scenario x -->
                <h2>
                    <a name="labelRulesPerScenario"/>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'questionnairesPerScenario'"/>
                    </xsl:call-template>
                </h2>
                <xsl:for-each select="$allScenarios/scenarios/scenario">
                    <xsl:variable name="scid" select="ancestor-or-self::scenario/@id"/>
                    <xsl:variable name="sced" select="ancestor-or-self::scenario/@effectiveDate"/>
                    <xsl:variable name="scenarioname">
                        <a href="{local:doHtmlName('tabScenarios', $projectPrefix, (), (), $scid, $sced, (), (),'.html', false())}">
                            <i>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="name"/>
                                </xsl:call-template>
                            </i>
                        </a>
                        <xsl:text> </xsl:text>
                        <xsl:call-template name="doShorthandId">
                            <xsl:with-param name="id" select="$scid"/>
                        </xsl:call-template>
                        <xsl:text> </xsl:text>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'xAsOfy'"/>
                        </xsl:call-template>
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="$sced"/>
                        </xsl:call-template>
                    </xsl:variable>
                    <h3>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'questionnairesForScenario'"/>
                        </xsl:call-template>
                        <xsl:copy-of select="$scenarioname"/>
                    </h3>
                    <table class="tabtab" style="width: 750px;" border="0" cellspacing="3" cellpadding="2">
                        <tr>
                            <th style="width: 200px;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Transaction'"/>
                                </xsl:call-template>
                            </th>
                            <th style="width: 200px;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'representingTemplate'"/>
                                </xsl:call-template>
                            </th>
                            <th style="width: 200px;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Link'"/>
                                </xsl:call-template>
                            </th>
                            <th style="width: 150px;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'xAsOfy'"/>
                                </xsl:call-template>
                            </th>
                        </tr>
                        <xsl:choose>
                            <xsl:when test=".//representingTemplate[string-length(@representingQuestionnaire) > 0]">
                                <xsl:for-each select=".//representingTemplate[string-length(@representingQuestionnaire) > 0]">
                                    <xsl:variable name="trid" select="parent::transaction/@id"/>
                                    <xsl:variable name="tred" select="parent::transaction/@effectiveDate"/>
                                    <xsl:variable name="qqid" select="@representingQuestionnaire"/>
                                    <xsl:variable name="qqed" select="(@representingQuestionnaireFlexibility, 'dynamic')[1]"/>
                                    <xsl:variable name="qq" as="element()*">
                                        <xsl:call-template name="getQuestionnaireContent">
                                            <xsl:with-param name="qqid" select="$qqid"/>
                                            <xsl:with-param name="qqed" select="$qqed"/>
                                        </xsl:call-template>
                                    </xsl:variable>
                                    <xsl:variable name="tmnm" select="$qq/name[1]"/>
                                    <xsl:variable name="tmed" select="$qq/@effectiveDate"/>
                                    <tr>
                                        <td style="text-align: left;">
                                            <a href="{local:doHtmlName('tabScenarios', $projectPrefix, (), (), $trid, $tred, (), (), '.html', false())}">
                                                <xsl:call-template name="doName">
                                                    <xsl:with-param name="ns" select="parent::transaction/name"/>
                                                </xsl:call-template>
                                            </a>
                                        </td>
                                        <td style="text-align: left;">
                                            <xsl:call-template name="doShorthandId">
                                                <xsl:with-param name="id" select="$qqid"/>
                                            </xsl:call-template>
                                        </td>
                                        <td style="text-align: left;">
                                            <a href="{local:doHtmlName('QQ', $qq/@id, $qqed, '.html')}" onclick="target='_blank';">
                                                <xsl:value-of select="$tmnm"/>
                                            </a>
                                        </td>
                                        <td style="text-align: left;">
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$tmed"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                            </xsl:when>
                            <xsl:otherwise>
                                <tr>
                                    <td style="text-align: left;" colspan="4">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'questionnaireNotDefinedYet'"/>
                                        </xsl:call-template>
                                    </td>
                                </tr>
                            </xsl:otherwise>
                        </xsl:choose>
                    </table>
                </xsl:for-each>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabQuestionnaires'"/>
            <xsl:with-param name="actualcontent" select="$content6"/>
        </xsl:call-template>
        
        <!-- create all template html representations, all have the exact same contents, they are just written for referencing -->
        <xsl:for-each select="$allQuestionnaires[@id]">
            <xsl:variable name="tid" select="@id"/>
            <xsl:variable name="tnm">
                <xsl:call-template name="doName">
                    <xsl:with-param name="ns" select="name"/>
                </xsl:call-template>
            </xsl:variable>
            <xsl:variable name="ted" select="@effectiveDate"/>
            <xsl:call-template name="logMessage">
                <xsl:with-param name="level" select="$logDEBUG"/>
                <xsl:with-param name="msg">
                    <xsl:text>*** HTML for questionnaire: name='</xsl:text>
                    <xsl:value-of select="$tnm[1]"/>
                    <xsl:text>' id='</xsl:text>
                    <xsl:value-of select="$tid"/>
                    <xsl:text>' effectiveDate='</xsl:text>
                    <xsl:value-of select="$ted"/>
                    <xsl:text>'</xsl:text>
                </xsl:with-param>
            </xsl:call-template>
            <!-- Write the static variant for include/contains with static flexibility -->
            <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('QQ',$tid,$ted,'.html',true())}" format="xhtml">
                <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                        <title>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Questionnaire'"/>
                            </xsl:call-template>
                            <xsl:value-of select="concat(@id, ' - ', $tnm)"/>
                        </title>
                        <xsl:call-template name="addAssetsHeader">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                        <!--link href="{$theAssetsDir}decor.css" rel="stylesheet" type="text/css"/-->
                    </head>
                    <body>
                        <div class="indexline">
                            <a href="{local:doHtmlName('tabFrontPage',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToIndex'"/>
                                </xsl:call-template>
                            </a>
                            <xsl:text> &#160;&lt;&lt;&#160; </xsl:text>
                            <a href="{local:doHtmlName('tabQuestionnaires',(),(),'.html', true())}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'backToQuestionnaires'"/>
                                </xsl:call-template>
                            </a>
                        </div>
                        <h1>
                            <xsl:call-template name="showStatusDot">
                                <xsl:with-param name="status" select="@statusCode"/>
                                <xsl:with-param name="title">
                                    <xsl:choose>
                                        <xsl:when test="@ident[not(. = $projectPrefix)]">
                                            <xsl:value-of select="'ref'"/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:with-param>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Questionnaire'"/>
                            </xsl:call-template>
                            <!--xsl:value-of select="$tid"/-->
                            <!--xsl:if test="string-length(@displayName)>0 and (@name != @displayName)"-->
                            <xsl:text>&#160;</xsl:text>
                            <i>
                                <xsl:copy-of select="$tnm"/>
                            </i>
                            <!--/xsl:if-->
                        </h1>
                        <!--h2>
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="@effectiveDate"/>
                                </xsl:call-template>
                            </h2-->
                        <table width="100%" border="0">
                            <tr>
                                <td class="tabtab">
                                    <xsl:apply-templates select=".">
                                        <xsl:with-param name="templatename" select="concat(@id, ' - ', @name)"/>
                                    </xsl:apply-templates>
                                </td>
                            </tr>
                        </table>
                        <xsl:call-template name="addAssetsBottom">
                            <xsl:with-param name="doTreeTable" select="true()"/>
                        </xsl:call-template>
                    </body>
                </html>
            </xsl:result-document>
            <!-- Write the whole thing again in a 'DYNAMIC' file for references in include/contains -->
            <xsl:if test="../@newestForId = true()">
                <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('QQ',$tid,'dynamic','.html',true())}" format="xhtml">
                    <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                            <meta http-equiv="refresh" content="0; URL={local:doHtmlName('QQ',$tid,$ted,'.html',true())}"/>
                            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                            <meta name="robots" content="noindex, nofollow"/>
                            <meta http-equiv="expires" content="0"/>
                            <!-- xhtml requirement -->
                            <title>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Questionnaire'"/>
                                </xsl:call-template>
                                <xsl:value-of select="concat(@id, ' - ')"/>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="name"/>
                                </xsl:call-template>
                            </title>
                        </head>
                        <!-- xhtml requirement -->
                        <body/>
                    </html>
                </xsl:result-document>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="doIssuesTab">
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Issues Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:variable name="content7">
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <xsl:choose>
                    <xsl:when test="count(//issues) = 0">
                        <!-- no issues at all -->
                        <h2>
                            <a name="labelIssues"/>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'tabIssuesTitleString'"/>
                            </xsl:call-template>
                        </h2>
                        <div id="Accordionis" class="Accordion">
                            <table style="border: 0;">
                                <xsl:call-template name="doMessage">
                                    <xsl:with-param name="level" select="'info'"/>
                                    <xsl:with-param name="msg">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueNoIssuesDocumentedYet'"/>
                                        </xsl:call-template>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </table>
                        </div>
                    </xsl:when>
                    <xsl:otherwise>
                        <div id="Accordionis" class="Accordion">
                            <!-- show all issues sorted -->
                            <xsl:call-template name="doShowIssues"/>
                        </div>
                    </xsl:otherwise>
                </xsl:choose>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabIssues'"/>
            <xsl:with-param name="actualcontent" select="$content7"/>
        </xsl:call-template>
        <!-- create all issue html representation -->
        <xsl:for-each-group select="//issues/issue" group-by="@id">
            <xsl:variable name="isid" select="@id"/>
            <xsl:if test="string-length($isid) &gt; 0">
                <xsl:call-template name="logMessage">
                    <xsl:with-param name="level" select="$logDEBUG"/>
                    <xsl:with-param name="msg">
                        <xsl:text>*** HTML for issue: id='</xsl:text>
                        <xsl:value-of select="$isid"/>
                        <xsl:text>' name='</xsl:text>
                        <xsl:value-of select="@displayName"/>
                        <xsl:text>'</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>
                <xsl:result-document href="{$theHtmlDir}{local:doHtmlName('IS',$isid,(),'.html',true())}" format="xhtml">
                    <html xml:lang="{substring($defaultLanguage,1,2)}" lang="{substring($defaultLanguage,1,2)}" xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                            <title>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'issuesHeader'"/>
                                    <xsl:with-param name="p1" select="$isid"/>
                                </xsl:call-template>
                            </title>
                            <!--<link href="{$theAssetsDir}decor.css" rel="stylesheet" type="text/css"/>
                                <link href="{$theAssetsDir}favicon.ico" rel="shortcut icon" type="image/x-icon"/>-->
                            <xsl:call-template name="addAssetsHeader">
                                <xsl:with-param name="doTreeTable" select="true()"/>
                            </xsl:call-template>
                        </head>
                        <body>
                            <div class="indexline">
                                <a href="{local:doHtmlName('tabFrontPage',(),(),'.html', true())}">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'backToIndex'"/>
                                    </xsl:call-template>
                                </a>
                                <xsl:text> &#160;&lt;&lt;&#160; </xsl:text>
                                <a href="{local:doHtmlName('tabIssues',(),(),'.html', true())}">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'backToIssues'"/>
                                    </xsl:call-template>
                                </a>
                            </div>
                            <xsl:apply-templates select="."/>
                        </body>
                    </html>
                </xsl:result-document>
            </xsl:if>
        </xsl:for-each-group>
    </xsl:template>
    <xsl:template name="doCompileTimeTab">
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Compilation Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:variable name="content8">
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <h2>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'tabCompileTimeIssuesTitleString'"/>
                    </xsl:call-template>
                </h2>
                <div id="Accordionce" class="Accordion">
                    <!--h2>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'tabCompileTimeInfoTitleString'"/>
                        </xsl:call-template>
                    </h2-->
                    <!-- 
                        the follwing div id runtimezipavailable will be shown the download
                        button if a $theRuntimeDirZIP object is available for download
                        and nothing otherwise
                        2DO : show message that the runtime is not available yet.
                    -->
                    <!--div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <h3 class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');" id="runtimezipalert">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'tabCompileTimeInfoSchematronRuntime'"/>
                                </xsl:call-template>
                            </h3>
                        </div>
                        <div class="AccordionPanelContent" id="runtimezipavailable" zipfile="{$theRuntimeDirZIP}"-->
                    <!-- show the download button if there is a downloadable runtime zip -->
                    <!--
                        <xsl:call-template name="showIcon">
                            <xsl:with-param name="which">download</xsl:with-param>
                        </xsl:call-template>
                        <xsl:text> </xsl:text>
                        <a href="{$theRuntimeDirZIP}">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'tabCompileTimeInfoDownlaod'"/>
                            </xsl:call-template>
                        </a>
                    -->
                    <!--xsl:call-template name="showIcon">
                                <xsl:with-param name="which">download</xsl:with-param>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'tabCompileTimeInfoDownlaodNotAvailableHere'"/>
                            </xsl:call-template>

                        </div>
                    </div-->
                    <!--  List of referenced value sets that cannot be found - list already created, show it -->
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <h3>
                                    <xsl:choose>
                                        <xsl:when test="count($valueSetReferenceErrors/*/error) = 0">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">info</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">notice</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'compileTimeIssueReferencedValueSetButNotFound'"/>
                                    </xsl:call-template>
                                </h3>
                            </div>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <xsl:choose>
                                <xsl:when test="count($valueSetReferenceErrors/*/error) = 0">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="level" select="'info'"/>
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'issueAllReferencedValueSetsWereFound'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table width="50%" border="0" cellspacing="2" cellpadding="2">
                                        <tr style="vertical-align: top;">
                                            <td class="tabtab">
                                                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                    <tr style="background-color: #FFCCCC;">
                                                        <td>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'compileTimeIssueReferencedValueSetButNotFoundNumber'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td>
                                                            <xsl:value-of select="count($valueSetReferenceErrors/*/error)"/>
                                                        </td>
                                                    </tr>
                                                    <xsl:for-each-group select="$valueSetReferenceErrors/*/error" group-by="concat(@id, @flexibility, @errortype)">
                                                        <xsl:variable name="id" select="@id"/>
                                                        <tr>
                                                            <td class="tabtab" colspan="2">
                                                                <table width="100%">
                                                                    <tr class="desclabel">
                                                                        <td>
                                                                            <strong>
                                                                                <xsl:value-of select="$id"/>
                                                                            </strong>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'xInBraces'"/>
                                                                                <xsl:with-param name="p1" select="@flexibility"/>
                                                                            </xsl:call-template>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="vertical-align: top;">
                                                                            <xsl:variable name="compileTimeIssueKey">
                                                                                <xsl:choose>
                                                                                    <xsl:when test="@errortype = 'terminologyref'">compileTimeIssueReferencedFromTerminologyAssociation</xsl:when>
                                                                                    <xsl:when test="@errortype = 'valuesetref'">compileTimeIssueReferencedFromValueSetRef</xsl:when>
                                                                                    <xsl:when test="@errortype = 'templateref'">compileTimeIssueReferencedFromTemplate</xsl:when>
                                                                                    <xsl:otherwise>compileTimeIssueReferencedFromOther</xsl:otherwise>
                                                                                </xsl:choose>
                                                                            </xsl:variable>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="$compileTimeIssueKey"/>
                                                                            </xsl:call-template>
                                                                            <ul>
                                                                                <xsl:for-each select="current-group()">
                                                                                    <xsl:variable name="idEff" select="normalize-space(string-join(@from-id | @from-effectiveDate, ' '))"/>
                                                                                    <li>
                                                                                        <xsl:choose>
                                                                                            <xsl:when test="name and @from-id">
                                                                                                <xsl:value-of select="name[@language = $defaultLanguage]"/>
                                                                                                <xsl:call-template name="getMessage">
                                                                                                    <xsl:with-param name="key" select="'xInBraces'"/>
                                                                                                    <xsl:with-param name="p1" select="$idEff"/>
                                                                                                </xsl:call-template>
                                                                                            </xsl:when>
                                                                                            <xsl:otherwise>
                                                                                                <xsl:value-of select="name[@language = $defaultLanguage]"/>
                                                                                                <xsl:value-of select="$idEff"/>
                                                                                            </xsl:otherwise>
                                                                                        </xsl:choose>
                                                                                    </li>
                                                                                </xsl:for-each>
                                                                            </ul>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                    </xsl:for-each-group>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>
                    <!-- The arbitrary limitation on the combination of completeCodeSystem and concepts has been lifted -->
                    <!--<xsl:variable name="vsWithCodeSystemRefAndConcepts" select="count($allValueSets//valueSet[completeCodeSystem and conceptList/concept])"/>

                    <!-\- List them -\->
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <h3 class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <xsl:choose>
                                    <xsl:when test="$vsWithCodeSystemRefAndConcepts=0">
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">info</xsl:with-param>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">alert</xsl:with-param>
                                        </xsl:call-template>
                                    </xsl:otherwise>
                                </xsl:choose>
                                <xsl:text> </xsl:text>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'compileTimeIssueValueSetWithCodeSystemRefAndConcepts'"/>
                                </xsl:call-template>
                            </h3>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <xsl:choose>
                                <xsl:when test="$vsWithCodeSystemRefAndConcepts=0">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="level" select="'info'"/>
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'issueNoValueSetWithCodeSystemRefAndConceptsFound'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table width="50%" border="0" cellspacing="2" cellpadding="2">
                                        <tr style="vertical-align: top;">
                                            <td class="tabtab">
                                                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                    <tr style="background-color: #FFCCCC;">
                                                        <td>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'compileTimeIssueValueSetWithCodeSystemRefAndConceptsNumber'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td>
                                                            <xsl:value-of select="$vsWithCodeSystemRefAndConcepts"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tabtab" colspan="2">
                                                            <ul>
                                                                <xsl:for-each select="$allValueSets//valueSet[completeCodeSystem and conceptList/concept]">
                                                                    <xsl:variable name="vsid" select="@id"/>
                                                                    <xsl:variable name="vseff" select="@effectiveDate"/>

                                                                    <li>
                                                                        <a href="{local:doHtmlName('VS',$vsid,$vseff,'.html')}">
                                                                            <xsl:value-of select="@name"/>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'xInBraces'"/>
                                                                                <xsl:with-param name="p1" select="$vsid"/>
                                                                            </xsl:call-template>
                                                                        </a>
                                                                    </li>
                                                                </xsl:for-each>
                                                            </ul>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>-->
                    <xsl:variable name="missingTemplates">
                        <xsl:call-template name="getMissingTemplates"/>
                    </xsl:variable>
                    <!--  List of included templates without a corresponding or empty template - list already created, show it -->
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <h3>
                                    <xsl:choose>
                                        <xsl:when test="count($missingTemplates/*/error) = 0">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">info</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">alert</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'compileTimeIssueIncludedTemplatesWithoutCorrespondingOrEmptyTemplate'"/>
                                    </xsl:call-template>
                                </h3>
                            </div>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <xsl:choose>
                                <xsl:when test="count($missingTemplates/*/error) = 0">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="level" select="'info'"/>
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'issueNoIncludedTemplatesWithoutACorrespondingOrEmptyTemplateFound'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table width="80%" border="0" cellspacing="2" cellpadding="2">
                                        <tr style="vertical-align: top;">
                                            <td class="tabtab">
                                                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                    <tr style="background-color: #FFCCCC;">
                                                        <td>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'compileTimeIssueIncludedTemplatesWithoutCorrespondingOrEmptyTemplateNumber'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td>
                                                            <xsl:value-of select="count(distinct-values($missingTemplates/*/error/concat(@ref, @flexibility, @empty)))"/>
                                                        </td>
                                                    </tr>
                                                    <xsl:for-each-group select="$missingTemplates/*/error" group-by="concat(@ref, @flexibility, @empty)">
                                                        <xsl:variable name="ref" select="current-group()[1]/@ref"/>
                                                        <xsl:variable name="flex" select="current-group()[1]/@flexibility"/>
                                                        <xsl:variable name="refdn" select="current-group()[1]/@refdisplayName"/>
                                                        <xsl:variable name="refstatus" select="current-group()[1]/@refstatusCode"/>
                                                        <xsl:variable name="empty" select="current-group()[1]/@empty"/>
                                                        <tr>
                                                            <td class="tabtab" colspan="2">
                                                                <table width="100%">
                                                                    <tr class="desclabel">
                                                                        <td>
                                                                            <xsl:if test="$refstatus">
                                                                                <xsl:call-template name="showStatusDot">
                                                                                    <xsl:with-param name="status" select="$refstatus"/>
                                                                                    <xsl:with-param name="title">
                                                                                        <xsl:call-template name="getXFormsLabel">
                                                                                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                                            <xsl:with-param name="simpleTypeValue" select="$refstatus"/>
                                                                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                                        </xsl:call-template>
                                                                                    </xsl:with-param>
                                                                                </xsl:call-template>
                                                                                <xsl:text> </xsl:text>
                                                                            </xsl:if>
                                                                            <strong>
                                                                                <xsl:value-of select="$ref"/>
                                                                            </strong>
                                                                            <xsl:text> </xsl:text>
                                                                            <xsl:if test="$refdn">
                                                                                <a href="{local:doHtmlName('TM',$ref,$flex,'.html')}">
                                                                                    <xsl:value-of select="$refdn"/>
                                                                                </a>
                                                                                <xsl:text> </xsl:text>
                                                                            </xsl:if>
                                                                            <xsl:choose>
                                                                                <xsl:when test="$flex castable as xs:dateTime">
                                                                                    <xsl:call-template name="showDate">
                                                                                        <xsl:with-param name="date" select="$flex"/>
                                                                                    </xsl:call-template>
                                                                                </xsl:when>
                                                                                <xsl:otherwise>
                                                                                    <xsl:call-template name="getMessage">
                                                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                                                    </xsl:call-template>
                                                                                </xsl:otherwise>
                                                                            </xsl:choose>
                                                                            <xsl:text> </xsl:text>
                                                                            <xsl:if test="$empty">
                                                                                <xsl:call-template name="getMessage">
                                                                                    <xsl:with-param name="key" select="'registeredButEmpty'"/>
                                                                                </xsl:call-template>
                                                                            </xsl:if>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="vertical-align: top;">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'compileTimeIssueReferencedInTemplate'"/>
                                                                            </xsl:call-template>
                                                                            <ol>
                                                                                <xsl:for-each select="current-group()">
                                                                                    <li>
                                                                                        <xsl:if test="@statusCode">
                                                                                            <xsl:call-template name="showStatusDot">
                                                                                                <xsl:with-param name="status" select="@statusCode"/>
                                                                                                <xsl:with-param name="title">
                                                                                                    <xsl:call-template name="getXFormsLabel">
                                                                                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                                                    </xsl:call-template>
                                                                                                </xsl:with-param>
                                                                                            </xsl:call-template>
                                                                                            <xsl:text> </xsl:text>
                                                                                        </xsl:if>
                                                                                        <xsl:choose>
                                                                                            <xsl:when test="@id">
                                                                                                <a href="{local:doHtmlName('TM',@id,@effectiveDate,'.html')}">
                                                                                                    <xsl:value-of
                                                                                                        select="
                                                                                                            if (string-length(@displayName) &gt; 0) then
                                                                                                                @displayName
                                                                                                            else
                                                                                                                @name"
                                                                                                    />
                                                                                                </a>
                                                                                                <xsl:call-template name="getMessage">
                                                                                                    <xsl:with-param name="key" select="'xInBraces'"/>
                                                                                                    <xsl:with-param name="p1" select="@id"/>
                                                                                                </xsl:call-template>
                                                                                            </xsl:when>
                                                                                            <xsl:otherwise>
                                                                                                <xsl:value-of select="@name"/>
                                                                                                <xsl:text> </xsl:text>
                                                                                                <xsl:value-of select="@ref"/>
                                                                                            </xsl:otherwise>
                                                                                        </xsl:choose>
                                                                                    </li>
                                                                                </xsl:for-each>
                                                                            </ol>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                    </xsl:for-each-group>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>
                    <!-- create a list of ids with missing designation -->
                    <xsl:variable name="missingIds">
                        <ids xmlns="">
                            <xsl:for-each-group select="//@codeSystem[not(ancestor::example)]/tokenize(., '\|')" group-by=".">
                                <xsl:variable name="theOID" select="current-grouping-key()"/>
                                <xsl:if test="empty($allIDs//id[@root = $theOID] or $allDECOR//sourceCodeSystem[@id = $theOID] | $allDatasets//terminologyAssociation[@codeSystem = $theOID][@codeSystemName])">
                                    <missingId oid="{$theOID}" type="code system" count="1"/>
                                </xsl:if>
                            </xsl:for-each-group>
                            <xsl:for-each-group select="//@root[not(ancestor::example)]/tokenize(., '\|')" group-by=".">
                                <xsl:variable name="theOID" select="."/>
                                <xsl:if test="not($allIDs//id[@root = $theOID] or $allTemplates//template[@id = $theOID])">
                                    <missingId oid="{$theOID}" type="id root" count="1"/>
                                </xsl:if>
                            </xsl:for-each-group>
                        </ids>
                    </xsl:variable>
                    <!-- List them -->
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <h3>
                                    <xsl:choose>
                                        <xsl:when test="count($missingIds/*/missingId) = 0">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">info</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">notice</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'compileTimeIssueMissingIdentifierDescriptionsFromDesignations'"/>
                                    </xsl:call-template>
                                </h3>
                            </div>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <xsl:choose>
                                <xsl:when test="count($missingIds/*/missingId) = 0">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="level" select="'info'"/>
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'issueNoMissingIdentifierDescriptionsFromDesignations'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table width="50%" border="0" cellspacing="2" cellpadding="2">
                                        <tr style="vertical-align: top;">
                                            <td class="tabtab">
                                                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                    <tr style="background-color: #FFCCCC;">
                                                        <td style="text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'OID'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td style="text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'Type'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td style="text-align: right;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'used'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                    </tr>
                                                    <xsl:for-each-group select="$missingIds/*/missingId" group-by="@oid">
                                                        <xsl:sort select="replace(replace(concat(@oid, '.'), '\.', '.0000000000'), '.0*([0-9]{9,})', '.$1')"/>
                                                        <xsl:variable name="theOID" select="@oid"/>
                                                        <tr>
                                                            <td>
                                                                <xsl:value-of select="$theOID"/>
                                                            </td>
                                                            <td>
                                                                <xsl:value-of select="@type"/>
                                                            </td>
                                                            <td style="text-align: right;">
                                                                <xsl:value-of select="count($missingIds/*/missingId[@oid = $theOID])"/>
                                                                <xsl:text>x</xsl:text>
                                                            </td>
                                                        </tr>
                                                    </xsl:for-each-group>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>
                    <!--  List of issue element present in any of the templates, show them -->
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <h3>
                                    <xsl:choose>
                                        <xsl:when test="count($allTemplates//issue) = 0">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">info</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">notice</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'listOfIssuesInTemplateSources'"/>
                                    </xsl:call-template>
                                </h3>
                            </div>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <xsl:choose>
                                <xsl:when test="count($allTemplates//issue) = 0">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="level" select="'info'"/>
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'issueNoIssuesDocumentedInTemplateSources'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table width="50%" border="0" cellspacing="2" cellpadding="2">
                                        <tr style="vertical-align: top;">
                                            <td class="tabtab">
                                                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                    <tr style="background-color: #FFCCCC;">
                                                        <td>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'listOfIssuesInTemplateSourcesNumber'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td>
                                                            <xsl:value-of select="count($allTemplates//issue)"/>
                                                        </td>
                                                    </tr>
                                                    <xsl:for-each select="$allTemplates//issue">
                                                        <tr style="vertical-align: top;">
                                                            <td colspan="2" class="tabtab">
                                                                <table border="0" cellspacing="2" cellpadding="2" width="100%">
                                                                    <tr>
                                                                        <td colspan="2" style="vertical-align: top;">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'compileTimeIssueReferencedInTemplate'"/>
                                                                            </xsl:call-template>
                                                                            <xsl:for-each select="(ancestor-or-self::template)[last()]">
                                                                                <xsl:choose>
                                                                                    <xsl:when test="@name and @id">
                                                                                        <xsl:value-of select="@name"/>
                                                                                        <xsl:call-template name="getMessage">
                                                                                            <xsl:with-param name="key" select="'xInBraces'"/>
                                                                                            <xsl:with-param name="p1" select="@id"/>
                                                                                        </xsl:call-template>
                                                                                    </xsl:when>
                                                                                    <xsl:otherwise>
                                                                                        <xsl:value-of select="@name"/>
                                                                                        <xsl:value-of select="@id"/>
                                                                                    </xsl:otherwise>
                                                                                </xsl:choose>
                                                                            </xsl:for-each>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td colspan="2" style="vertical-align: top;">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'pathWithColon'"/>
                                                                            </xsl:call-template>
                                                                            <xsl:for-each select="ancestor-or-self::element">
                                                                                <xsl:value-of select="@name"/>
                                                                                <xsl:if test="position() != last()">
                                                                                    <xsl:text>/</xsl:text>
                                                                                </xsl:if>
                                                                            </xsl:for-each>
                                                                        </td>
                                                                    </tr>
                                                                    <xsl:for-each select="tracking">
                                                                        <tr class="desclabel">
                                                                            <td style="width: 30px;">
                                                                                <xsl:call-template name="showStatusDot">
                                                                                    <xsl:with-param name="status" select="@statusCode"/>
                                                                                    <xsl:with-param name="title">
                                                                                        <xsl:call-template name="getXFormsLabel">
                                                                                            <xsl:with-param name="simpleTypeKey" select="'IssueStatusCodeLifeCycle'"/>
                                                                                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                                        </xsl:call-template>
                                                                                    </xsl:with-param>
                                                                                </xsl:call-template>
                                                                            </td>
                                                                            <td style="vertical-align: top;">
                                                                                <xsl:call-template name="showDate">
                                                                                    <xsl:with-param name="date" select="@effectiveDate"/>
                                                                                </xsl:call-template>
                                                                                <xsl:text>&#160;</xsl:text>
                                                                                <xsl:for-each select="author">
                                                                                    <xsl:value-of select="."/>
                                                                                    <xsl:if test="position() != last()">
                                                                                        <xsl:text> / </xsl:text>
                                                                                    </xsl:if>
                                                                                </xsl:for-each>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td/>
                                                                            <td>
                                                                                <xsl:call-template name="doDescription">
                                                                                    <xsl:with-param name="ns" select="desc"/>
                                                                                </xsl:call-template>
                                                                            </td>
                                                                        </tr>
                                                                    </xsl:for-each>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                    </xsl:for-each>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>
                    <!-- create a list of duplicate ids of concepts in a single dataset -->
                    <xsl:variable name="duplicateKeyIds">
                        <duplicates xmlns="">
                            <xsl:for-each-group select="$allDatasets/dataset//concept[not(ancestor::conceptList | ancestor::history)]" group-by="concat(@id, @effectiveDate)">
                                <xsl:variable name="cnt" select="count(current-group())"/>
                                <xsl:if test="$cnt gt 1">
                                    <xsl:for-each select="current-group()">
                                        <xsl:variable name="deid" select="@id"/>
                                        <xsl:variable name="deed" select="@effectiveDate"/>
                                        <xsl:variable name="dsid" select="ancestor::dataset/@id"/>
                                        <xsl:variable name="dsed" select="ancestor::dataset/@effectiveDate"/>
                                        <dup id="{$deid}" effectiveDate="{$deed}" dataset="{$dsid}" datasetEffectiveDate="{$dsed}" count="{$cnt}"/>
                                    </xsl:for-each>
                                </xsl:if>
                            </xsl:for-each-group>
                        </duplicates>
                    </xsl:variable>
                    <!-- List them -->
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <h3>
                                    <xsl:choose>
                                        <xsl:when test="count($duplicateKeyIds/*/dup) = 0">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">info</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">notice</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'duplicateKeyIdsInDataConcepts'"/>
                                    </xsl:call-template>
                                </h3>
                            </div>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <xsl:choose>
                                <xsl:when test="count($duplicateKeyIds/*/dup) = 0">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="level" select="'info'"/>
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'issueNoDuplicateKeyIdsInDataConcepts'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table width="50%" border="0" cellspacing="2" cellpadding="2">
                                        <tr style="vertical-align: top;">
                                            <td class="tabtab">
                                                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                    <tr style="background-color: #FFCCCC;">
                                                        <td style="text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'DuplicateId'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td style="text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'inDataSet'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td style="text-align: right;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'timesUsed'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                    </tr>
                                                    <xsl:for-each-group select="$duplicateKeyIds/*/dup" group-by="@id">
                                                        <xsl:sort select="replace(replace(concat(@id, '.'), '\.', '.0000000000'), '.0*([0-9]{9,})', '.$1')"/>
                                                        <tr>
                                                            <td>
                                                                <xsl:value-of select="@id"/>
                                                            </td>
                                                            <td>
                                                                <xsl:value-of select="@dataset"/>
                                                            </td>
                                                            <td style="text-align: right;">
                                                                <xsl:value-of select="@count"/>
                                                                <xsl:text>x</xsl:text>
                                                            </td>
                                                        </tr>
                                                    </xsl:for-each-group>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>
                    <!-- create a list of data types used that are NOT in supported data types -->
                    <xsl:variable name="missingDatatypes">
                        <dts xmlns="">
                            <xsl:for-each-group select="//element/@datatype" group-by="concat(., local:getTemplateFormat(ancestor::template[1]))">
                                <xsl:variable name="theDT" select="."/>
                                <xsl:variable name="theDTtype" select="local:getTemplateFormat(current-group()[1]/ancestor::template[1])" as="xs:string"/>
                                <xsl:variable name="theDTsupported" select="exists($supportedDatatypes/dt[@type = $theDTtype][@name = $theDT])" as="xs:boolean"/>
                                <dt name="{$theDT}" supported="{$theDTsupported}" count="{count(current-group())}"/>
                            </xsl:for-each-group>
                            <xsl:for-each-group select="//attribute/@datatype" group-by="concat(., local:getTemplateFormat(ancestor::template[1]))">
                                <xsl:variable name="theDT" select="."/>
                                <xsl:variable name="theDTtype" select="local:getTemplateFormat(ancestor::template[1])" as="xs:string"/>
                                <xsl:variable name="theDTsupported" select="exists($supportedAtomicDatatypes/dt[@type = $theDTtype][@name = $theDT])" as="xs:boolean"/>
                                <dt name="{$theDT}" supported="{$theDTsupported}" count="{count(current-group())}"/>
                            </xsl:for-each-group>
                        </dts>
                    </xsl:variable>
                    <!-- List them -->
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <h3>
                                    <xsl:choose>
                                        <xsl:when test="count($missingDatatypes/*/dt[@supported = 'false']) = 0">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">info</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">alert</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'compileTimeIssueDatatypeFlavors'"/>
                                    </xsl:call-template>
                                </h3>
                            </div>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <xsl:choose>
                                <xsl:when test="count($missingDatatypes/*/dt) = 0">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="level" select="'info'"/>
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'issueNoDatatypesOrDatatypeFlavorsUsed'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table width="50%" border="0" cellspacing="2" cellpadding="2">
                                        <tr style="vertical-align: top;">
                                            <td class="tabtab">
                                                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                    <tr style="background-color: #FFCCCC;">
                                                        <td style="text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'compileTimeIssueDatatypeHeading'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td style="text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'compileTimeIssueDatatypeDefined'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td style="text-align: right;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'compileTimeIssueDatatypeUsed'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                    </tr>
                                                    <xsl:for-each select="$missingDatatypes/*/dt">
                                                        <xsl:sort select="@name"/>
                                                        <xsl:variable name="theDT" select="@name"/>
                                                        <tr>
                                                            <xsl:if test="@supported != 'true'">
                                                                <xsl:attribute name="style" select="'background-color: #FFEEEE;'"/>
                                                            </xsl:if>
                                                            <td>
                                                                <xsl:choose>
                                                                    <xsl:when test="contains($theDT, '.')">
                                                                        <!-- indent a data type flavor -->
                                                                        <xsl:call-template name="repeatString">
                                                                            <xsl:with-param name="number" select="2"/>
                                                                            <xsl:with-param name="theString" select="'&#160;'"/>
                                                                        </xsl:call-template>
                                                                        <xsl:value-of select="$theDT"/>
                                                                    </xsl:when>
                                                                    <xsl:otherwise>
                                                                        <xsl:value-of select="$theDT"/>
                                                                    </xsl:otherwise>
                                                                </xsl:choose>
                                                            </td>
                                                            <td>
                                                                <xsl:choose>
                                                                    <xsl:when test="@supported = 'true'">
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'yes'"/>
                                                                        </xsl:call-template>
                                                                    </xsl:when>
                                                                    <xsl:otherwise>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'no'"/>
                                                                        </xsl:call-template>
                                                                    </xsl:otherwise>
                                                                </xsl:choose>
                                                            </td>
                                                            <td style="text-align: right;">
                                                                <xsl:value-of select="@count"/>
                                                                <xsl:text>x</xsl:text>
                                                            </td>
                                                        </tr>
                                                    </xsl:for-each>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>
                    <!-- create a list of references thru @ref anywhere that are not resolvable within this DECOR project. 
                        - Contains/Inherit from different project will not resolve by design
                        - Partial compilations will not all resolve by design, hence we skip those that have precalculated attributes because they were apparently resolved in compilation
                    -->
                    <xsl:variable name="refs">
                        <refs xmlns="">
                            <xsl:for-each-group select="$allDECOR//*[@ref][empty(@datasetId)][not(
                                self::codeSystem | 
                                ancestor::history | 
                                self::inherit[not(@prefix = $projectPrefix)] | 
                                self::relationship[not(@prefix = $projectPrefix)] |
                                self::contains[not(@prefix = $projectPrefix)] |
                                self::concept[parent::templateAssociation][not(@ident = $projectPrefix)] | 
                                ancestor-or-self::*[@statusCode = ('cancelled', 'rejected')]
                            )]" group-by="concat(@ref, (@flexibility, @effectiveDate)[. castable as xs:dateTime][1])">
                                <xsl:variable name="theRef" select="current-group()[1]/@ref"/>
                                <xsl:variable name="theCount" select="count($allDECOR//*[@id = $theRef][not(ancestor::history)] | $allDECOR//*[@name = $theRef][not(ancestor::history)] | $allDECOR//*[@root = $theRef][not(ancestor::history)])"/>
                                <xsl:if test="$theCount = 0">
                                    <ref ref="{$theRef}" count="{$theCount}">
                                        <xsl:choose>
                                            <xsl:when test="matches(string($theRef), '[1-9][0-9]*(\.[0-9]+)*')">
                                                <xsl:attribute name="type" select="'oid'"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:attribute name="type" select="'name'"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                        <xsl:for-each select="current-group()">
                                            <usage>
                                                <xsl:value-of select="string-join(ancestor-or-self::*/name(), '/')"/>
                                            </usage>
                                        </xsl:for-each>
                                    </ref>
                                </xsl:if>
                            </xsl:for-each-group>
                        </refs>
                    </xsl:variable>
                    <!-- List them -->
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <h3>
                                    <xsl:choose>
                                        <xsl:when test="empty($refs/*/ref)">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">info</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">notice</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'RefsWithoutId'"/>
                                    </xsl:call-template>
                                </h3>
                            </div>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <xsl:choose>
                                <xsl:when test="empty($refs/*/ref)">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="level" select="'info'"/>
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'issueNoIdForRef'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table width="50%" border="0" cellspacing="2" cellpadding="2">
                                        <tr style="vertical-align: top;">
                                            <td class="tabtab">
                                                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                    <tr style="background-color: #FFCCCC;">
                                                        <td style="text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'References'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                        <td>#</td>
                                                    </tr>
                                                    <xsl:for-each-group select="$refs/*/ref" group-by="@ref">
                                                        <xsl:sort select="replace(replace(concat(@ref, '.'), '\.', '.0000000000'), '.0*([0-9]{9,})', '.$1')"/>
                                                        <tr>
                                                            <td>
                                                                <xsl:value-of select="@ref"/>
                                                                <div>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'pathWithColon'"/>
                                                                    </xsl:call-template>
                                                                    <xsl:for-each select="usage">
                                                                        <xsl:value-of select="."/>
                                                                        <xsl:if test="position() != last()">
                                                                            <br/>
                                                                        </xsl:if>
                                                                    </xsl:for-each>
                                                                </div>
                                                            </td>
                                                            <td>
                                                                <xsl:value-of select="@count"/>
                                                            </td>
                                                        </tr>
                                                    </xsl:for-each-group>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>
                    <!-- create a list of concept/@ref within a representingTemplate that do not belong to the dataset stated in @sourceDataset -->
                    <xsl:variable name="conref" as="element(ref)*">
                        <xsl:for-each-group select="//representingTemplate[@sourceDataset][not(ancestor::*[@statusCode = ('cancelled', 'deprecated', 'rejected')])]" group-by="concat(@sourceDataset, @sourceDatasetFlexibility)">
                            <xsl:variable name="dsid" select="current-group()[1]/@sourceDataset"/>
                            <xsl:variable name="dsed" select="current-group()[1]/@sourceDatasetFlexibility"/>
                            <xsl:variable name="dataset" select="if ($dsid) then local:getDataset($dsid, $dsed) else ()" as="element()?"/>
                            <xsl:for-each select="current-group()">
                                <xsl:variable name="trid" select="ancestor::transaction[1]/@id"/>
                                <xsl:variable name="tred" select="ancestor::transaction[1]/@effectiveDate"/>
                                <xsl:variable name="thelabel" select="normalize-space(concat(@displayName, ' ', parent::transaction/name[@language = $defaultLanguage]))"/>
                                <xsl:for-each select="concept">
                                    <xsl:variable name="deid" select="@ref"/>
                                    <xsl:variable name="deed" select="@flexibility[not(. = 'dynamic')]"/>
                                    <xsl:variable name="concept" select="local:getConcept($deid, $deed, $dsid, $dsed)"/>
                                    <xsl:if test="empty($concept)">
                                        <xsl:variable name="alternativeDataset" as="element()*">
                                            <xsl:variable name="theConcept" select="$allDatasets//concept[@id = $deid]"/>
                                            <xsl:choose>
                                                <xsl:when test="$deed">
                                                    <xsl:copy-of select="$allDatasets//concept[@id = $deid][@effectiveDate = $deed]/ancestor::dataset"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:copy-of select="$allDatasets//concept[@id = $deid][@effectiveDate = max($theConcept/xs:dateTime(@effectiveDate))]/ancestor::dataset"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:variable>
                                        <ref ref="{$deid}" trid="{$trid}" tred="{$tred}" label="{$thelabel}" sourceDataset="{$dsid}" xmlns="">
                                            <xsl:if test="$deed">
                                                <xsl:attribute name="flexibility" select="$deed"/>
                                            </xsl:if>
                                            <xsl:if test="$dsed">
                                                <xsl:attribute name="sourceDatasetFlexibility" select="$dsed"/>
                                            </xsl:if>
                                            <xsl:if test="$dataset">
                                                <xsl:attribute name="datasetId" select="$dataset/@id"/>
                                                <xsl:attribute name="datasetEffectiveDate" select="$dataset/@effectiveDate"/>
                                                <xsl:attribute name="datasetName" select="($dataset/name[@language = $defaultLanguage], $dataset/name)[1]"/>
                                            </xsl:if>
                                            <xsl:if test="$alternativeDataset">
                                                <xsl:attribute name="locationId" select="$alternativeDataset/@id"/>
                                                <xsl:attribute name="locationEffectiveDate" select="$alternativeDataset/@effectiveDate"/>
                                                <xsl:attribute name="locationName" select="($alternativeDataset/name[@language = $defaultLanguage], $alternativeDataset/name)[1]"/>
                                            </xsl:if>
                                        </ref>
                                    </xsl:if>
                                </xsl:for-each>
                            </xsl:for-each>
                        </xsl:for-each-group>
                    </xsl:variable>
                    <!-- List them -->
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <h3>
                                    <xsl:choose>
                                        <xsl:when test="count($conref) = 0">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">info</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">notice</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'RepTemConceptsNotInSourceDataSet'"/>
                                    </xsl:call-template>
                                </h3>
                            </div>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <xsl:choose>
                                <xsl:when test="count($conref) = 0">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="level" select="'info'"/>
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'issueNoRepTemConceptsNotInSourceDataSet'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table width="50%" border="0" cellspacing="2" cellpadding="2">
                                        <tr style="vertical-align: top;">
                                            <td class="tabtab">
                                                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                    <tr style="background-color: #FFCCCC;">
                                                        <td style="text-align: left;" colspan="2">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'RepTemConceptsNotInSourceDataSet'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                    </tr>
                                                    <xsl:for-each-group select="$conref" group-by="concat(@trid, @tred)">
                                                        <xsl:sort select="replace(replace(concat(current-grouping-key(), '.'), '\.', '.0000000000'), '.0*([0-9]{9,})', '.$1')"/>
                                                        <xsl:variable name="trid" select="current-group()[1]/@trid"/>
                                                        <xsl:variable name="tred" select="current-group()[1]/@tred"/>
                                                        <xsl:variable name="trname" select="current-group()[1]/@label"/>
                                                        <xsl:variable name="dsid" select="current-group()[1]/@sourceDataset"/>
                                                        <xsl:variable name="dsed" select="current-group()[1]/@sourceDatasetFlexibility"/>
                                                        <xsl:variable name="dsname" select="current-group()[1]/@datasetName"/>
                                                        <tr style="background-color: #FFEEEE;">
                                                            <td style="text-align: left;" colspan="2">
                                                                <div>
                                                                    <b>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'Transaction'"/>
                                                                        </xsl:call-template>
                                                                        <xsl:text>: </xsl:text>
                                                                    </b>
                                                                    <xsl:value-of select="$trid"/>
                                                                    <xsl:text> </xsl:text>
                                                                    <i>
                                                                        <a href="{local:doHtmlName('TR', @trid, @tred, '.html')}" onclick="target='_blank';">
                                                                            <xsl:value-of select="normalize-space(@label)"/>
                                                                        </a>
                                                                    </i>
                                                                    <xsl:text> (</xsl:text>
                                                                    <xsl:value-of select="$tred"/>
                                                                    <xsl:text>)</xsl:text>
                                                                </div>
                                                                <div>
                                                                    <b>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'sourceDataSet'"/>
                                                                        </xsl:call-template>
                                                                        <xsl:text>: </xsl:text>
                                                                    </b>
                                                                    <xsl:value-of select="$dsid"/>
                                                                    <xsl:text> </xsl:text>
                                                                    <i>
                                                                        <xsl:value-of select="$dsname"/>
                                                                    </i>
                                                                    <xsl:text> (</xsl:text>
                                                                    <xsl:value-of select="$dsed"/>
                                                                    <xsl:text>)</xsl:text>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                        <xsl:for-each select="current-group()">
                                                            <xsl:sort select="replace(replace(concat(@ref, '.'), '\.', '.0000000000'), '.0*([0-9]{9,})', '.$1')"/>
                                                            <tr>
                                                                <td>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'conceptIdLabel'"/>
                                                                    </xsl:call-template>
                                                                    <xsl:value-of select="@ref"/>
                                                                </td>
                                                                <td>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'compileTimeIsNotInSourceDataset'"/>
                                                                    </xsl:call-template>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td>&#160;</td>
                                                                <td>
                                                                    <xsl:choose>
                                                                        <xsl:when test="@locationId">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'compileTimeButIsInDataset'"/>
                                                                            </xsl:call-template>
                                                                            <xsl:text>: </xsl:text>
                                                                            <xsl:value-of select="@locationId"/>
                                                                            <xsl:text> </xsl:text>
                                                                            <i>
                                                                                <a href="{local:doHtmlName('DS', $projectPrefix, @locationId, @locationEffectiveDate, @ref, @flexibility, (), (), '.html', false())}" onclick="target='_blank';">
                                                                                    <xsl:value-of select="@locationName"/>
                                                                                </a>
                                                                            </i>
                                                                            <xsl:text> (</xsl:text>
                                                                            <xsl:value-of select="@locationEffectiveDate"/>
                                                                            <xsl:text>)</xsl:text>
                                                                        </xsl:when>
                                                                        <xsl:otherwise>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'compileTimeIsInNoDataset'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:otherwise>
                                                                    </xsl:choose>
                                                                </td>
                                                            </tr>
                                                        </xsl:for-each>
                                                    </xsl:for-each-group>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <h3>
                                    <xsl:choose>
                                        <xsl:when test="count($allMissingLabels/*/missingCode) = 0">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">info</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">notice</xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'compileTimeIssueReferencedLabelNotDefined'"/>
                                    </xsl:call-template>
                                </h3>
                            </div>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <xsl:choose>
                                <xsl:when test="count($allMissingLabels/*/missingCode) = 0">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="level" select="'info'"/>
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'issueAllUsedIssueLabelWereDefined'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table width="50%" border="0" cellspacing="2" cellpadding="2">
                                        <tr style="vertical-align: top;">
                                            <td class="tabtab">
                                                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                    <tr style="background-color: #FFCCCC;">
                                                        <td style="text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'compileTimeIssueReferencedLabelNotDefined'"/>
                                                            </xsl:call-template>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <table width="100%">
                                                                <thead>
                                                                    <tr>
                                                                        <th>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'definedCode'"/>
                                                                            </xsl:call-template>
                                                                        </th>
                                                                        <th>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'Name'"/>
                                                                            </xsl:call-template>
                                                                        </th>
                                                                        <th>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'Issue'"/>
                                                                            </xsl:call-template>
                                                                        </th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody>
                                                                    <xsl:for-each select="$allMissingLabels/wrap/missingCode">
                                                                        <tr>
                                                                            <td>
                                                                                <xsl:value-of select="@labelCode"/>
                                                                            </td>
                                                                            <td>
                                                                                <xsl:value-of select="@refName"/>
                                                                            </td>
                                                                            <td>
                                                                                <xsl:call-template name="doShorthandId">
                                                                                    <xsl:with-param name="id" select="@ref"/>
                                                                                </xsl:call-template>
                                                                            </td>
                                                                        </tr>
                                                                    </xsl:for-each>
                                                                </tbody>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </div>
                    <div class="AccordionPanel">
                        <div class="AccordionPanelTab">
                            <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                <h3>
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which">info</xsl:with-param>
                                    </xsl:call-template>
                                    <!-- !!!! don't delete or replace this div as it is used by ADRAM -->
                                    <div class="transformationProtocolIcon" style="display:none;"/>
                                    <xsl:text> </xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'transformationProtocol'"/>
                                    </xsl:call-template>
                                    <!-- !!!! don't delete or replace this div as it is used by ADRAM -->
                                    <div class="transformationProtocolSummary" style="display:none;"/>
                                </h3>
                            </div>
                        </div>
                        <xsl:text>

</xsl:text>
                        <div class="AccordionPanelContent">
                            <!-- !!!! don't delete or replace these div lines as it is used by ADRAM -->
                            <code>Protocol not registered. <!--
                                <div class="transformationProtocolContent" style="display:none;"/>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'transformationProtocolNotRegistered'"/>
                                </xsl:call-template>
                                <div class="transformationProtocolContent" style="display:none;"/>
                                --></code>
                        </div>
                    </div>
                    <!-- indicate filtered/partial publication if filters on -->
                    <xsl:if test="$filtersfileavailable = true()">
                        <div class="AccordionPanel">
                            <div class="AccordionPanelTab">
                                <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                    <h3>
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">notice</xsl:with-param>
                                        </xsl:call-template>
                                        <xsl:text>&#160;</xsl:text>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'partialPublication'"/>
                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                        </xsl:call-template>
                                    </h3>
                                </div>
                            </div>
                            <xsl:text>

</xsl:text>
                            <div class="AccordionPanelContent">
                                <xsl:call-template name="showIcon">
                                    <xsl:with-param name="which">partialpublication</xsl:with-param>
                                </xsl:call-template>
                                <xsl:text>&#160;</xsl:text>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'partialPublicationInfolist'"/>
                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                    <xsl:with-param name="p1" select="doc($filtersfile)/*/normalize-space(@label)"/>
                                </xsl:call-template>
                                <p/>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'partialPublicationArtefactlist'"/>
                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                </xsl:call-template>
                                <ul>
                                    <xsl:for-each select="doc($filtersfile)/filters/*[name() = ('dataset', 'scenario', 'transaction', 'valueSet', 'template')]">
                                        <xsl:variable name="artefactlabel">
                                            <xsl:choose>
                                                <xsl:when test="name() = 'dataset'">Dataset</xsl:when>
                                                <xsl:when test="name() = 'scenario'">Scenario</xsl:when>
                                                <xsl:when test="name() = 'transaction'">Transaction</xsl:when>
                                                <xsl:when test="name() = 'valueSet'">valueSet</xsl:when>
                                                <xsl:when test="name() = 'template'">Template</xsl:when>
                                            </xsl:choose>
                                        </xsl:variable>
                                        <li>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="$artefactlabel"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                            <xsl:text> </xsl:text>
                                            <xsl:value-of select="@ref"/>
                                            <xsl:if test="string-length(@name) > 0">
                                                <xsl:text> (</xsl:text>
                                                <xsl:value-of select="@name"/>
                                                <xsl:text>)</xsl:text>
                                            </xsl:if>
                                        </li>
                                    </xsl:for-each>
                                </ul>
                            </div>
                        </div>
                    </xsl:if>
                </div>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabCompileTime'"/>
            <xsl:with-param name="actualcontent" select="$content8"/>
        </xsl:call-template>
    </xsl:template>
    <xsl:template name="doLegalTab">
        <!-- a little milestoning -->
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logINFO"/>
            <xsl:with-param name="msg">
                <xsl:text>*** Creating HTML For Legal Tab</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:variable name="content9">
            <div class="TabbedPanelsContent" xmlns="http://www.w3.org/1999/xhtml">
                <table width="50%" border="0" cellspacing="20" cellpadding="20">
                    <tr>
                        <td>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'licenseNoticeGPL'"/>
                            </xsl:call-template>
                            <a href="http://www.gnu.org/licenses/gpl.html">http://www.gnu.org/licenses/gpl.html</a>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'furtherContentToBeDetermined_1'"/>
                            </xsl:call-template>
                            <a href="https://art-decor.org">art-decor.org</a>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <a href="http://www.axialis.com/free/icons">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Icons'"/>
                                </xsl:call-template>
                            </a>
                            <xsl:text> </xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'by'"/>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <a href="http://www.axialis.com">Axialis Team</a>
                        </td>
                    </tr>
                </table>
            </div>
        </xsl:variable>
        <xsl:call-template name="doTabs4ThisTab">
            <xsl:with-param name="actualtab" select="'tabLegal'"/>
            <xsl:with-param name="actualcontent" select="$content9"/>
        </xsl:call-template>
    </xsl:template>
    <xsl:template name="doProjectInfo">
        <!--h3>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'tabProjectInfoProject'"/>
                    </xsl:call-template>
                </h3>
                <strong>
                    <xsl:call-template name="doName">
                        <xsl:with-param name="ns" select="//project/name"/>
                    </xsl:call-template>
                </strong-->
        <!--h3>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'tabProjectInfoDefaultLanguage'"/>
                    </xsl:call-template>
                </h3>
                <xsl:value-of select="//project/@defaultLanguage"/-->
        <xsl:choose>
            <xsl:when test="count(//project/desc[string-length(.) &gt; 0])">
                <!--h3>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'tabProjectInfoDescription'"/>
                    </xsl:call-template>
                </h3-->
                <xsl:call-template name="doDescription">
                    <xsl:with-param name="ns" select="//project/desc[string-length(.) &gt; 0]"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'tabProjectInfoMissing'"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:for-each select="(//project/license)[1]">
            <h3 xmlns="http://www.w3.org/1999/xhtml">
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'tabProjectInfoLicense'"/>
                </xsl:call-template>
            </h3>
            <table style="border: 0;" xmlns="http://www.w3.org/1999/xhtml">
                <tr>
                    <td>
                        <xsl:variable name="licenseCode" select="@code"/>
                        <xsl:variable name="licenseDisplayName" select="@displayName"/>
                        <xsl:value-of select="$licenseCode"/>
                        <xsl:text> - </xsl:text>
                        <xsl:choose>
                            <xsl:when test="$licenseDisplayName">
                                <xsl:value-of select="$licenseDisplayName"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="getXFormsLabel">
                                    <xsl:with-param name="simpleTypeKey" select="'LicenseTypes'"/>
                                    <xsl:with-param name="simpleTypeValue" select="$licenseCode"/>
                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                </tr>
            </table>
        </xsl:for-each>
        <h3 xmlns="http://www.w3.org/1999/xhtml">
            <xsl:call-template name="getMessage">
                <xsl:with-param name="key" select="'tabProjectInfoAdditional'"/>
            </xsl:call-template>
        </h3>
        <table style="border: 0;" xmlns="http://www.w3.org/1999/xhtml">
            <tr>
                <td class="tabtab">
                    <table width="100%" border="0" cellspacing="3" cellpadding="2">
                        <xsl:if test="$projectIsRepository or $projectIsPrivate">
                            <tr>
                                <th style="text-align: left;" colspan="2">
                                    <xsl:call-template name="doPrivateRepositoryNotice"/>
                                </th>
                            </tr>
                        </xsl:if>
                        <tr class="headinglabel">
                            <th style="text-align: left;" colspan="2">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Properties'"/>
                                </xsl:call-template>
                            </th>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <span style="margin-right: 20px">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Prefix'"/>
                                    </xsl:call-template>
                                    <xsl:text>: </xsl:text>
                                    <xsl:value-of select="$projectPrefix"/>
                                </span>
                                <span style="margin-right: 20px">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'tabProjectInfoDefaultLanguage'"/>
                                    </xsl:call-template>
                                    <xsl:text>: </xsl:text>
                                    <xsl:value-of select="//project/@defaultLanguage"/>
                                </span>
                                <xsl:if test="$projectIsRepository">
                                    <span style="margin-right: 20px; font-weight: bold;">
                                        <xsl:attribute name="title">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Is-repository-hint'"/>
                                            </xsl:call-template>
                                        </xsl:attribute>
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">repository</xsl:with-param>
                                            <xsl:with-param name="style">margin: 0px 5px;</xsl:with-param>
                                        </xsl:call-template>
                                        <xsl:text> </xsl:text>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Is-repository'"/>
                                        </xsl:call-template>
                                    </span>
                                </xsl:if>
                                <xsl:if test="$projectIsPrivate">
                                    <span style="margin-right: 20px; font-weight: bold;">
                                        <xsl:attribute name="title">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Is-private-hint'"/>
                                            </xsl:call-template>
                                        </xsl:attribute>
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">notice</xsl:with-param>
                                            <xsl:with-param name="style">margin: 0px 5px;</xsl:with-param>
                                        </xsl:call-template>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Is-private'"/>
                                        </xsl:call-template>
                                    </span>
                                </xsl:if>
                                <xsl:if test="$projectIsExperimental">
                                    <span style="font-weight: bold;">
                                        <xsl:attribute name="title">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Is-experimental-hint'"/>
                                            </xsl:call-template>
                                        </xsl:attribute>
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">experimental</xsl:with-param>
                                            <xsl:with-param name="style">margin: 0px 5px;</xsl:with-param>
                                        </xsl:call-template>
                                        <xsl:text> </xsl:text>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Is-experimental'"/>
                                        </xsl:call-template>
                                    </span>
                                </xsl:if>
                            </td>
                        </tr>
                        <tr class="headinglabel">
                            <th style="text-align: left; width: 50%;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'publication-location'"/>
                                </xsl:call-template>
                            </th>
                            <th style="text-align: left; width: 50%;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'project-overview'"/>
                                </xsl:call-template>
                            </th>
                        </tr>
                        <tr>
                            <td>
                                <a href="{$seeURLprefix}">
                                    <xsl:value-of select="$seeURLprefix"/>
                                </a>
                            </td>
                            <td>
                                <a href="{$projectRestUri}">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'project-index'"/>
                                    </xsl:call-template>
                                </a>
                            </td>
                        </tr>
                        <tr class="headinglabel">
                            <th style="text-align: left;" colspan="2">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'tabProjectInfoDisclaimer'"/>
                                </xsl:call-template>
                            </th>
                        </tr>
                        <tr>
                            <td style="text-align: left;" colspan="2">
                                <xsl:copy-of select="$disclaimer"/>
                            </td>
                        </tr>
                        <xsl:if test="//project/author">
                            <tr class="headinglabel">
                                <th style="text-align: left;" colspan="2">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'tabProjectInfoAuthorList'"/>
                                    </xsl:call-template>
                                </th>
                            </tr>
                            <tr>
                                <td style="text-align: left;" colspan="2">
                                    <ul>
                                        <xsl:variable name="now" select="current-dateTime()"/>
                                        <xsl:for-each select="//project/author">
                                            <li>
                                                <xsl:if test="@expirationDate &lt; $now">
                                                    <xsl:attribute name="style">color: grey;</xsl:attribute>
                                                </xsl:if>
                                                <xsl:value-of select="."/>
                                            </li>
                                        </xsl:for-each>
                                    </ul>
                                </td>
                            </tr>
                        </xsl:if>
                    </table>
                </td>
            </tr>
        </table>
        <h3 xmlns="http://www.w3.org/1999/xhtml">
            <xsl:call-template name="getMessage">
                <xsl:with-param name="key" select="'tabProjectInfoVersionInfo'"/>
            </xsl:call-template>
        </h3>
        <table width="100%" border="0" xmlns="http://www.w3.org/1999/xhtml">
            <tr>
                <td class="tabtab">
                    <table width="100%" border="0" cellspacing="3" cellpadding="2">
                        <tr class="headinglabel">
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'tabProjectInfoAuthorDate'"/>
                                </xsl:call-template>
                            </th>
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'tabProjectInfoAuthorBy'"/>
                                </xsl:call-template>
                            </th>
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'tabProjectInfoAuthorDescription'"/>
                                </xsl:call-template>
                            </th>
                        </tr>
                        <xsl:for-each select="//project/version | //project/release">
                            <xsl:sort select="@date" order="descending"/>
                            <xsl:choose>
                                <xsl:when test="name() = 'release'">
                                    <tr>
                                        <xsl:if test="position() = 1">
                                            <xsl:attribute name="id">_current</xsl:attribute>
                                        </xsl:if>
                                        <th style="vertical-align: top;">
                                            <xsl:variable name="theAnchor" select="concat('_', replace(@date, '[^\d]', ''))"/>
                                            <xsl:attribute name="id" select="$theAnchor"/>
                                            <a href="#{$theAnchor}">
                                                <xsl:attribute name="title">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'direct-link-to-self'"/>
                                                    </xsl:call-template>
                                                </xsl:attribute>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="@date"/>
                                                </xsl:call-template>
                                            </a>
                                        </th>
                                        <th style="vertical-align: top;">
                                            <xsl:value-of select="@by"/>
                                        </th>
                                        <td style="vertical-align: top;">
                                            <b>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'tabProjectInfoReleaseLabel'"/>
                                                </xsl:call-template>
                                                <xsl:if test="@versionLabel">
                                                    <xsl:text>: </xsl:text>
                                                    <xsl:value-of select="@versionLabel"/>
                                                </xsl:if>
                                            </b>
                                            <br/>
                                            <xsl:call-template name="doDescription">
                                                <xsl:with-param name="ns" select="desc | note"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:when>
                                <xsl:otherwise>
                                    <tr>
                                        <td style="vertical-align: top;">
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="@date"/>
                                            </xsl:call-template>
                                        </td>
                                        <td style="vertical-align: top;">
                                            <xsl:value-of select="@by"/>
                                        </td>
                                        <td style="vertical-align: top;">
                                            <xsl:call-template name="doDescription">
                                                <xsl:with-param name="ns" select="desc"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:for-each>
                    </table>
                </td>
            </tr>
        </table>
    </xsl:template>
    <xsl:template name="doPrivateRepositoryNotice">
        <xsl:variable name="projectIsRepository" select="$allDECOR[string(@repository) = 'true']"/>
        <xsl:variable name="projectIsPrivate" select="$allDECOR[string(@private) = 'true']"/>
        <xsl:choose>
            <xsl:when test="$projectIsRepository and $projectIsPrivate">
                <xsl:call-template name="showIcon">
                    <xsl:with-param name="which">notice</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'noticeIsPrivateRepository'"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$projectIsRepository">
                <xsl:call-template name="showIcon">
                    <xsl:with-param name="which">notice</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'noticeIsRepository'"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$projectIsPrivate">
                <xsl:call-template name="showIcon">
                    <xsl:with-param name="which">notice</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'noticeIsPrivate'"/>
                </xsl:call-template>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="doDataset">
        <xsl:param name="nestingWithTables" select="true()"/>
        <xsl:param name="dsid" as="xs:string?"/>
        <xsl:param name="dsed" as="xs:string?"/>
        <xsl:param name="trid" as="xs:string?"/>
        <xsl:param name="tred" as="xs:string?"/>
        <xsl:param name="id" select="$dsid, $trid" as="xs:string?"/>
        <xsl:param name="effectiveDate" select="$dsed, $tred" as="xs:string?"/>
        <xsl:param name="versionLabel" select="@versionLabel" as="xs:string?"/>
        <xsl:param name="expirationDate" select="@expirationDate" as="xs:string?"/>
        <xsl:param name="statusCode" select="@statusCode" as="xs:string?"/>
        <!-- show dataset meta data -->
        <table width="100%" border="0" cellspacing="3" cellpadding="2" xmlns="http://www.w3.org/1999/xhtml">
            <tr class="headinglabel">
                <th style="text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Name'"/>
                    </xsl:call-template>
                </th>
                <th style="text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Id'"/>
                    </xsl:call-template>
                </th>
            </tr>
            <tr>
                <td style="text-align: left;">
                    <xsl:call-template name="showStatusDot">
                        <xsl:with-param name="status" select="$statusCode"/>
                        <xsl:with-param name="title">
                            <xsl:call-template name="getXFormsLabel">
                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                <xsl:with-param name="simpleTypeValue" select="$statusCode"/>
                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                            </xsl:call-template>
                        </xsl:with-param>
                    </xsl:call-template>
                    <xsl:text>&#160;</xsl:text>
                    <xsl:call-template name="doName">
                        <xsl:with-param name="ns" select="name"/>
                    </xsl:call-template>
                    <xsl:if test="$versionLabel">
                        <xsl:text> (</xsl:text>
                        <xsl:value-of select="$versionLabel"/>
                        <xsl:text>)</xsl:text>
                    </xsl:if>
                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                </td>
                <td style="text-align: left; vertical-align: top;">
                    <xsl:value-of select="$id"/>
                </td>
            </tr>
            <tr class="headinglabel">
                <th style="text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'EffectiveDate'"/>
                    </xsl:call-template>
                </th>
                <th style="text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'ExpirationDate'"/>
                    </xsl:call-template>
                </th>
            </tr>
            <tr>
                <td style="text-align: left;">
                    <xsl:call-template name="showDate">
                        <xsl:with-param name="date" select="$effectiveDate"/>
                    </xsl:call-template>
                </td>
                <td style="text-align: left; vertical-align: top;">
                    <xsl:call-template name="showDate">
                        <xsl:with-param name="date" select="$expirationDate"/>
                    </xsl:call-template>
                </td>
            </tr>
            <xsl:if test="actors/actor">
                <tr>
                    <th style="text-align: left; vertical-align: top;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Actor'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;">
                        <xsl:for-each select="actors/actor">
                            <xsl:variable name="aid" select="@id"/>
                            <xsl:variable name="theActor" select="$allActors//actor[@id = $aid]"/>
                            <div>
                                <xsl:attribute name="title">
                                    <xsl:call-template name="doDescription">
                                        <xsl:with-param name="ns" select="$theActor/desc"/>
                                    </xsl:call-template>
                                </xsl:attribute>
                                <xsl:choose>
                                    <xsl:when test="@role = ('sender', 'receiver')">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="concat('actorRole-', @role)"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="@role"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                                <xsl:text> (</xsl:text>
                                <xsl:choose>
                                    <xsl:when test="$theActor/@type = ('device', 'person', 'organization')">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="concat('actorType-', $theActor/@type)"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="$theActor/@type"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                                <xsl:text>) </xsl:text>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="$theActor/name"/>
                                </xsl:call-template>
                                <xsl:for-each select="$theActor/relationship">
                                    <xsl:variable name="theRefActorId" select="@ref"/>
                                    <xsl:variable name="theRefActor" select="$allActors//actor[@id = $theRefActorId]"/>
                                    <xsl:text> - </xsl:text>
                                    <xsl:call-template name="getXFormsLabel">
                                        <xsl:with-param name="simpleTypeKey" select="'RelationshipTypes'"/>
                                        <xsl:with-param name="simpleTypeValue" select="@type"/>
                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <xsl:choose>
                                        <xsl:when test="$theRefActor">
                                            <xsl:call-template name="doName">
                                                <xsl:with-param name="ns" select="$theRefActor/name"/>
                                            </xsl:call-template>
                                            <i>
                                                <xsl:text> (</xsl:text>
                                                <xsl:value-of select="$theRefActor/@type"/>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'fromLabel'"/>
                                                </xsl:call-template>
                                                <xsl:choose>
                                                    <xsl:when test="$theRefActor/@ident[not(. = $projectPrefix)]">
                                                        <xsl:value-of select="$theRefActor/@ident"/>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'this project'"/>
                                                        </xsl:call-template>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                                <xsl:text>)</xsl:text>
                                            </i>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">alert</xsl:with-param>
                                                <xsl:with-param name="tooltip">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'compileTimeObjectReferenceTargetMissing'"/>
                                                    </xsl:call-template>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                            <xsl:value-of select="$theRefActorId"/>
                                            <xsl:call-template name="logMessage">
                                                <xsl:with-param name="level" select="$logERROR"/>
                                                <xsl:with-param name="msg">
                                                    <xsl:text>+++ Could not find referenced actor id='</xsl:text>
                                                    <xsl:value-of select="$theRefActorId"/>
                                                    <xsl:text>' referenced from relationship in actor '</xsl:text>
                                                    <xsl:call-template name="doDescription">
                                                        <xsl:with-param name="ns" select="name"/>
                                                    </xsl:call-template>
                                                    <xsl:text>' (</xsl:text>
                                                    <xsl:value-of select="@id"/>
                                                    <xsl:text>). This might be due to it being in a different project/BBR or because the reference is broken.</xsl:text>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:for-each>
                            </div>
                        </xsl:for-each>
                    </td>
                </tr>
            </xsl:if>
            <tr class="headinglabel">
                <th style="text-align: left; vertical-align: top;" colspan="2">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Description'"/>
                    </xsl:call-template>
                </th>
            </tr>
            <tr>
                <td style="text-align: left;" colspan="2">
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="desc"/>
                    </xsl:call-template>
                </td>
            </tr>
            <xsl:if test="trigger">
                <tr class="headinglabel">
                    <th style="text-align: left; vertical-align: top;" colspan="2">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'transactionTrigger'"/>
                        </xsl:call-template>
                    </th>
                </tr>
                <tr>
                    <td style="text-align: left;" colspan="2">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="trigger"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="condition">
                <tr class="headinglabel">
                    <th style="text-align: left; vertical-align: top;" colspan="2">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'transactionCondition'"/>
                        </xsl:call-template>
                    </th>
                </tr>
                <tr>
                    <td style="text-align: left;" colspan="2">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="condition"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- <relationship type="SPEC" ref="2.16.840.1.113883.2.4.3.11.60.40.1.10.1.1" flexibility="2015-04-01T00:00:00"/> -->
            <xsl:if test="property">
                <xsl:variable name="theProperties" as="element()">
                    <table class="zebra-table" width="100%">
                        <xsl:for-each select="property">
                            <xsl:variable name="ref" select="@ref"/>
                            <xsl:variable name="flex" select="@flexibility"/>
                            <tr>
                                <td style="text-align: left; background-color: #F6F3EE;">
                                    <xsl:value-of select="@name"/>
                                </td>
                                <td>
                                    <xsl:copy-of select="node()"/>
                                </td>
                            </tr>
                        </xsl:for-each>
                    </table>
                </xsl:variable>
                <tr>
                    <td colspan="2">
                        <table class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                            <tr class="desclabel" data-tt-id="property-{generate-id(.)}">
                                <td class="togglertreetable" style="height: 1.5em;">
                                    <span class="expcaption">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Properties'"/>
                                        </xsl:call-template>
                                    </span>
                                </td>
                            </tr>
                            <tr data-tt-id="propertyBody-{generate-id(.)}" data-tt-parent-id="property-{generate-id(.)}">
                                <td>
                                    <xsl:copy-of select="$theProperties"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="relationship">
                <tr>
                    <th style="text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Relationship'"/>
                        </xsl:call-template>
                    </th>
                    <td>
                        <table class="zebra-table" width="100%">
                            <xsl:for-each select="relationship">
                                <xsl:variable name="ref" select="@ref"/>
                                <xsl:variable name="flex" select="@flexibility"/>
                                <tr>
                                    <td>
                                        <xsl:call-template name="getXFormsLabel">
                                            <xsl:with-param name="simpleTypeKey" select="'RelationshipTypes'"/>
                                            <xsl:with-param name="simpleTypeValue" select="@type"/>
                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                        </xsl:call-template>
                                    </td>
                                    <td>
                                        <xsl:variable name="dataset" select="
                                                if ($ref) then
                                                    local:getDataset($ref, $flex)
                                                else
                                                    ()" as="element(dataset)*"/>
                                        <xsl:variable name="dsed">
                                            <xsl:choose>
                                                <xsl:when test="$flex castable as xs:dateTime">
                                                    <xsl:value-of select="$flex"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:value-of select="$dataset[1]/@effectiveDate"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:variable>
                                        <xsl:variable name="dstext" as="xs:string*">
                                            <xsl:choose>
                                                <xsl:when test="$dataset[@iddisplay]">
                                                    <xsl:value-of select="($dataset/@iddisplay)[1]"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="doShorthandId">
                                                        <xsl:with-param name="id" select="$ref"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            <xsl:text> - </xsl:text>
                                            <xsl:choose>
                                                <xsl:when test="matches(@flexibility, '^\d{4}')">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="$flex"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:variable>
                                        <xsl:choose>
                                            <xsl:when test="$dataset">
                                                <a href="{local:doHtmlName('DS',$dataset[1]/@id,$dsed,'.html')}" onclick="target='_blank';">
                                                    <xsl:call-template name="doName">
                                                        <xsl:with-param name="ns" select="$dataset[1]/name"/>
                                                    </xsl:call-template>
                                                </a>
                                                <i>
                                                    <xsl:text> (</xsl:text>
                                                    <xsl:value-of select="string-join($dstext, '')"/>
                                                    <xsl:text>)</xsl:text>
                                                </i>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="string-join($dstext, '')"/>
                                                <xsl:call-template name="logMessage">
                                                    <xsl:with-param name="level" select="$logDEBUG"/>
                                                    <xsl:with-param name="msg">
                                                        <xsl:text>+++ Could not find referenced dataset id='</xsl:text>
                                                        <xsl:value-of select="$ref"/>
                                                        <xsl:text>' referenced from relationship in dataset '</xsl:text>
                                                        <xsl:call-template name="doDescription">
                                                            <xsl:with-param name="ns" select="../name"/>
                                                        </xsl:call-template>
                                                        <xsl:text>' (</xsl:text>
                                                        <xsl:value-of select="../@id"/>
                                                        <xsl:text> - </xsl:text>
                                                        <xsl:value-of select="../@effectiveDate"/>
                                                        <xsl:text>). This might be due to it being in a different project/BBR or because the ref/effectiveDate is broken.</xsl:text>
                                                    </xsl:with-param>
                                                </xsl:call-template>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </td>
                                </tr>
                            </xsl:for-each>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="source">
                <tr class="headinglabel">
                    <th style="text-align: left;" colspan="2">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Source'"/>
                        </xsl:call-template>
                    </th>
                </tr>
                <tr>
                    <td style="text-align: left;" colspan="2">
                        <xsl:value-of select="source"/>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="rationale">
                <tr class="headinglabel">
                    <th style="text-align: left;" colspan="2">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Rationale'"/>
                        </xsl:call-template>
                    </th>
                </tr>
                <tr>
                    <td style="text-align: left;" colspan="2">
                        <xsl:value-of select="rationale"/>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="operationalization">
                <tr class="headinglabel">
                    <th style="text-align: left;" colspan="2">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Operationalizations'"/>
                        </xsl:call-template>
                    </th>
                </tr>
                <tr>
                    <td style="text-align: left;" colspan="2">
                        <xsl:value-of select="operationalization"/>
                    </td>
                </tr>
            </xsl:if>
            <!--
            <tr class="headinglabel">
                <th style="text-align: left;" colspan="2">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'contentWithColon'"/>
                    </xsl:call-template>
                </th>
            </tr>
            -->
            <xsl:if test="copyright">
                <tr class="headinglabel">
                    <th style="text-align: left; vertical-align: top;" colspan="2">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Copyright'"/>
                        </xsl:call-template>
                    </th>
                </tr>
                <tr>
                    <td style="text-align: left;" colspan="2">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="copyright"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="publishingAuthority">
                <xsl:apply-templates select="publishingAuthority | endorsingauthority">
                    <xsl:with-param name="headerLabel" select="'headinglabel'"/>
                    <xsl:with-param name="colspan" select="2"></xsl:with-param>
                </xsl:apply-templates>
            </xsl:if>
        </table>
        <xsl:if test="count(concept) = 0">
            <table style="border: 0;">
                <xsl:call-template name="doMessage">
                    <xsl:with-param name="level" select="'info'"/>
                    <xsl:with-param name="msg">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'issueNoUnderlyingModelWithThisScenarioTransactionDefinedYet'"/>
                        </xsl:call-template>
                    </xsl:with-param>
                </xsl:call-template>
            </table>
        </xsl:if>
        <xsl:if test="$switchCreateTreeTableHtml = 'true'">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <button id="expandAll" type="button">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'buttonExpandAll'"/>
                    </xsl:call-template>
                </button>
                <button id="collapseAll" type="button">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                    </xsl:call-template>
                </button>
                <input id="nameSearch">
                    <xsl:attribute name="placeholder">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'textSearch'"/>
                        </xsl:call-template>
                    </xsl:attribute>
                </input>
                <select id="hiddenColumns">
                    <option value="title">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'showColumn'"/>
                        </xsl:call-template>
                    </option>
                    <option value="columnDetails" disabled="disabled">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Details'"/>
                        </xsl:call-template>
                    </option>
                </select>
            </div>
        </xsl:if>
        <table id="transactionTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2" xmlns="http://www.w3.org/1999/xhtml">
            <tr>
                <th class="columnName" style="text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Name'"/>
                    </xsl:call-template>
                </th>
                <th class="columnDetails" style="text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Details'"/>
                    </xsl:call-template>
                    <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                        <xsl:text>&#160;</xsl:text>
                        <span class="hideMe" type="button">[‑]</span>
                    </xsl:if>
                </th>
                <th class="columnNoPrint"/>
            </tr>
            <xsl:apply-templates select="concept" mode="dataset">
                <xsl:with-param name="level" select="1"/>
                <xsl:with-param name="dsid" select="$dsid"/>
                <xsl:with-param name="dsed" select="$dsed"/>
                <xsl:with-param name="trid" select="$trid"/>
                <xsl:with-param name="tred" select="$tred"/>
            </xsl:apply-templates>
        </table>
    </xsl:template>
    <xsl:template name="doScenarios">
        <xsl:variable name="node-id-sc" select="generate-id(.)"/>
        <!-- show dataset meta data -->
        <tr data-tt-id="{$node-id-sc}" xmlns="http://www.w3.org/1999/xhtml">
            <td class="togglertreetable columnName" colspan="3">
                <xsl:call-template name="showStatusDot">
                    <xsl:with-param name="status" select="@statusCode"/>
                    <xsl:with-param name="title">
                        <xsl:call-template name="getXFormsLabel">
                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                        </xsl:call-template>
                    </xsl:with-param>
                </xsl:call-template>
                <xsl:text>&#160;</xsl:text>
                <xsl:call-template name="doName">
                    <xsl:with-param name="ns" select="name"/>
                </xsl:call-template>
                <div style="float: right;">
                    <xsl:call-template name="doShorthandId">
                        <xsl:with-param name="id" select="@id"/>
                    </xsl:call-template>
                </div>
            </td>
        </tr>
        <!-- ==== Generics for scenario ==== -->
        <!-- id / versionLabel / effectiveDate / expirationDate -->
        <tr data-tt-id="{$node-id-sc}-meta" data-tt-parent-id="{$node-id-sc}" xmlns="http://www.w3.org/1999/xhtml">
            <td class="columnDetails"/>
            <td class="columnDetails" colspan="2">
                <table border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="strong" style="padding-left: 0;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'EffectiveDate'"/>
                            </xsl:call-template>
                        </td>
                        <td>
                            <xsl:call-template name="showDate">
                                <xsl:with-param name="date" select="@effectiveDate"/>
                            </xsl:call-template>
                            <xsl:if test="@versionLabel">
                                <xsl:text> - </xsl:text>
                                <xsl:value-of select="@versionLabel"/>
                            </xsl:if>
                        </td>
                        <xsl:if test="@expirationDate">
                            <td class="strong">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'ExpirationDate'"/>
                                </xsl:call-template>
                            </td>
                            <td>
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="@expirationDate"/>
                                </xsl:call-template>
                            </td>
                        </xsl:if>
                    </tr>
                </table>
            </td>
        </tr>
        <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
            <tr data-tt-id="{$node-id-sc}-desc" data-tt-parent-id="{$node-id-sc}" xmlns="http://www.w3.org/1999/xhtml">
                <td class="columnDetails"/>
                <td class="columnDetails strong" style="vertical-align: top; width: 5%;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Description'"/>
                    </xsl:call-template>
                </td>
                <td class="columnDetails">
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="desc"/>
                    </xsl:call-template>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="trigger">
            <tr data-tt-id="{$node-id-sc}-trigger" data-tt-parent-id="{$node-id-sc}" xmlns="http://www.w3.org/1999/xhtml">
                <td class="columnDetails"/>
                <td class="columnDetails strong" style="vertical-align: top; width: 5%;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'scenarioTrigger'"/>
                    </xsl:call-template>
                </td>
                <td class="columnDetails">
                    <xsl:if test="trigger[@id]">
                        <div>
                            <span class="strong">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Id'"/>
                                </xsl:call-template>
                            </span>
                            <xsl:text>: </xsl:text>
                            <xsl:value-of select="trigger/@id[1]"/>
                        </div>
                    </xsl:if>
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="trigger"/>
                    </xsl:call-template>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="condition">
            <tr data-tt-id="{$node-id-sc}-condition" data-tt-parent-id="{$node-id-sc}" xmlns="http://www.w3.org/1999/xhtml">
                <td class="columnDetails"/>
                <td class="columnDetails strong" style="vertical-align: top; width: 5%;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'scenarioCondition'"/>
                    </xsl:call-template>
                </td>
                <td class="columnDetails">
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="condition"/>
                    </xsl:call-template>
                </td>
            </tr>
        </xsl:if>
        <xsl:apply-templates select="transaction"/>
    </xsl:template>
    <xsl:template name="doIdentifiers">
        <h2 xmlns="http://www.w3.org/1999/xhtml">
            <a name="labelIdentifiers"/>
            <xsl:call-template name="getMessage">
                <xsl:with-param name="key" select="'tabIdentifiersTitleString'"/>
            </xsl:call-template>
        </h2>
        <p xmlns="http://www.w3.org/1999/xhtml">
            <xsl:call-template name="getMessage">
                <xsl:with-param name="key" select="'tabIdentifiersRenderingRemark'"/>
            </xsl:call-template>
        </p>
        <div id="Accordionid" class="Accordion" xmlns="http://www.w3.org/1999/xhtml">
            <xsl:for-each select="$allIDs/id">
                <xsl:sort select="@root"/>
                <xsl:variable name="theRoot" select="@root"/>
                <div class="AccordionPanel">
                    <div class="AccordionPanelTab">
                        <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                            <h3>
                                <xsl:choose>
                                    <xsl:when test="count(designation[@language = $defaultLanguage]) &gt; 0">
                                        <i>
                                            <xsl:value-of select="designation[@language = $defaultLanguage]/@displayName"/>
                                        </i>
                                    </xsl:when>
                                    <!-- Do we have en-US at all? -->
                                    <xsl:when test="count(designation[@language = 'en-US']) &gt; 0">
                                        <i>
                                            <xsl:value-of select="designation[@language = 'en-US']/@displayName"/>
                                        </i>
                                    </xsl:when>
                                    <xsl:when test="count(designation[@language = 'en-EN']) &gt; 0">
                                        <i>
                                            <xsl:value-of select="designation[@language = 'en-EN']/@displayName"/>
                                        </i>
                                    </xsl:when>
                                </xsl:choose>
                                <xsl:text>&#160;</xsl:text>
                                <xsl:value-of select="$theRoot"/>
                            </h3>
                        </div>
                    </div>
                    <div class="AccordionPanelContent">
                        <table border="0" cellspacing="10">
                            <tr>
                                <td class="tabtab">
                                    <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                        <tr class="headinglabel" style="vertical-align: top;">
                                            <th style="text-align: left;">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'idLanguage'"/>
                                                </xsl:call-template>
                                            </th>
                                            <th style="text-align: left;">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'DisplayName'"/>
                                                </xsl:call-template>
                                            </th>
                                            <th style="vertical-align: top; text-align: left;">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Description'"/>
                                                </xsl:call-template>
                                            </th>
                                            <xsl:if test="designation[@type | @preferredForLanguage]">
                                                <th style="text-align: left;">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'Type'"/>
                                                    </xsl:call-template>
                                                </th>
                                            </xsl:if>
                                        </tr>
                                        <xsl:for-each select="designation">
                                            <tr>
                                                <td>
                                                    <xsl:value-of select="@language"/>
                                                </td>
                                                <td>
                                                    <xsl:value-of select="@displayName"/>
                                                </td>
                                                <td>
                                                    <xsl:value-of select="text()"/>
                                                </td>
                                                <xsl:if test="../designation[@type | @preferredForLanguage]">
                                                    <td>
                                                        <xsl:choose>
                                                            <xsl:when test="@preferredForLanguage = 'true' or @type = 'preferred'">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'idPreferred'"/>
                                                                </xsl:call-template>
                                                            </xsl:when>
                                                            <xsl:when test="@type = 'synonym'">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'idSynonym'"/>
                                                                </xsl:call-template>
                                                            </xsl:when>
                                                            <xsl:when test="@type = 'abbreviation'">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'idAbbreviation'"/>
                                                                </xsl:call-template>
                                                            </xsl:when>
                                                            <xsl:when test="not(@type)"/>
                                                            <xsl:otherwise>
                                                                <xsl:call-template name="logMessage">
                                                                    <xsl:with-param name="level" select="$logFATAL"/>
                                                                    <xsl:with-param name="msg">
                                                                        <xsl:text>+++ Internal XSL error: unsupported id[@root="</xsl:text>
                                                                        <xsl:value-of select="$theRoot"/>
                                                                        <xsl:text>"]/designation/@type="</xsl:text>
                                                                        <xsl:value-of select="@type"/>
                                                                        <xsl:text>"</xsl:text>
                                                                    </xsl:with-param>
                                                                </xsl:call-template>
                                                            </xsl:otherwise>
                                                        </xsl:choose>
                                                    </td>
                                                </xsl:if>
                                            </tr>
                                        </xsl:for-each>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </xsl:for-each>
        </div>
        <h2 xmlns="http://www.w3.org/1999/xhtml">
            <xsl:call-template name="getMessage">
                <xsl:with-param name="key" select="'listOfTemplateIdentifiersInThisProject'"/>
            </xsl:call-template>
        </h2>
        <table border="0" cellspacing="10" style="min-width: 80%" xmlns="http://www.w3.org/1999/xhtml">
            <tr>
                <td class="tabtab">
                    <table width="100%" border="0" cellspacing="3" cellpadding="2">
                        <tr class="headinglabel" style="vertical-align: top;">
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Id'"/>
                                </xsl:call-template>
                            </th>
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'DisplayName'"/>
                                </xsl:call-template>
                            </th>
                            <!--<th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Name'"/>
                                </xsl:call-template>
                            </th>-->
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'EffectiveDate'"/>
                                </xsl:call-template>
                            </th>
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Type'"/>
                                </xsl:call-template>
                            </th>
                        </tr>
                        <xsl:for-each-group select="$allTemplates/*/ref/template" group-by="(@id | @ref)">
                            <xsl:variable name="tmid" select="current-grouping-key()"/>
                            <xsl:variable name="tmnewest" select="(current-group()[@newestForId = 'true'], current-group())[1]"/>
                            <tr style="vertical-align: top;">
                                <td style="vertical-align: top;">
                                    <xsl:call-template name="doShorthandId">
                                        <xsl:with-param name="id" select="$tmid"/>
                                    </xsl:call-template>
                                </td>
                                <td style="vertical-align: top;">
                                    <xsl:value-of select="$tmnewest/(@displayName, @name)[1]"/>
                                </td>
                                <!--<td style="vertical-align: top;">
                                    <xsl:value-of select="@name"/>
                                </td>-->
                                <td style="vertical-align: top;">
                                    <xsl:for-each select="current-group()/@effectiveDate">
                                        <xsl:sort select="." order="descending"/>
                                        <div>
                                            <a href="{local:doHtmlName('TM', $tmid, ., '.html')}" onclick="target='_blank';">
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="."/>
                                                </xsl:call-template>
                                            </a>
                                        </div>
                                    </xsl:for-each>
                                </td>
                                <td style="vertical-align: top;">
                                    <xsl:value-of select="$tmnewest/classification/@type"/>
                                </td>
                            </tr>
                            <xsl:variable name="errmsg">
                                <xsl:for-each select="current-group()">
                                    <xsl:variable name="tmnm" select="@name"/>
                                    <xsl:variable name="tmed" select="@effectiveDate"/>
                                    
                                    <xsl:if test="count($allTemplates/*/ref/template[@id = $tmid][@effectiveDate = $tmed]) &gt; 1">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'possibleConflictingDuplicateIds'"/>
                                        </xsl:call-template>
                                    </xsl:if>
                                    <xsl:if test="count($allTemplates/*/ref/template[@name = $tmnm][not((@id | @ref) = $tmid)]) &gt; 1">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'possibleConflictingDuplicateNames'"/>
                                        </xsl:call-template>
                                    </xsl:if>
                                </xsl:for-each>
                            </xsl:variable>
                            <xsl:if test="not(empty($errmsg))">
                                <tr>
                                    <td> </td>
                                    <td colspan="3">
                                        <table style="border: 0;">
                                            <xsl:call-template name="doMessage">
                                                <xsl:with-param name="level" select="'warning'"/>
                                                <xsl:with-param name="msg" select="$errmsg"/>
                                            </xsl:call-template>
                                        </table>
                                    </td>
                                </tr>
                            </xsl:if>
                        </xsl:for-each-group>
                    </table>
                </td>
            </tr>
        </table>
        <h2 xmlns="http://www.w3.org/1999/xhtml">
            <xsl:call-template name="getMessage">
                <xsl:with-param name="key" select="'listOfValueSetIdentifiersInThisProject'"/>
            </xsl:call-template>
        </h2>
        <table border="0" cellspacing="10" style="min-width: 80%" xmlns="http://www.w3.org/1999/xhtml">
            <tr>
                <td class="tabtab">
                    <table width="100%" border="0" cellspacing="3" cellpadding="2">
                        <tr class="headinglabel" style="vertical-align: top;">
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Id'"/>
                                </xsl:call-template>
                            </th>
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'DisplayName'"/>
                                </xsl:call-template>
                            </th>
                            <!--<th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Name'"/>
                                </xsl:call-template>
                            </th>-->
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'EffectiveDate'"/>
                                </xsl:call-template>
                            </th>
                        </tr>
                        <xsl:for-each-group select="$allValueSets/*/valueSet" group-by="(@id | @ref)">
                            <xsl:variable name="vsid" select="current-grouping-key()"/>
                            <xsl:variable name="vsnewest" select="(current-group()[@effectiveDate = max(current-group()/xs:dateTime(@effectiveDate))], current-group())[1]"/>
                            <tr style="vertical-align: top;">
                                <td style="vertical-align: top;">
                                    <xsl:call-template name="doShorthandId">
                                        <xsl:with-param name="id" select="$vsid"/>
                                    </xsl:call-template>
                                </td>
                                <td style="vertical-align: top;">
                                    <xsl:value-of select="$vsnewest/(@displayName, @name)[1]"/>
                                </td>
                                <!--<td style="vertical-align: top;">
                                    <xsl:value-of select="@name"/>
                                </td>-->
                                <td style="vertical-align: top;">
                                    <xsl:for-each select="current-group()/@effectiveDate">
                                        <xsl:sort select="." order="descending"/>
                                        <div>
                                            <a href="{local:doHtmlName('VS', $vsid, ., '.html')}" onclick="target='_blank';">
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="."/>
                                                </xsl:call-template>
                                            </a>
                                        </div>
                                    </xsl:for-each>
                                </td>
                            </tr>
                            <xsl:variable name="errmsg" as="element()*">
                                <xsl:for-each select="current-group()">
                                    <xsl:variable name="vsnm" select="@name"/>
                                    <xsl:variable name="vsed" select="@effectiveDate"/>
                                    
                                    <xsl:if test="count($allValueSets/*/ref/valueSet[@id = $vsid][@effectiveDate = $vsed]) &gt; 1">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'possibleConflictingDuplicateIds'"/>
                                        </xsl:call-template>
                                    </xsl:if>
                                    <xsl:if test="count($allValueSets/*/ref/valueSet[@name = $vsnm][not((@id | @ref) = $vsid)]) &gt; 1">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'possibleConflictingDuplicateNames'"/>
                                        </xsl:call-template>
                                    </xsl:if>
                                </xsl:for-each>
                            </xsl:variable>
                            <xsl:if test="not(empty($errmsg))">
                                <tr>
                                    <td> </td>
                                    <td colspan="2">
                                        <table style="border: 0;">
                                            <xsl:call-template name="doMessage">
                                                <xsl:with-param name="level" select="'warning'"/>
                                                <xsl:with-param name="msg" select="$errmsg"/>
                                            </xsl:call-template>
                                        </table>
                                    </td>
                                </tr>
                            </xsl:if>
                        </xsl:for-each-group>
                    </table>
                </td>
            </tr>
        </table>
    </xsl:template>
    <xsl:template match="template" mode="showpreliminaries">
        <xsl:param name="underlyingModel"/>
        <xsl:param name="resultingRule"/>
        <xsl:param name="direction"/>
        <xsl:param name="onespacebetweenheaderparticlesonly" select="false()"/>
        <xsl:text>

</xsl:text>
        <!-- 
            create the template name description
            an @id and a @name is mandatory per template
            give human readable @displayName preference (if present) over pure @name
            if @name and @displayName are identical, print only once
        -->
        <xsl:variable name="templatename">
            <xsl:choose>
                <xsl:when test="string-length(@displayName) &gt; 0">
                    <xsl:value-of select="@displayName"/>
                </xsl:when>
                <xsl:when test="string-length(@name) &gt; 0">
                    <xsl:value-of select="@name"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'rulesNoNameOrDisplaynameDefinedYet'"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!--div class="AccordionPanel">
            <div class="AccordionPanelTab"-->
        <div class="acco" onclick="window.open('{local:doHtmlName('TM',@id,@effectiveDate,'.html')}')" xmlns="http://www.w3.org/1999/xhtml">
            <h3>
                <xsl:call-template name="showStatusDot">
                    <xsl:with-param name="status" select="@statusCode"/>
                    <xsl:with-param name="title">
                        <xsl:choose>
                            <xsl:when test="@ident[not(. = $projectPrefix)]">
                                <xsl:value-of select="'ref'"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="getXFormsLabel">
                                    <xsl:with-param name="simpleTypeKey" select="'TemplateStatusCodeLifeCycle'"/>
                                    <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>
                <xsl:text>&#160;</xsl:text>
                <xsl:copy-of select="$templatename"/>
                <xsl:if test="$onespacebetweenheaderparticlesonly = false()">
                    <!-- correction for printing re/ spaces between headline particles -->
                    <xsl:text>&#160;</xsl:text>
                </xsl:if>
                <xsl:text>&#160;</xsl:text>
                <xsl:value-of select="@id"/>
                <xsl:if test="$onespacebetweenheaderparticlesonly = false()">
                    <!-- correction for printing re/ spaces between headline particles -->
                    <xsl:text>&#160;</xsl:text>
                </xsl:if>
                <xsl:text>&#160;-&#160;</xsl:text>
                <xsl:call-template name="showDate">
                    <xsl:with-param name="date" select="@effectiveDate"/>
                </xsl:call-template>
                <xsl:if test="@versionLabel">
                    <xsl:text> (</xsl:text>
                    <xsl:value-of select="@versionLabel"/>
                    <xsl:text>)</xsl:text>
                </xsl:if>
                <xsl:apply-templates select="." mode="buildReferenceBox"/>
            </h3>
            <!-- in case this is a scenario transaction rule, show data -->
            <xsl:if test="string-length(concat($underlyingModel, $resultingRule)) &gt; 0">
                <table border="0" cellspacing="2" cellpadding="5" style="background-color: #FFFFFF;">
                    <tr class="headinglable">
                        <th colspan="2">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Direction'"/>
                            </xsl:call-template>
                        </th>
                        <th>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'UnderlyingModel'"/>
                            </xsl:call-template>
                        </th>
                        <th>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'RuleName'"/>
                            </xsl:call-template>
                        </th>
                        <th>Schematron</th>
                    </tr>
                    <tr>
                        <td>
                            <xsl:call-template name="showDirection">
                                <xsl:with-param name="dir" select="$direction"/>
                            </xsl:call-template>
                        </td>
                        <td>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="concat('transactionDirection', $direction)"/>
                            </xsl:call-template>
                        </td>
                        <td>
                            <xsl:value-of select="$underlyingModel"/>
                        </td>
                        <td>
                            <xsl:value-of select="$resultingRule"/>
                        </td>
                        <td>
                            <xsl:value-of select="concat($projectPrefix, $resultingRule, '.sch')"/>
                        </td>
                    </tr>
                </table>
            </xsl:if>
        </div>
        <!--/div>
            <xsl:text>

</xsl:text>
            <div class="AccordionPanelContent">
                <xsl:apply-templates select=".">
                    <xsl:with-param name="templatename" select="$templatename"/>
                </xsl:apply-templates>
            </div>
        </div-->
    </xsl:template>
    <xsl:template match="template">
        <xsl:param name="templatename"/>
        <xsl:param name="label" as="element()?"/>
        <!-- cache id, name, effectiveDate and calculate if we're the newest version of the template -->
        <xsl:variable name="tid" select="@id"/>
        <xsl:variable name="teff" select="@effectiveDate"/>
        <xsl:variable name="tname" select="@name"/>
        <xsl:variable name="tIsNewest" select="max($allTemplates/*/ref/template[@id = $tid]/xs:dateTime(@effectiveDate)) = $teff"/>
        <xsl:variable name="tmformat" select="local:getTemplateFormat(.)"/>
        <xsl:variable name="fWidth" select="'20em'"/>
        <!-- create item label to show -->
        <xsl:variable name="itemlabel" as="element()?">
            <xsl:choose>
                <xsl:when test="string-length(item[1]/@label) &gt; 0">
                    <!-- use current item/@label -->
                    <item xmlns="" label="{replace(string(item[1]/@label), '-', '‑')}">
                        <xsl:copy-of select="item[1]/desc"/>
                    </item>
                </xsl:when>
                <xsl:when test="$label[string-length(@label[1]) &gt; 0]">
                    <!-- use inherited label if present -->
                    <xsl:copy-of select="$label"/>
                </xsl:when>
                <xsl:otherwise>
                    <!-- use leave it empty -->
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <table width="100%" border="0" cellspacing="3" cellpadding="2" xmlns="http://www.w3.org/1999/xhtml">
            <!-- id / effectiveDate -->
            <tr style="vertical-align: top;">
                <!-- id -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Id'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:variable name="ident" select="(@ident, ../@ident)[1]"/>
                    <xsl:variable name="url" select="(@url, ../@url)[1]"/>
                    <xsl:choose>
                        <!-- In live ART-DECOR you can just go there, but in an offline publication, we cannot jump to a different publication location -->
                        <xsl:when test="$url and not(empty($projectPrefix)) and $ident[not(. = $projectPrefix)] and $seeThisUrlLocation = ('live', 'live-vue')">
                            <a href="{local:doHtmlName('TM',$url, $ident, $tid, $teff, (), (), (), (), '.html', false(), 'html')}" onclick="target='_blank';">
                                <xsl:value-of select="$tid"/>
                            </a>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$tid"/>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                </td>
                <!-- version information -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'effectiveDate'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:if test="$teff[string-length() &gt; 0]">
                        <!--<xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'templateValidFrom'"/>
                        </xsl:call-template>-->
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="$teff"/>
                        </xsl:call-template>
                    </xsl:if>
                    <xsl:if test="@expirationDate[string-length() gt 0]">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'templateValidTo'"/>
                        </xsl:call-template>
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="@expirationDate"/>
                        </xsl:call-template>
                    </xsl:if>
                    <xsl:variable name="otherVersions" select="$allTemplateRefs/*/template[@name = $tname or @id = $tid][@effectiveDate[not(. = $teff)]]" as="element()*"/>
                    <xsl:if test="$otherVersions">
                        <div>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'OtherVersionsWithThisId'"/>
                            </xsl:call-template>
                            <ul>
                                <xsl:for-each-group select="$otherVersions" group-by="concat(@id, @effectiveDate)">
                                    <xsl:sort select="@effectiveDate" order="descending"/>
                                    <xsl:for-each select="current-group()[1]">
                                        <li>
                                            <xsl:call-template name="showStatusDot">
                                                <xsl:with-param name="status" select="@statusCode"/>
                                                <xsl:with-param name="title">
                                                    <xsl:call-template name="getXFormsLabel">
                                                        <xsl:with-param name="simpleTypeKey" select="'TemplateStatusCodeLifeCycle'"/>
                                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                    </xsl:call-template>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                            <xsl:text> </xsl:text>
                                            <a href="{local:doHtmlName('TM', @id, @effectiveDate, '.html')}" onclick="target='_blank';">
                                                <xsl:value-of select="(@displayName, @name)[1]"/>
                                            </a>
                                            <xsl:if test="@versionLabel">
                                                <xsl:value-of select="@versionLabel"/>
                                                <xsl:text> - </xsl:text>
                                            </xsl:if>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'xAsOfy'"/>
                                            </xsl:call-template>
                                            <xsl:text> </xsl:text>
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="@effectiveDate"/>
                                            </xsl:call-template>
                                            <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                        </li>
                                    </xsl:for-each>
                                </xsl:for-each-group>
                            </ul>
                        </div>
                    </xsl:if>
                </td>
            </tr>
            <!-- status / versionLabel -->
            <tr style="vertical-align: top;">
                <!-- status -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Status'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:call-template name="showStatusDot">
                        <xsl:with-param name="status" select="@statusCode"/>
                        <xsl:with-param name="title">
                            <xsl:call-template name="getXFormsLabel">
                                <xsl:with-param name="simpleTypeKey" select="'TemplateStatusCodeLifeCycle'"/>
                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                            </xsl:call-template>
                        </xsl:with-param>
                    </xsl:call-template>
                    <xsl:text> </xsl:text>
                    <xsl:call-template name="getXFormsLabel">
                        <xsl:with-param name="simpleTypeKey" select="'TemplateStatusCodeLifeCycle'"/>
                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                    </xsl:call-template>
                </td>
                <!-- versionLabel -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'columnVersionLabel'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@versionLabel"/>
                </td>
            </tr>
            <!-- name / displayName -->
            <tr style="vertical-align: top;">
                <!-- name -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Name'"/>
                    </xsl:call-template>
                    <!--<xsl:if test="count(context) = 0">
                        <!-\- no context means: internal template -\->
                        <xsl:text> (</xsl:text>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'internal'"/>
                        </xsl:call-template>
                        <xsl:text>)</xsl:text>
                    </xsl:if>-->
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@name"/>
                </td>
                <!-- displayName -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'DisplayName'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@displayName"/>
                </td>
            </tr>
            <!-- description if given -->
            <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
                <tr style="vertical-align: top;">
                    <xsl:choose>
                        <xsl:when test="desc[string-length(string-join(descendant-or-self::text(), ' ')) > 200]">
                            <td style="text-align: left;" colspan="4">
                                <xsl:variable name="elid" select="local:randomString2(., ())"/>
                                <!--<xsl:variable name="elidtoggler" select="concat('toggler-', $elid)"/>-->
                                <table id="templateDescTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                                    <tr class="desclabel" data-tt-id="templateDescHeader">
                                        <td class="togglertreetable" style="height: 1.5em;">
                                            <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                <xsl:attribute name="class" select="'toggler'"/>
                                                <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                            </xsl:if>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'templateDescription'"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                    <tr data-tt-id="templateDescBody" data-tt-parent-id="templateDescHeader">
                                        <td>
                                            <div id="{$elid}">
                                                <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                    <xsl:attribute name="class" select="'toggle'"/>
                                                </xsl:if>
                                                <xsl:call-template name="doDescription">
                                                    <xsl:with-param name="ns" select="desc"/>
                                                </xsl:call-template>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </xsl:when>
                        <xsl:otherwise>
                            <th style="width: {$fWidth}; text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'templateDescription'"/>
                                </xsl:call-template>
                            </th>
                            <td style="text-align: left;" colspan="3">
                                <xsl:call-template name="doDescription">
                                    <xsl:with-param name="ns" select="desc"/>
                                </xsl:call-template>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>
                </tr>
            </xsl:if>
            <!-- context of this template -->
            <xsl:if test="context">
                <xsl:variable name="cid">
                    <xsl:choose>
                        <xsl:when test="context/@id = '*'">
                            <!-- use siblings of template's id -->
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'tmpContextSibling'"/>
                                <xsl:with-param name="p1" select="@id"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:when test="context/@id = '**'">
                            <!-- use parent of current template's id -->
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'tmpContextParent'"/>
                                <xsl:with-param name="p1" select="@id"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:when test="context/@path">
                            <xsl:variable name="cctxpth">
                                <xsl:call-template name="outputPath">
                                    <xsl:with-param name="pathname">
                                        <xsl:value-of select="context/@path"/>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </xsl:variable>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'tmpContextPath'"/>
                                <xsl:with-param name="p1" select="$cctxpth"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="context/@id"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'context'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:value-of select="$cid"/>
                    </td>
                </tr>
            </xsl:if>
            <!-- item labels -->
            <xsl:if test="item/@label">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'itemReference'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:value-of select="replace(string(item/@label), '-', '‑')"/>
                        <xsl:if test="count(desc) &gt; 0">
                            <br/>
                        </xsl:if>
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="item/desc"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- classification -->
            <xsl:if test="classification">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Classification'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:for-each select="classification">
                            <xsl:call-template name="getXFormsLabel">
                                <xsl:with-param name="simpleTypeKey" select="'TemplateTypes'"/>
                                <xsl:with-param name="simpleTypeValue" select="@type"/>
                            </xsl:call-template>
                            <xsl:if test="position() != last()">
                                <br/>
                            </xsl:if>
                        </xsl:for-each>
                    </td>
                </tr>
            </xsl:if>
            <!-- @closed -->
            <tr style="vertical-align: top;">
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'openClosedLabel'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;" colspan="3">
                    <xsl:choose>
                        <xsl:when test="string(@isClosed) = 'true'">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'templateIsClosed'"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'templateIsOpen'"/>
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
            </tr>
            <!-- is associated with what concepts?
                
                <templateAssociation templateId="2.999.999.993.77.10.900100" effectiveDate="2012-04-10T00:00:00">
                    <concept ref="2.999.999.993.77.2.1.100060" effectiveDate="2012-04-10T00:00:00" elementId="2.999.999.993.77.9.900100.1"/>
                </templateAssociation>
                
            -->
            <xsl:variable name="associatedConcepts" select="$allTemplateAssociation/*/templateAssociation[@templateId = $tid][@effectiveDate = $teff]/concept | descendant::staticAssociations/origconcept" as="element()*"/>
            <xsl:variable name="renderedConcepts" as="element()*">
                <xsl:for-each-group select="$associatedConcepts" group-by="concat(@ref, @effectiveDate)">
                    <xsl:variable name="deid" select="current-group()[1]/@ref"/>
                    <xsl:variable name="deed" select="current-group()[1]/@effectiveDate"/>
                    <xsl:variable name="concept" select="(current-group()/self::origconcept[name], local:getConceptFlat($deid, $deed))[1]" as="element()?"/>
                    <xsl:variable name="destatus" select="(current-group()/@conceptStatusCode, $concept/@statusCode)[1]" as="item()?"/>
                    <xsl:variable name="deversionlabel" select="(current-group()/@conceptVersionLabel, $concept/@versionLabel)[1]"/>
                    <xsl:variable name="dataset" select="local:getDatasetForConcept($deid, $deed)"/>
                    <xsl:variable name="dsid" select="(current-group()/@datasetId, $dataset/@id)[1]"/>
                    <xsl:variable name="dsef" select="(current-group()/@datasetEffectiveDate, $dataset/@effectiveDate)[1]"/>
                    <xsl:variable name="dspath">
                        <xsl:choose>
                            <xsl:when test="@path">
                                <xsl:value-of select="current-group()[1]/@path"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:for-each select="$dataset//concept[(@id | @ref) = $concept/(@id | @ref)][(@effectiveDate | @flexibility) = $concept/(@effectiveDate | @flexibility)]/ancestor::concept">
                                    <xsl:call-template name="doName">
                                        <!-- will not exist on RetrieveTemplate expanded templates -->
                                        <xsl:with-param name="ns" select="local:getConceptFlat((@id | @ref), (@effectiveDate | @flexibility))/name"/>
                                    </xsl:call-template>
                                    <xsl:text> / </xsl:text>
                                </xsl:for-each>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="dsstatus" select="(current-group()/@datasetStatusCode, $dataset/@statusCode)[1]" as="item()?"/>
                    <xsl:variable name="dsname">
                        <xsl:choose>
                            <xsl:when test="current-group()[1]/datasetName">
                                <xsl:call-template name="doName">
                                    <!-- will not exist on RetrieveTemplate expanded templates -->
                                    <xsl:with-param name="ns" select="current-group()[1]/datasetName"/>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:when test="@datasetName">
                                <xsl:value-of select="current-group()[1]/@datasetName"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="doName">
                                    <!-- will not exist on RetrieveTemplate expanded templates -->
                                    <xsl:with-param name="ns" select="$dataset/name"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="dsversionlabel" select="(current-group()/@datasetVersionLabel, $dataset/@versionLabel)[1]"/>
                    <xsl:variable name="deiddisplay">
                        <xsl:choose>
                            <xsl:when test="@refdisplay[not(. = '')]">
                                <xsl:value-of select="current-group()[1]/@refdisplay"/>
                            </xsl:when>
                            <xsl:when test="$concept[@iddisplay]">
                                <xsl:value-of select="($concept/@iddisplay)[1]"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="doShorthandId">
                                    <xsl:with-param name="id" select="$deid"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:if test="empty($concept)">
                        <xsl:call-template name="logMessage">
                            <xsl:with-param name="level" select="$logDEBUG"/>
                            <xsl:with-param name="msg">
                                <xsl:text>+++ Could not find concept "</xsl:text>
                                <xsl:value-of select="$deid"/>
                                <xsl:text>" effectiveDate "</xsl:text>
                                <xsl:value-of select="$deed"/>
                                <xsl:text>" associated with template id "</xsl:text>
                                <xsl:value-of select="$tid"/>
                                <xsl:text>" effectiveDate "</xsl:text>
                                <xsl:value-of select="$teff"/>
                                <xsl:text>" name "</xsl:text>
                                <xsl:value-of select="$tname"/>
                                <xsl:text> and element </xsl:text>
                                <xsl:value-of select="@elementId | @elementPath"/>
                                <xsl:text>. This may not be meaningful as all templateAssociations anywhere copied during compile phase, but datasets are limited to those pertaining to the project. This might place certain associations out of context.</xsl:text>
                            </xsl:with-param>
                        </xsl:call-template>
                        <!--<tr class="missingAssociation" xmlns="http://www.w3.org/1999/xhtml">
                            <td style="vertical-align: top;" colspan="3">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'theReferencedConceptAsOfCannotBeFound'"/>
                                    <xsl:with-param name="p1" select="$deid"/>
                                    <xsl:with-param name="p2">
                                        <xsl:call-template name="showDate">
                                            <xsl:with-param name="date" select="$deed"/>
                                        </xsl:call-template>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </td>
                        </tr>-->
                    </xsl:if>
                    <xsl:for-each select="$concept">
                        <tr>
                            <td style="text-align: left; vertical-align: top; width: 1%;">
                                <xsl:choose>
                                    <xsl:when test="empty($dsid)">
                                        <xsl:copy-of select="$deiddisplay"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <a href="{local:doHtmlName('DS', $projectPrefix, $dsid, $dsef, $deid, $deed, (), (), '.html', false())}" onclick="target='_blank';">
                                            <xsl:copy-of select="$deiddisplay"/>
                                        </a>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                            <td style="vertical-align: top;">
                                <xsl:if test="string-length($dspath) > 0">
                                    <xsl:attribute name="title" select="$dspath"/>
                                </xsl:if>
                                <xsl:if test="string-length($destatus) > 0">
                                    <xsl:call-template name="showStatusDot">
                                        <xsl:with-param name="status" select="$destatus"/>
                                        <xsl:with-param name="title">
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="$destatus"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                    <xsl:text>&#160;</xsl:text>
                                </xsl:if>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="$concept/name"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="$deversionlabel"/>
                            </td>
                            <td style="text-align: left; vertical-align: top;">
                                <xsl:if test="string-length($dsstatus) > 0">
                                    <xsl:call-template name="showStatusDot">
                                        <xsl:with-param name="status" select="$dsstatus"/>
                                        <xsl:with-param name="title">
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="$dsstatus"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                    <xsl:text>&#160;</xsl:text>
                                </xsl:if>
                                <xsl:copy-of select="$dsname"/>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="$dsversionlabel"/>
                                <xsl:if test="current-group()[1][not(@ident = $projectPrefix)]">
                                    <xsl:text> </xsl:text>
                                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                </xsl:if>
                            </td>
                        </tr>
                    </xsl:for-each>
                </xsl:for-each-group>
            </xsl:variable>
            <xsl:if test="$renderedConcepts[not(@class = 'missingAssociation')]">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'AssociatedWith'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:variable name="elid" select="local:randomString2(., ())"/>
                        <!--<xsl:variable name="elidtoggler" select="concat('toggler-', $elid)"/>-->
                        <table id="assocsTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                            <tr class="desclabel" data-tt-id="assocsHeader">
                                <td class="togglertreetable" style="height: 1.5em;">
                                    <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                        <xsl:attribute name="class" select="'toggler'"/>
                                        <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                    </xsl:if>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'AssociatedWith'"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <xsl:variable name="assoccnt" select="count($renderedConcepts[not(@class = 'missingAssociation')])"/>
                                    <xsl:choose>
                                        <xsl:when test="$assoccnt = 1">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'numberOfConcept'"/>
                                                <xsl:with-param name="p1" select="$assoccnt"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'numberOfConcepts'"/>
                                                <xsl:with-param name="p1" select="$assoccnt"/>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <!-- 2018-03-27 Deactivated code because we will not be detecting those anymore due to changes in compilation. Activate logDEBUG to send messages to the log -->
                                    <!--<xsl:if test="$renderedConcepts[@class = 'missingAssociation']">
                                        <xsl:text>&#160;</xsl:text>
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">notice</xsl:with-param>
                                        </xsl:call-template>
                                    </xsl:if>-->
                                </td>
                            </tr>
                            <tr data-tt-id="assocsBody" data-tt-parent-id="assocsHeader">
                                <td>
                                    <div id="{$elid}">
                                        <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                            <xsl:attribute name="class" select="'toggle'"/>
                                        </xsl:if>
                                        <table width="100%" border="0" cellspacing="1" cellpadding="3">
                                            <tr>
                                                <th style="width: 20%; text-align: left;">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'Id'"/>
                                                    </xsl:call-template>
                                                </th>
                                                <th style="width: 60%; text-align: left;">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'Name'"/>
                                                    </xsl:call-template>
                                                </th>
                                                <th style="width: 20%; text-align: left;">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'Dataset'"/>
                                                    </xsl:call-template>
                                                </th>
                                            </tr>
                                            <xsl:copy-of select="$renderedConcepts[not(@class = 'missingAssociation')]"/>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <!-- used in what other templates? -->
            <xsl:variable name="associatedTemplates" as="element()">
                <wrap xmlns="">
                    <xsl:choose>
                        <xsl:when test="ref | uses">
                            <!-- 
                                or in an already expanded template format use directly ref and uses
                                <ref type="contains" id="1.2.276.0.76.10.12345" name="ClinicalInformation" displayName="Klinische Parameter" effectiveDate="2014-11-01T00:00:00"/>
                                
                                ref types are 'include', 'contains', 'dependency'
                            -->
                            <!-- used by first -->
                            <!-- sometimes we reach a ref immediately (contains/include) and through another template (dependency). In this case, skip the dependency template -->
                            <xsl:variable name="refs" select="ref" as="element()*"/>
                            <xsl:for-each select="$refs">
                                <xsl:variable name="xti" select="@id"/>
                                <xsl:variable name="xte" select="@effectiveDate"/>
                                <xsl:variable name="flex" select="(@flexibility, 'dynamic')[1]"/>
                                <xsl:if test="not(@type = 'dependency') or not($refs[@id = $xti][@effectiveDate = $xte][not(@type = 'dependency')])">
                                    <ref flexibility="{$flex}">
                                        <xsl:copy-of select="@*"/>
                                    </ref>
                                </xsl:if>
                            </xsl:for-each>
                            <!-- now template uses -->
                            <xsl:for-each select="uses">
                                <xsl:variable name="flex" select="
                                        if (@flexibility) then
                                            @flexibility
                                        else
                                            ('dynamic')"/>
                                <uses flexibility="{$flex}">
                                    <xsl:copy-of select="@*"/>
                                </uses>
                            </xsl:for-each>
                        </xsl:when>
                        <xsl:otherwise>
                            <!-- used by not in wiki mode -->
                            <xsl:if test="not($adram = ('mediawiki', 'confluence', 'wordpress'))">
                                <!-- used by first -->
                                <xsl:for-each select="$allTemplates/*/ref[template//include[@ref = $tid or @ref = $tname][($tIsNewest and (not(@flexibility) or string(@flexibility) = 'dynamic')) or @flexibility = $teff]]">
                                    <xsl:variable name="xti" select="template/@id"/>
                                    <xsl:variable name="xtn" select="template/@name"/>
                                    <xsl:variable name="xte" select="template/@effectiveDate"/>
                                    <xsl:variable name="xdn" select="template/@displayName"/>
                                    <xsl:variable name="xin" select="max($allTemplates/*/ref/template[@id = $xti]/xs:dateTime(@effectiveDate)) = $xte"/>
                                    <xsl:variable name="xst" select="template/@statusCode"/>
                                    <xsl:variable name="xvl" select="template/@versionLabel"/>
                                    <ref type="include" newestForId="{$xin}">
                                        <xsl:copy-of select="template/(@* except (@type | @flexibility))"/>
                                    </ref>
                                    <!-- get Template Chain recursively, submit template id and name  -->
                                    <xsl:call-template name="getTemplateChain">
                                        <xsl:with-param name="yti" select="$xti"/>
                                        <xsl:with-param name="ytn" select="$xtn"/>
                                        <xsl:with-param name="yte" select="$xte"/>
                                        <xsl:with-param name="ydn" select="$xdn"/>
                                        <xsl:with-param name="yin" select="$xin"/>
                                        <xsl:with-param name="yst" select="$xst"/>
                                        <xsl:with-param name="yvl" select="$xvl"/>
                                        <xsl:with-param name="sofar" select="concat(':', $xti, ':', $xtn, ':')"/>
                                    </xsl:call-template>
                                </xsl:for-each>
                                <xsl:for-each select="$allTemplates/*/ref[template//*[@contains = $tid or @contains = $tname][($tIsNewest and (not(@flexibility) or string(@flexibility) = 'dynamic')) or @flexibility = $teff]]">
                                    <xsl:variable name="xti" select="template/@id"/>
                                    <xsl:variable name="xtn" select="template/@name"/>
                                    <xsl:variable name="xte" select="template/@effectiveDate"/>
                                    <xsl:variable name="xdn" select="template/@displayName"/>
                                    <xsl:variable name="xin" select="max($allTemplates/*/ref/template[@id = $xti]/xs:dateTime(@effectiveDate)) = $xte"/>
                                    <xsl:variable name="xst" select="template/@statusCode"/>
                                    <xsl:variable name="xvl" select="template/@versionLabel"/>
                                    <ref type="contains" newestForId="{$xin}">
                                        <xsl:copy-of select="template/(@* except (@type | @flexibility))"/>
                                    </ref>
                                    <!-- get Template Chain recursively, submit template id and name  -->
                                    <xsl:call-template name="getTemplateChain">
                                        <xsl:with-param name="yti" select="$xti"/>
                                        <xsl:with-param name="ytn" select="$xtn"/>
                                        <xsl:with-param name="yte" select="$xte"/>
                                        <xsl:with-param name="ydn" select="$xdn"/>
                                        <xsl:with-param name="yin" select="$xin"/>
                                        <xsl:with-param name="yst" select="$xst"/>
                                        <xsl:with-param name="yvl" select="$xvl"/>
                                        <xsl:with-param name="sofar" select="concat(':', $xti, ':', $xtn, ':')"/>
                                    </xsl:call-template>
                                </xsl:for-each>
                            </xsl:if>
                            <!-- now template uses -->
                            <xsl:for-each select=".//element[@contains] | .//include[@ref]">
                                <xsl:variable name="xid" select="concat(@contains, @ref)"/>
                                <xsl:variable name="flex" select="(@flexibility, 'dynamic')[1]"/>
                                <xsl:variable name="type">
                                    <xsl:choose>
                                        <xsl:when test="self::element">contains</xsl:when>
                                        <xsl:otherwise>include</xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>
                                <xsl:variable name="effd">
                                    <xsl:choose>
                                        <xsl:when test="$flex castable as xs:dateTime">
                                            <xsl:value-of select="$flex"/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="string(max($allTemplates/*/ref[template[@id = $xid or @name = $xid]]/xs:dateTime(@effectiveDate)))"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>
                                <xsl:variable name="tmpl" select="$allTemplates/*/ref[template[@id = $xid][@effectiveDate = $effd]] | $allTemplates/*/ref[template[@name = $xid][@effectiveDate = $effd]]"/>
                                <xsl:for-each select="$tmpl">
                                    <uses type="{$type}" flexibility="{$flex}">
                                        <xsl:copy-of select="template/(@* except (@type | @flexibility))"/>
                                    </uses>
                                </xsl:for-each>
                            </xsl:for-each>
                        </xsl:otherwise>
                    </xsl:choose>
                </wrap>
            </xsl:variable>
            <xsl:variable name="associatedTransactions" as="element()">
                <wrap xmlns="">
                    <xsl:choose>
                        <xsl:when test="representingTemplate">
                            <xsl:for-each select="representingTemplate">
                                <xsl:variable name="trid" select="@transactionId"/>
                                <xsl:variable name="tred" select="@transactionEffectiveDate"/>
                                <transaction id="{$trid}" effectiveDate="{$tred}">
                                    <xsl:copy-of select="@* except (@id | @effectiveDate)"/>
                                    <xsl:copy-of select="node()"/>
                                </transaction>
                            </xsl:for-each>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:for-each select="$allScenarios//transaction[representingTemplate/@ref]">
                                <xsl:choose>
                                    <xsl:when test="representingTemplate[@flexibility[not(. castable as xs:dateTime)]][$tIsNewest][@ref = ($tid, $tname)]">
                                        <xsl:copy-of select="."/>
                                    </xsl:when>
                                    <xsl:when test="representingTemplate[@flexibility[not(. castable as xs:dateTime)]][$tIsNewest][@ref = $associatedTemplates//ref[@newestForId = 'true']/(@id, @name)]">
                                        <xsl:copy-of select="."/>
                                    </xsl:when>
                                    <xsl:when test="representingTemplate[concat(@ref, @flexibility[. castable as xs:dateTime]) = (concat($tid, $teff), concat($tname, $teff))]">
                                        <xsl:copy-of select="."/>
                                    </xsl:when>
                                    <xsl:when test="representingTemplate[concat(@ref, @flexibility[. castable as xs:dateTime]) = ($associatedTemplates//ref/concat(@id, @ffectiveDate), $associatedTemplates//ref/concat(@name, @ffectiveDate))]">
                                        <xsl:copy-of select="."/>
                                    </xsl:when>
                                </xsl:choose>
                            </xsl:for-each>
                        </xsl:otherwise>
                    </xsl:choose>
                </wrap>
            </xsl:variable>
            <xsl:if test="count($associatedTemplates/*) > 0 or count($associatedTransactions/*) > 0">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:if test="not($adram = ('mediawiki', 'confluence', 'wordpress'))">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'UsedBy'"/>
                            </xsl:call-template>
                            <xsl:text> / </xsl:text>
                        </xsl:if>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Uses'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:variable name="elid" select="local:randomString2(., ())"/>
                        <table class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                            <tr class="desclabel" data-tt-id="usedHeader">
                                <td class="togglertreetable" style="height: 1.5em;">
                                    <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                        <xsl:attribute name="class" select="'toggler'"/>
                                        <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                    </xsl:if>
                                    <xsl:variable name="trxcnt" select="count(distinct-values($associatedTransactions/transaction/concat(@id, @effectiveDate)))"/>
                                    <xsl:variable name="refcnt" select="count(distinct-values($associatedTemplates/ref/concat(@id, @effectiveDate)))"/>
                                    <xsl:variable name="usecnt" select="count(distinct-values($associatedTemplates/uses/concat(@id, @effectiveDate)))"/>
                                    <xsl:if test="not($adram = ('mediawiki', 'confluence', 'wordpress'))">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'UsedBy'"/>
                                        </xsl:call-template>
                                        <xsl:text> </xsl:text>
                                        <xsl:choose>
                                            <xsl:when test="$trxcnt = 1 and $refcnt = 1">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'numberOfTransactionTemplate'"/>
                                                    <xsl:with-param name="p1" select="$trxcnt"/>
                                                    <xsl:with-param name="p2" select="$refcnt"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:when test="$trxcnt != 1 and $refcnt = 1">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'numberOfTransactionsTemplate'"/>
                                                    <xsl:with-param name="p1" select="$trxcnt"/>
                                                    <xsl:with-param name="p2" select="$refcnt"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:when test="$trxcnt = 1 and $refcnt != 1">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'numberOfTransactionTemplates'"/>
                                                    <xsl:with-param name="p1" select="$trxcnt"/>
                                                    <xsl:with-param name="p2" select="$refcnt"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'numberOfTransactionsTemplates'"/>
                                                    <xsl:with-param name="p1" select="$trxcnt"/>
                                                    <xsl:with-param name="p2" select="$refcnt"/>
                                                </xsl:call-template>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                        <xsl:text>, </xsl:text>
                                    </xsl:if>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Uses'"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <xsl:choose>
                                        <xsl:when test="$usecnt = 1">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'numberOfTemplate'"/>
                                                <xsl:with-param name="p1" select="$usecnt"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'numberOfTemplates'"/>
                                                <xsl:with-param name="p1" select="$usecnt"/>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </td>
                            </tr>
                            <tr data-tt-id="usedBody" data-tt-parent-id="usedHeader">
                                <td>
                                    <div id="{$elid}">
                                        <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                            <xsl:attribute name="class" select="'toggle'"/>
                                        </xsl:if>
                                        <table width="100%" border="0" cellspacing="1" cellpadding="3">
                                            <xsl:for-each select="$associatedTransactions/transaction, $associatedTemplates/ref, $associatedTemplates/uses">
                                                <xsl:variable name="xpfx" select="(@prefix, @ident, $projectPrefix)[1]"/>
                                                <xsl:variable name="xti" select="@id"/>
                                                <xsl:variable name="xtn" select="@name"/>
                                                <xsl:variable name="xty" select="@type"/>
                                                <xsl:variable name="xte" select="@effectiveDate"/>
                                                <xsl:variable name="xdn" select="@displayName"/>
                                                <xsl:variable name="xin" select="@newestForId"/>
                                                <xsl:variable name="xflx" select="@flexibility"/>
                                                <xsl:variable name="xsts" select="@statusCode"/>
                                                <xsl:variable name="xvsl" select="@versionLabel"/>
                                                <xsl:variable name="ename" select="name()"/>
                                                <xsl:if test="not(preceding-sibling::*[name() = $ename]) and not($ename = 'ref' and $associatedTransactions/transaction)">
                                                    <tr>
                                                        <th style="width: 20%; text-align: left;">
                                                            <xsl:choose>
                                                                <xsl:when test="$ename = ('transaction', 'ref')">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'UsedBy'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'Uses'"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </th>
                                                        <th style="width: 1%; text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'as'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                        <th style="width: 60%; text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'Name'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                        <th style="width: 19%; text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'Version'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                    </tr>
                                                </xsl:if>
                                                <xsl:if test="not(preceding-sibling::*[name() = $ename][@id = $xti][@effectiveDate = $xte])">
                                                    <tr>
                                                        <td style="text-align: left;">
                                                            <xsl:choose>
                                                                <xsl:when test="$ename = 'transaction'">
                                                                    <a href="{local:doHtmlName('TR',$xpfx,$xti,$xte,(),(),(),(),'.html',false())}" onclick="target='_blank';">
                                                                        <xsl:call-template name="doShorthandId">
                                                                            <xsl:with-param name="id" select="$xti"/>
                                                                        </xsl:call-template>
                                                                    </a>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <a href="{local:doHtmlName('TM',$xpfx,$xti,$xte,(),(),(),(),'.html',false())}" onclick="target='_blank';">
                                                                        <xsl:value-of select="$xti"/>
                                                                    </a>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </td>
                                                        <td style="text-align: left;">
                                                            <xsl:choose>
                                                                <xsl:when test="$ename = 'transaction'">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'Transaction'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:when test="$xty = 'contains'">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'tmpContains'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:when test="$xty = 'include'">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'tmpInclude'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:when test="$xty = 'dependency' or self::ref">
                                                                    <xsl:call-template name="showIcon">
                                                                        <xsl:with-param name="which">link</xsl:with-param>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                            </xsl:choose>
                                                        </td>
                                                        <td style="text-align: left;">
                                                            <xsl:if test="$xsts">
                                                                <xsl:call-template name="showStatusDot">
                                                                    <xsl:with-param name="status" select="$xsts"/>
                                                                    <xsl:with-param name="title">
                                                                        <xsl:call-template name="getXFormsLabel">
                                                                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                            <xsl:with-param name="simpleTypeValue" select="$xsts"/>
                                                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                        </xsl:call-template>
                                                                    </xsl:with-param>
                                                                </xsl:call-template>
                                                                <xsl:text> </xsl:text>
                                                            </xsl:if>
                                                            <xsl:choose>
                                                                <xsl:when test="self::transaction">
                                                                    <xsl:call-template name="doName">
                                                                        <xsl:with-param name="ns" select="name"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:when test="string-length($xdn) &gt; 0">
                                                                    <xsl:value-of select="$xdn"/>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:value-of select="$xtn"/>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                            <xsl:if test="string-length($xvsl)>0">
                                                                <xsl:text> (</xsl:text>
                                                                <xsl:value-of select="@versionLabel"/>
                                                                <xsl:text>)</xsl:text>
                                                            </xsl:if>
                                                        </td>
                                                        <td style="text-align: left;">
                                                            <xsl:choose>
                                                                <xsl:when test="$ename = 'uses' and matches($xflx, '^\d')">
                                                                    <xsl:call-template name="showDate">
                                                                        <xsl:with-param name="date" select="$xflx"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:when test="$ename = 'uses' and $xflx">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="showDate">
                                                                        <xsl:with-param name="date" select="$xte"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </td>
                                                    </tr>
                                                    <xsl:choose>
                                                        <xsl:when test="following-sibling::*[name() = $ename][@id = $xti][@effectiveDate = $xte][@circularForId]">
                                                            <tr>
                                                                <td style="text-align: left;"/>
                                                                <td style="text-align: left;" colspan="3">
                                                                    <xsl:call-template name="showIcon">
                                                                        <xsl:with-param name="which">notice</xsl:with-param>
                                                                    </xsl:call-template>
                                                                    <xsl:text>&#160;</xsl:text>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'tmpCircularReference'"/>
                                                                        <xsl:with-param name="p1">
                                                                            <xsl:call-template name="doShorthandId">
                                                                                <xsl:with-param name="id" select="$xti"/>
                                                                            </xsl:call-template>
                                                                        </xsl:with-param>
                                                                    </xsl:call-template>
                                                                </td>
                                                            </tr>
                                                        </xsl:when>
                                                        <xsl:when test="following-sibling::*[name() = $ename][@id = $xti][@effectiveDate = $xte][@circularForName]">
                                                            <tr>
                                                                <td style="text-align: left;"/>
                                                                <td style="text-align: left;" colspan="3">
                                                                    <xsl:call-template name="showIcon">
                                                                        <xsl:with-param name="which">notice</xsl:with-param>
                                                                    </xsl:call-template>
                                                                    <xsl:text>&#160;</xsl:text>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'tmpCircularReference'"/>
                                                                        <xsl:with-param name="p1">
                                                                            <xsl:call-template name="doShorthandId">
                                                                                <xsl:with-param name="id" select="$xtn"/>
                                                                            </xsl:call-template>
                                                                        </xsl:with-param>
                                                                    </xsl:call-template>
                                                                </td>
                                                            </tr>
                                                        </xsl:when>
                                                    </xsl:choose>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <!-- relationship -->
            <!-- <relationship type="SPEC" model="" template="" flexibility=""/> -->
            <!-- 2DO model resolving comparable problem to transaction/@model -->
            <!-- 2DO implement links to templates/models if possible -->
            <xsl:if test="relationship">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Relationship'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:for-each select="relationship">
                            <xsl:call-template name="getXFormsLabel">
                                <xsl:with-param name="simpleTypeKey" select="'RelationshipTypes'"/>
                                <xsl:with-param name="simpleTypeValue" select="@type"/>
                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                            </xsl:call-template>
                            <xsl:text>: </xsl:text>
                            <xsl:choose>
                                <xsl:when test="@template">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'tmpArtifactTypeTemplate'"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'tmpArtifactTypeModel'"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text> </xsl:text>
                            <xsl:choose>
                                <xsl:when test="@template and $seeThisUrlLocation = ('live', 'live-vue')">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'tmpRelationshipLinked'"/>
                                        <xsl:with-param name="p1">
                                            <xsl:variable name="rccontent" as="element()*">
                                                <xsl:call-template name="getRulesetContent">
                                                    <xsl:with-param name="ruleset" select="@template"/>
                                                    <xsl:with-param name="flexibility" select="@flexibility"/>
                                                    <xsl:with-param name="sofar" select="()"/>
                                                </xsl:call-template>
                                            </xsl:variable>
                                            <xsl:value-of select="local:doHtmlName('TM', @url, @ident, @template, @flexibility, (), (), (), (), '.html', exists($rccontent))"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="p2" select="@template"/>
                                        <xsl:with-param name="p3" select="concat(@tmdisplayName, ' ')"/>
                                        <xsl:with-param name="p4">
                                            <xsl:choose>
                                                <xsl:when test="matches(@flexibility, '^\d{4}')">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="@flexibility"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'tmpRelationship'"/>
                                        <xsl:with-param name="p1">
                                            <xsl:choose>
                                                <xsl:when test="@template">
                                                    <xsl:value-of select="@template"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:value-of select="@model"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:with-param>
                                        <xsl:with-param name="p2" select="concat(@tmdisplayName, ' ')"/>
                                        <xsl:with-param name="p3">
                                            <xsl:choose>
                                                <xsl:when test="matches(@flexibility, '^\d{4}')">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="@flexibility"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:apply-templates select="." mode="buildReferenceBox"/>
                            <xsl:if test="position() != last()">
                                <br/>
                            </xsl:if>
                        </xsl:for-each>
                    </td>
                </tr>
            </xsl:if>
            <!-- template examples always first if any -->
            <xsl:apply-templates select="example" mode="templateparticle">
                <xsl:with-param name="parent-id" select="''"/>
                <xsl:with-param name="fWidth" select="$fWidth"/>
                <xsl:with-param name="sofar" select="()"/>
                <xsl:with-param name="templateFormat" select="$tmformat"/>
            </xsl:apply-templates>
            <!-- if this is a transsaction template, as links to the default instances is those have been generated -->
            <xsl:variable name="candidateTransactions" select="$allScenarios//representingTemplate[@ref = $tid]"/>
            <xsl:if test="$createDefaultInstancesForRepresentingTemplates=true() and $candidateTransactions">
                <!-- a little milestoning -->
                <xsl:call-template name="logMessage">
                    <xsl:with-param name="level" select="$logDEBUG"/>
                    <xsl:with-param name="msg">
                        <xsl:text>*** Creating links to default instances for representing templates</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'defaultInstance'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <table class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                            <tr class="desclabel" data-tt-id="instance-{generate-id(.)}">
                                <td class="togglertreetable" style="height: 1.5em;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'defaultInstance'"/>
                                    </xsl:call-template>
                                </td>
                            </tr>
                            <tr data-tt-id="instanceBody-{generate-id(.)}" data-tt-parent-id="instance-{generate-id(.)}">
                                <td>
                                    <table>
                                        <tr>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Scenario'"/>
                                                </xsl:call-template>
                                            </th>
                                            <th>
                                                <xsl:call-template name="showIcon">
                                                    <xsl:with-param name="which">doublearrow</xsl:with-param>
                                                    <xsl:with-param name="tooltip">
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'Group'"/>
                                                        </xsl:call-template>
                                                    </xsl:with-param>
                                                </xsl:call-template>
                                                <xsl:text>&#160;</xsl:text>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Transaction'"/>
                                                </xsl:call-template>
                                            </th>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Transaction'"/>
                                                </xsl:call-template>
                                            </th>
                                            <th/>
                                        </tr>
                                        <xsl:for-each select="$candidateTransactions">
                                            <xsl:variable name="trid" select="parent::transaction/@id"/>
                                            <!-- cache transaction/@effectiveDate. This is relatively new so might not be present -->
                                            <xsl:variable name="treff" select="parent::transaction/@effectiveDate"/>
                                            <xsl:variable name="tflex" select="@flexibility"/>
                                            <xsl:variable name="rccontent" as="element(template)?">
                                                <xsl:call-template name="getRulesetContent">
                                                    <xsl:with-param name="ruleset" select="$tid"/>
                                                    <xsl:with-param name="flexibility" select="$tflex"/>
                                                    <xsl:with-param name="sofar" select="()"/>
                                                </xsl:call-template>
                                            </xsl:variable>
                                            <xsl:if test="$rccontent[@id = $tid][@effectiveDate = $teff]">
                                                <xsl:call-template name="logMessage">
                                                    <xsl:with-param name="level" select="$logDEBUG"/>
                                                    <xsl:with-param name="msg">
                                                        <xsl:text>*** Instance files HTML/XML for transaction: name='</xsl:text>
                                                        <xsl:value-of select="parent::transaction/name[1]"/>
                                                        <xsl:text>' id='</xsl:text>
                                                        <xsl:value-of select="$trid"/>
                                                        <xsl:text>' effectiveDate='</xsl:text>
                                                        <xsl:value-of select="parent::transaction/@effectiveDate"/>
                                                        <xsl:text>'</xsl:text>
                                                    </xsl:with-param>
                                                </xsl:call-template>
                                                <tr>
                                                    <td>
                                                        <xsl:for-each select="ancestor::scenario">
                                                            <xsl:call-template name="showStatusDot">
                                                                <xsl:with-param name="status" select="@statusCode"/>
                                                                <xsl:with-param name="title">
                                                                    <xsl:call-template name="getXFormsLabel">
                                                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                    </xsl:call-template>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                            <xsl:text>&#160;</xsl:text>
                                                            <a href="{local:doHtmlName('SC', @id , @effectiveDate, '.html')}" onclick="target='_blank';" target="_blank">
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="name"/>
                                                                </xsl:call-template>
                                                                <xsl:if test="@versionLabel">
                                                                    <xsl:text> </xsl:text>
                                                                    <xsl:value-of select="@versionLabel"/>
                                                                </xsl:if>
                                                            </a>
                                                        </xsl:for-each>
                                                    </td>
                                                    <td>
                                                        <xsl:for-each select="parent::transaction/parent::transaction">
                                                            <xsl:call-template name="showStatusDot">
                                                                <xsl:with-param name="status" select="@statusCode"/>
                                                                <xsl:with-param name="title">
                                                                    <xsl:call-template name="getXFormsLabel">
                                                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                    </xsl:call-template>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                            <xsl:text>&#160;</xsl:text>
                                                            <a href="{local:doHtmlName('TR', @id , @effectiveDate, '.html')}" onclick="target='_blank';" target="_blank">
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="name"/>
                                                                </xsl:call-template>
                                                                <xsl:if test="@versionLabel">
                                                                    <xsl:text> </xsl:text>
                                                                    <xsl:value-of select="@versionLabel"/>
                                                                </xsl:if>
                                                            </a>
                                                        </xsl:for-each>
                                                    </td>
                                                    <td>
                                                        <xsl:for-each select="parent::transaction">
                                                            <xsl:call-template name="showStatusDot">
                                                                <xsl:with-param name="status" select="@statusCode"/>
                                                                <xsl:with-param name="title">
                                                                    <xsl:call-template name="getXFormsLabel">
                                                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                    </xsl:call-template>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                            <xsl:text>&#160;</xsl:text>
                                                            <xsl:call-template name="showDirection">
                                                                <xsl:with-param name="dir" select="@type"/>
                                                            </xsl:call-template>
                                                            <xsl:text>&#160;</xsl:text>
                                                            <a href="{local:doHtmlName('TR', @id , @effectiveDate, '.html')}" onclick="target='_blank';" target="_blank">
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="name"/>
                                                                </xsl:call-template>
                                                                <xsl:if test="@versionLabel">
                                                                    <xsl:text> </xsl:text>
                                                                    <xsl:value-of select="@versionLabel"/>
                                                                </xsl:if>
                                                            </a>
                                                        </xsl:for-each>
                                                    </td>
                                                    <td>
                                                        <div>
                                                            <a href="{local:doHtmlName('TR', $trid, $treff, '_instance.html', true())}" onclick="target='_blank';" target="_blank">
                                                                <xsl:text>HTML (</xsl:text>
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'Transaction'"/>
                                                                </xsl:call-template>
                                                                <xsl:text>)</xsl:text>
                                                            </a>
                                                        </div>
                                                        <div>
                                                            <a href="{local:doHtmlName('DS', $trid, $treff, '_instance.html', true())}" onclick="target='_blank';" target="_blank">
                                                                <xsl:text>HTML (</xsl:text>
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'Dataset'"/>
                                                                </xsl:call-template>
                                                                <xsl:text>)</xsl:text>
                                                            </a>
                                                        </div>
                                                        <div>
                                                            <a href="{local:doHtmlName('TR', $trid, $treff, '_instance.xml', true())}" onclick="target='_blank';" target="_blank">
                                                                <xsl:text>XML</xsl:text>
                                                            </a>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <!-- diff engine -->
            <xsl:if test="diff:delete[@name = ('example')]">
                <tr>
                    <td>
                        <table class="ad-diffblock-horizontal">
                            <tr class="ad-diff-red">
                                <td class="ad-diff-singlebox">
                                    <strike>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Example'"/>
                                        </xsl:call-template>
                                    </strike>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td colspan="3"/>
                </tr>
            </xsl:if>
            <!-- issues -->
            <xsl:call-template name="check4Issue">
                <xsl:with-param name="id" select="@id"/>
                <xsl:with-param name="effectiveDate" select="@effectiveDate"/>
                <xsl:with-param name="colspans" select="3"/>
            </xsl:call-template>
            <!-- if there is at least one element or attribute or one choice or one include in a template, process it -->
            <xsl:choose>
                <xsl:when test="count(element | attribute | include | choice | assert | report | let | defineVariable | constraint | property) &gt; 0">
                    <tr style="vertical-align: top;">
                        <td colspan="4" class="tabtab">
                            <xsl:if test="$switchCreateTreeTableHtml = 'true'">
                                <div>
                                    <button id="expandAll" type="button">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                        </xsl:call-template>
                                    </button>
                                    <button id="collapseAll" type="button">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                        </xsl:call-template>
                                    </button>
                                    <input id="nameSearch">
                                        <xsl:attribute name="placeholder">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'textSearch'"/>
                                            </xsl:call-template>
                                        </xsl:attribute>
                                    </input>
                                    <!--<select id="hiddenColumns">
                                        <option value="title">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'showColumn'"/>
                                            </xsl:call-template>
                                        </option>
                                        <option value="columnDetails" disabled="disabled">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Details'"/>
                                            </xsl:call-template>
                                        </option>
                                    </select>-->
                                </div>
                            </xsl:if>
                            <table id="transactionTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                                <thead>
                                    <tr>
                                        <th style="width: 30%; text-align: left;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'itemLabel'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th style="width: 2em; text-align: left;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'datatypeLabel'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th style="width: 2em; text-align: left;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'cardinalityLabel'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th style="width: 2em; text-align: left;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'conformanceLabel'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th style="text-align: left;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'descLabel'"/>
                                            </xsl:call-template>
                                        </th>
                                        <th style="width: 2em; text-align: left;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Label'"/>
                                            </xsl:call-template>
                                        </th>
                                    </tr>
                                </thead>
                                <tbody class="list">
                                    <xsl:apply-templates select="element | attribute | include | choice | assert | report | let | defineVariable | constraint | property" mode="templateparticle">
                                        <xsl:with-param name="level" select="0"/>
                                        <xsl:with-param name="label" select="$itemlabel"/>
                                        <xsl:with-param name="parent-id" select="''"/>
                                        <xsl:with-param name="sofar" select="concat($tid, '-', $teff)"/>
                                        <xsl:with-param name="templateFormat" select="$tmformat"/>
                                    </xsl:apply-templates>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                </xsl:when>
                <xsl:otherwise>
                    <tr>
                        <td colspan="4">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'noElemsAttribInclChoiceDefined'"/>
                            </xsl:call-template>
                        </td>
                    </tr>
                </xsl:otherwise>
            </xsl:choose>
        </table>
    </xsl:template>
    <xsl:template name="getTemplateChain">
        <!-- 
            get template chain (dependencies), params are 
            current template id $xti and name $ytn
            and the chain so far in $sofar to detect circular references
            $sofar concats every id and name node visited so far surrounded by :
        -->
        <xsl:param name="yti"/>
        <xsl:param name="ytn"/>
        <xsl:param name="yte"/>
        <xsl:param name="ydn"/>
        <xsl:param name="yin"/>
        <xsl:param name="yst"/>
        <xsl:param name="yvl"/>
        <xsl:param name="sofar"/>
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logALL"/>
            <xsl:with-param name="msg">
                <xsl:text>R====</xsl:text>
                <xsl:value-of select="$yti"/>
                <xsl:text>/</xsl:text>
                <xsl:value-of select="$ytn"/>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logALL"/>
            <xsl:with-param name="msg">
                <xsl:text>SOFAR(</xsl:text>
                <xsl:value-of select="$sofar"/>
                <xsl:text>)   SUB(</xsl:text>
                <xsl:value-of select="substring-after($sofar, $yti)"/>
                <xsl:text>)   CIRC: </xsl:text>
                <xsl:value-of select="contains(substring-after($sofar, $yti), concat(':', $yti, ':'))"/>
                <xsl:text>&#160;</xsl:text>
                <xsl:value-of select="contains(substring-after($sofar, $ytn), concat(':', $ytn, ':'))"/>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:choose>
            <xsl:when test="contains(substring-after($sofar, $yti), concat(':', $yti, ':'))">
                <!-- circular reference by id -->
                <ref xmlns="" type="dependency" id="{$yti}" name="{$ytn}" effectiveDate="{$yte}" displayName="{$ydn}" statusCode="{$yst}" versionLabel="{$yvl}" newestForId="{$yin}" circularForId="{true()}"/>
            </xsl:when>
            <xsl:when test="contains(substring-after($sofar, $ytn), concat(':', $ytn, ':'))">
                <!-- circular reference by name -->
                <ref xmlns="" type="dependency" id="{$yti}" name="{$ytn}" effectiveDate="{$yte}" displayName="{$ydn}" statusCode="{$yst}" versionLabel="{$yvl}" newestForId="{$yin}" circularForName="{true()}"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:for-each select="
                        $allTemplates/*/ref[template//include[@ref = $yti or @ref = $ytn][($yin and (not(@flexibility) or string(@flexibility) = 'dynamic')) or @flexibility = $yte]] |
                        $allTemplates/*/ref[template//*[@contains = $yti or @contains = $ytn][($yin and (not(@flexibility) or string(@flexibility) = 'dynamic')) or @flexibility = $yte]]">
                    <xsl:variable name="xti" select="template/@id"/>
                    <xsl:variable name="xtn" select="template/@name"/>
                    <xsl:variable name="xdn" select="template/@displayName"/>
                    <xsl:variable name="xte" select="template/@effectiveDate"/>
                    <xsl:variable name="xin" select="max($allTemplates/*/ref/template[@id = $xti]/xs:dateTime(@effectiveDate)) = $xte"/>
                    <xsl:variable name="xst" select="template/@statusCode"/>
                    <xsl:variable name="xvl" select="template/@versionLabel"/>
                    <ref xmlns="" type="dependency" newestForId="{$xin}">
                        <xsl:copy-of select="template/(@* except (@type | @flexibility))"/>
                        <xsl:copy-of select="template/classification"/>
                    </ref>
                    <xsl:call-template name="getTemplateChain">
                        <xsl:with-param name="yti" select="$xti"/>
                        <xsl:with-param name="ytn" select="$xtn"/>
                        <xsl:with-param name="yte" select="$xte"/>
                        <xsl:with-param name="ydn" select="$xdn"/>
                        <xsl:with-param name="yin" select="$xin"/>
                        <xsl:with-param name="yst" select="$xst"/>
                        <xsl:with-param name="yvl" select="$xvl"/>
                        <xsl:with-param name="sofar" select="concat($sofar, ':', $yti, ':', $ytn)"/>
                    </xsl:call-template>
                </xsl:for-each>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="*" mode="templateparticle">
        <xsl:param name="sofar" select="()"/>
        <xsl:text>OOPS: </xsl:text>
        <xsl:value-of select="name()"/>
    </xsl:template>
    <xsl:template match="questionnaire">
        <xsl:param name="templatename"/>
        <xsl:param name="label" as="element()?"/>
        <!-- cache id, name, effectiveDate and calculate if we're the newest version of the template -->
        <xsl:variable name="tid" select="@id"/>
        <xsl:variable name="teff" select="@effectiveDate"/>
        <xsl:variable name="tname" select="@name"/>
        <xsl:variable name="tIsNewest" select="max($allQuestionnaires[@id = $tid]/xs:dateTime(@effectiveDate)) = $teff"/>
        <xsl:variable name="fWidth" select="'20em'"/>
        <table width="100%" border="0" cellspacing="3" cellpadding="2" xmlns="http://www.w3.org/1999/xhtml">
            <!-- id / effectiveDate -->
            <tr style="vertical-align: top;">
                <!-- id -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Id'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:variable name="ident" select="(@ident, ../@ident)[1]"/>
                    <xsl:variable name="url" select="(@url, ../@url)[1]"/>
                    <xsl:choose>
                        <!-- In live ART-DECOR you can just go there, but in an offline publication, we cannot jump to a different publication location -->
                        <xsl:when test="$url and not(empty($projectPrefix)) and $ident[not(. = $projectPrefix)] and $seeThisUrlLocation = ('live', 'live-vue')">
                            <a href="{local:doHtmlName('QQ',$url,$ident,$tid,$teff,(),(),(),(),'.html',false())}" onclick="target='_blank';">
                                <xsl:value-of select="$tid"/>
                            </a>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$tid"/>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                </td>
                <!-- version information -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'effectiveDate'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:if test="$teff[string-length() &gt; 0]">
                        <!--<xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'templateValidFrom'"/>
                        </xsl:call-template>-->
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="$teff"/>
                        </xsl:call-template>
                    </xsl:if>
                    <xsl:if test="@expirationDate[string-length() gt 0]">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'templateValidTo'"/>
                        </xsl:call-template>
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="@expirationDate"/>
                        </xsl:call-template>
                    </xsl:if>
                    <xsl:variable name="otherVersions" select="$allQuestionnaires[@id = $tid][@effectiveDate[not(. = $teff)]]" as="element()*"/>
                    <xsl:if test="$otherVersions">
                        <div>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'OtherVersionsWithThisId'"/>
                            </xsl:call-template>
                            <ul>
                                <xsl:for-each-group select="$otherVersions" group-by="concat(@id, @effectiveDate)">
                                    <xsl:sort select="@effectiveDate" order="descending"/>
                                    <xsl:for-each select="current-group()[1]">
                                        <li>
                                            <xsl:call-template name="showStatusDot">
                                                <xsl:with-param name="status" select="@statusCode"/>
                                                <xsl:with-param name="title">
                                                    <xsl:call-template name="getXFormsLabel">
                                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                    </xsl:call-template>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                            <xsl:text> </xsl:text>
                                            <a href="{local:doHtmlName('QQ', @id, @effectiveDate, '.html')}" onclick="target='_blank';">
                                                <xsl:value-of select="(@displayName, @name)[1]"/>
                                            </a>
                                            <xsl:if test="@versionLabel">
                                                <xsl:value-of select="@versionLabel"/>
                                                <xsl:text> - </xsl:text>
                                            </xsl:if>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'xAsOfy'"/>
                                            </xsl:call-template>
                                            <xsl:text> </xsl:text>
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="@effectiveDate"/>
                                            </xsl:call-template>
                                            <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                        </li>
                                    </xsl:for-each>
                                </xsl:for-each-group>
                            </ul>
                        </div>
                    </xsl:if>
                </td>
            </tr>
            <!-- status / versionLabel -->
            <tr style="vertical-align: top;">
                <!-- status -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Status'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:call-template name="showStatusDot">
                        <xsl:with-param name="status" select="@statusCode"/>
                        <xsl:with-param name="title">
                            <xsl:call-template name="getXFormsLabel">
                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                            </xsl:call-template>
                        </xsl:with-param>
                    </xsl:call-template>
                    <xsl:text> </xsl:text>
                    <xsl:call-template name="getXFormsLabel">
                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                    </xsl:call-template>
                </td>
                <!-- versionLabel -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'columnVersionLabel'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@versionLabel"/>
                </td>
            </tr>
            <!-- name / canonicalUri -->
            <tr style="vertical-align: top;">
                <!-- name -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Name'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:call-template name="doName">
                        <xsl:with-param name="ns" select="name"/>
                    </xsl:call-template>
                </td>
                <!-- canonicalUri -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'canonicalUri'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@canonicalUri"/>
                </td>
            </tr>
            <!-- description if given -->
            <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
                <tr style="vertical-align: top;">
                    <xsl:choose>
                        <xsl:when test="desc[string-length(string-join(descendant-or-self::text(), ' ')) > 200]">
                            <td style="text-align: left;" colspan="4">
                                <xsl:variable name="elid" select="local:randomString2(., ())"/>
                                <!--<xsl:variable name="elidtoggler" select="concat('toggler-', $elid)"/>-->
                                <table id="templateDescTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                                    <tr class="desclabel" data-tt-id="templateDescHeader">
                                        <td class="togglertreetable" style="height: 1.5em;">
                                            <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                <xsl:attribute name="class" select="'toggler'"/>
                                                <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                            </xsl:if>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'templateDescription'"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                    <tr data-tt-id="templateDescBody" data-tt-parent-id="templateDescHeader">
                                        <td>
                                            <div id="{$elid}">
                                                <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                    <xsl:attribute name="class" select="'toggle'"/>
                                                </xsl:if>
                                                <xsl:call-template name="doDescription">
                                                    <xsl:with-param name="ns" select="desc"/>
                                                </xsl:call-template>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </xsl:when>
                        <xsl:otherwise>
                            <th style="width: {$fWidth}; text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'templateDescription'"/>
                                </xsl:call-template>
                            </th>
                            <td style="text-align: left;" colspan="3">
                                <xsl:call-template name="doDescription">
                                    <xsl:with-param name="ns" select="desc"/>
                                </xsl:call-template>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>
                </tr>
            </xsl:if>
            <xsl:if test="purpose[not(. = '')]">
                <tr style="vertical-align: top;">
                    <xsl:choose>
                        <xsl:when test="purpose[string-length(string-join(descendant-or-self::text(), ' ')) > 200]">
                            <td style="text-align: left;" colspan="4">
                                <xsl:variable name="elid" select="local:randomString2(., ())"/>
                                <!--<xsl:variable name="elidtoggler" select="concat('toggler-', $elid)"/>-->
                                <table id="templateDescTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                                    <tr class="desclabel" data-tt-id="templateDescHeader">
                                        <td class="togglertreetable" style="height: 1.5em;">
                                            <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                <xsl:attribute name="class" select="'toggler'"/>
                                                <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                            </xsl:if>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Purpose'"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                    <tr data-tt-id="templateDescBody" data-tt-parent-id="templateDescHeader">
                                        <td>
                                            <div id="{$elid}">
                                                <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                    <xsl:attribute name="class" select="'toggle'"/>
                                                </xsl:if>
                                                <xsl:call-template name="doDescription">
                                                    <xsl:with-param name="ns" select="purpose"/>
                                                </xsl:call-template>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </xsl:when>
                        <xsl:otherwise>
                            <th style="width: {$fWidth}; text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Purpose'"/>
                                </xsl:call-template>
                            </th>
                            <td style="text-align: left;" colspan="3">
                                <xsl:call-template name="doDescription">
                                    <xsl:with-param name="ns" select="purpose"/>
                                </xsl:call-template>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>
                </tr>
            </xsl:if>
            <xsl:if test="copyright[not(. = '')]">
                <tr style="vertical-align: top;">
                    <xsl:choose>
                        <xsl:when test="copyright[string-length(string-join(descendant-or-self::text(), ' ')) > 200]">
                            <td style="text-align: left;" colspan="4">
                                <xsl:variable name="elid" select="local:randomString2(., ())"/>
                                <!--<xsl:variable name="elidtoggler" select="concat('toggler-', $elid)"/>-->
                                <table id="templateDescTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                                    <tr class="desclabel" data-tt-id="templateDescHeader">
                                        <td class="togglertreetable" style="height: 1.5em;">
                                            <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                <xsl:attribute name="class" select="'toggler'"/>
                                                <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                            </xsl:if>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Copyright'"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                    <tr data-tt-id="templateDescBody" data-tt-parent-id="templateDescHeader">
                                        <td>
                                            <div id="{$elid}">
                                                <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                    <xsl:attribute name="class" select="'toggle'"/>
                                                </xsl:if>
                                                <xsl:call-template name="doDescription">
                                                    <xsl:with-param name="ns" select="copyright"/>
                                                </xsl:call-template>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </xsl:when>
                        <xsl:otherwise>
                            <th style="width: {$fWidth}; text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Copyright'"/>
                                </xsl:call-template>
                            </th>
                            <td style="text-align: left;" colspan="3">
                                <xsl:call-template name="doDescription">
                                    <xsl:with-param name="ns" select="copyright"/>
                                </xsl:call-template>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>
                </tr>
            </xsl:if>
            <xsl:if test="jurisdiction">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Jurisdiction'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:for-each select="jurisdiction">
                            <div>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'codeCodeSystemNameShallBeX-v2'"/>
                                    <xsl:with-param name="p1" select="@code"/>
                                    <xsl:with-param name="p3">
                                        <xsl:choose>
                                            <xsl:when test="@canonicalUri">
                                                <xsl:value-of select="concat(@codeSystem, ' (', @canonicalUri, ')')"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="@codeSystem"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:with-param>
                                </xsl:call-template>
                                <xsl:if test="@displayName">
                                    <xsl:text> - </xsl:text>
                                    <xsl:value-of select="@displayName"/>
                                </xsl:if>
                            </div>
                        </xsl:for-each>
                    </td>
                </tr>
            </xsl:if>
            <xsl:apply-templates select="publishingAuthority | endorsingauthority">
                <xsl:with-param name="fWidth" select="$fWidth"/>
            </xsl:apply-templates>
            <!-- classification -->
            <xsl:if test="classification">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Classification'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:for-each select="classification/tag">
                            <xsl:value-of select="."/>
                            <xsl:if test="position() != last()">
                                <br/>
                            </xsl:if>
                        </xsl:for-each>
                    </td>
                </tr>
            </xsl:if>
            <!-- is associated with what concepts?
                
                <templateAssociation templateId="2.999.999.993.77.10.900100" effectiveDate="2012-04-10T00:00:00">
                    <concept ref="2.999.999.993.77.2.1.100060" effectiveDate="2012-04-10T00:00:00" elementId="2.999.999.993.77.9.900100.1"/>
                </templateAssociation>
                
            -->
            <xsl:variable name="associatedConcepts" select="$allQuestionnaireAssociations[@questionnaireId = $tid][@questionnaireEffectiveDate = $teff]/concept" as="element()*"/>
            <xsl:variable name="renderedConcepts" as="element()*">
                <xsl:for-each-group select="$associatedConcepts" group-by="concat(@ref, @effectiveDate)">
                    <xsl:variable name="deid" select="current-group()[1]/@ref"/>
                    <xsl:variable name="deed" select="current-group()[1]/@effectiveDate"/>
                    <xsl:variable name="concept" select="(current-group()/self::origconcept[name], local:getConceptFlat($deid, $deed))[1]" as="element()?"/>
                    <xsl:variable name="destatus" select="(current-group()/@conceptStatusCode, $concept/@statusCode)[1]" as="item()?"/>
                    <xsl:variable name="deversionlabel" select="(current-group()/@conceptVersionLabel, $concept/@versionLabel)[1]"/>
                    <xsl:variable name="dataset" select="local:getDatasetForConcept($deid, $deed)"/>
                    <xsl:variable name="dsid" select="(current-group()/@datasetId, $dataset/@id)[1]"/>
                    <xsl:variable name="dsef" select="(current-group()/@datasetEffectiveDate, $dataset/@effectiveDate)[1]"/>
                    <xsl:variable name="dspath">
                        <xsl:choose>
                            <xsl:when test="@path">
                                <xsl:value-of select="current-group()[1]/@path"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:for-each select="$dataset//concept[(@id | @ref) = $concept/(@id | @ref)][(@effectiveDate | @flexibility) = $concept/(@effectiveDate | @flexibility)]/ancestor::concept">
                                    <xsl:call-template name="doName">
                                        <!-- will not exist on RetrieveTemplate expanded templates -->
                                        <xsl:with-param name="ns" select="local:getConceptFlat((@id | @ref), (@effectiveDate | @flexibility))/name"/>
                                    </xsl:call-template>
                                    <xsl:text> / </xsl:text>
                                </xsl:for-each>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="dsstatus" select="(current-group()/@datasetStatusCode, $dataset/@statusCode)[1]" as="item()?"/>
                    <xsl:variable name="dsname">
                        <xsl:choose>
                            <xsl:when test="current-group()[1]/datasetName">
                                <xsl:call-template name="doName">
                                    <!-- will not exist on RetrieveTemplate expanded templates -->
                                    <xsl:with-param name="ns" select="current-group()[1]/datasetName"/>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:when test="@datasetName">
                                <xsl:value-of select="current-group()[1]/@datasetName"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="doName">
                                    <!-- will not exist on RetrieveTemplate expanded templates -->
                                    <xsl:with-param name="ns" select="$dataset/name"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="dsversionlabel" select="(current-group()/@datasetVersionLabel, $dataset/@versionLabel)[1]"/>
                    <xsl:variable name="deiddisplay">
                        <xsl:choose>
                            <xsl:when test="@refdisplay[not(. = '')]">
                                <xsl:value-of select="current-group()[1]/@refdisplay"/>
                            </xsl:when>
                            <xsl:when test="$concept[@iddisplay]">
                                <xsl:value-of select="($concept/@iddisplay)[1]"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="doShorthandId">
                                    <xsl:with-param name="id" select="$deid"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:if test="empty($concept)">
                        <xsl:call-template name="logMessage">
                            <xsl:with-param name="level" select="$logDEBUG"/>
                            <xsl:with-param name="msg">
                                <xsl:text>+++ Could not find concept "</xsl:text>
                                <xsl:value-of select="$deid"/>
                                <xsl:text>" effectiveDate "</xsl:text>
                                <xsl:value-of select="$deed"/>
                                <xsl:text>" associated with questionnaire id "</xsl:text>
                                <xsl:value-of select="$tid"/>
                                <xsl:text>" effectiveDate "</xsl:text>
                                <xsl:value-of select="$teff"/>
                                <xsl:text>" name "</xsl:text>
                                <xsl:value-of select="$tname"/>
                                <xsl:text> and item </xsl:text>
                                <xsl:value-of select="@elementId | @elementPath"/>
                                <xsl:text>. This may not be meaningful as all questionnaireAssociations anywhere copied during compile phase, but datasets are limited to those pertaining to the project. This might place certain associations out of context.</xsl:text>
                            </xsl:with-param>
                        </xsl:call-template>
                        <!--<tr class="missingAssociation" xmlns="http://www.w3.org/1999/xhtml">
                            <td style="vertical-align: top;" colspan="3">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'theReferencedConceptAsOfCannotBeFound'"/>
                                    <xsl:with-param name="p1" select="$deid"/>
                                    <xsl:with-param name="p2">
                                        <xsl:call-template name="showDate">
                                            <xsl:with-param name="date" select="$deed"/>
                                        </xsl:call-template>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </td>
                        </tr>-->
                    </xsl:if>
                    <xsl:for-each select="$concept">
                        <tr>
                            <td style="text-align: left; vertical-align: top; width: 1%;">
                                <xsl:choose>
                                    <xsl:when test="empty($dsid)">
                                        <xsl:copy-of select="$deiddisplay"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <a href="{local:doHtmlName('DS', $projectPrefix, $dsid, $dsef, $deid, $deed, (), (), '.html', false())}" onclick="target='_blank';">
                                            <xsl:copy-of select="$deiddisplay"/>
                                        </a>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                            <td style="vertical-align: top;">
                                <xsl:if test="string-length($dspath) > 0">
                                    <xsl:attribute name="title" select="$dspath"/>
                                </xsl:if>
                                <xsl:if test="string-length($destatus) > 0">
                                    <xsl:call-template name="showStatusDot">
                                        <xsl:with-param name="status" select="$destatus"/>
                                        <xsl:with-param name="title">
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="$destatus"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                    <xsl:text>&#160;</xsl:text>
                                </xsl:if>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="$concept/name"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="$deversionlabel"/>
                            </td>
                            <td style="text-align: left; vertical-align: top;">
                                <xsl:if test="string-length($dsstatus) > 0">
                                    <xsl:call-template name="showStatusDot">
                                        <xsl:with-param name="status" select="$dsstatus"/>
                                        <xsl:with-param name="title">
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="$dsstatus"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                    <xsl:text>&#160;</xsl:text>
                                </xsl:if>
                                <xsl:copy-of select="$dsname"/>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="$dsversionlabel"/>
                                <xsl:if test="current-group()[1][not(@ident = $projectPrefix)]">
                                    <xsl:text> </xsl:text>
                                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                </xsl:if>
                            </td>
                        </tr>
                    </xsl:for-each>
                </xsl:for-each-group>
            </xsl:variable>
            <xsl:if test="$renderedConcepts[not(@class = 'missingAssociation')]">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'AssociatedWith'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:variable name="elid" select="local:randomString2(., ())"/>
                        <!--<xsl:variable name="elidtoggler" select="concat('toggler-', $elid)"/>-->
                        <table id="assocsTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                            <tr class="desclabel" data-tt-id="assocsHeader">
                                <td class="togglertreetable" style="height: 1.5em;">
                                    <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                        <xsl:attribute name="class" select="'toggler'"/>
                                        <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                    </xsl:if>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'AssociatedWith'"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <xsl:variable name="assoccnt" select="count($renderedConcepts[not(@class = 'missingAssociation')])"/>
                                    <xsl:choose>
                                        <xsl:when test="$assoccnt = 1">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'numberOfConcept'"/>
                                                <xsl:with-param name="p1" select="$assoccnt"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'numberOfConcepts'"/>
                                                <xsl:with-param name="p1" select="$assoccnt"/>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <!-- 2018-03-27 Deactivated code because we will not be detecting those anymore due to changes in compilation. Activate logDEBUG to send messages to the log -->
                                    <!--<xsl:if test="$renderedConcepts[@class = 'missingAssociation']">
                                        <xsl:text>&#160;</xsl:text>
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">notice</xsl:with-param>
                                        </xsl:call-template>
                                    </xsl:if>-->
                                </td>
                            </tr>
                            <tr data-tt-id="assocsBody" data-tt-parent-id="assocsHeader">
                                <td>
                                    <div id="{$elid}">
                                        <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                            <xsl:attribute name="class" select="'toggle'"/>
                                        </xsl:if>
                                        <table width="100%" border="0" cellspacing="1" cellpadding="3">
                                            <tr>
                                                <th style="width: 20%; text-align: left;">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'Id'"/>
                                                    </xsl:call-template>
                                                </th>
                                                <th style="width: 60%; text-align: left;">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'Name'"/>
                                                    </xsl:call-template>
                                                </th>
                                                <th style="width: 20%; text-align: left;">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'Dataset'"/>
                                                    </xsl:call-template>
                                                </th>
                                            </tr>
                                            <xsl:copy-of select="$renderedConcepts[not(@class = 'missingAssociation')]"/>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <xsl:variable name="associatedTransactions" select="
                $allScenarios//transaction[representingTemplate[@representingQuestionnaire = $tid][$tIsNewest][not(@representingQuestionnaireFlexibility castable as xs:dateTime)] |
                                           representingTemplate[@representingQuestionnaire = $tid][@representingQuestionnaireFlexibility = $teff]]" as="element()*"/>
            <xsl:if test="$associatedTransactions">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:if test="not($adram = ('mediawiki', 'confluence', 'wordpress'))">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'UsedBy'"/>
                            </xsl:call-template>
                        </xsl:if>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:variable name="elid" select="local:randomString2(., ())"/>
                        <table class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                            <tr class="desclabel" data-tt-id="usedHeader">
                                <td class="togglertreetable" style="height: 1.5em;">
                                    <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                        <xsl:attribute name="class" select="'toggler'"/>
                                        <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                    </xsl:if>
                                    <xsl:variable name="trxcnt" select="count(distinct-values($associatedTransactions/concat(@id, @effectiveDate)))"/>
                                    <xsl:if test="not($adram = ('mediawiki', 'confluence', 'wordpress'))">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'UsedBy'"/>
                                        </xsl:call-template>
                                        <xsl:text> </xsl:text>
                                        <xsl:choose>
                                            <xsl:when test="$trxcnt = 1">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'numberOfTransaction'"/>
                                                    <xsl:with-param name="p1" select="$trxcnt"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'numberOfTransactions'"/>
                                                    <xsl:with-param name="p1" select="$trxcnt"/>
                                                </xsl:call-template>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:if>
                                </td>
                            </tr>
                            <tr data-tt-id="usedBody" data-tt-parent-id="usedHeader">
                                <td>
                                    <div id="{$elid}">
                                        <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                            <xsl:attribute name="class" select="'toggle'"/>
                                        </xsl:if>
                                        <table width="100%" border="0" cellspacing="1" cellpadding="3">
                                            <xsl:for-each select="$associatedTransactions">
                                                <xsl:variable name="xpfx" select="(@prefix, @ident, $projectPrefix)[1]"/>
                                                <xsl:variable name="xti" select="@id"/>
                                                <xsl:variable name="xtn" select="@name"/>
                                                <xsl:variable name="xty" select="@type"/>
                                                <xsl:variable name="xte" select="@effectiveDate"/>
                                                <xsl:variable name="xdn" select="@displayName"/>
                                                <xsl:variable name="xin" select="@newestForId"/>
                                                <xsl:variable name="xflx" select="@flexibility"/>
                                                <xsl:variable name="xsts" select="@statusCode"/>
                                                <xsl:variable name="xvsl" select="@versionLabel"/>
                                                <xsl:variable name="ename" select="name()"/>
                                                <xsl:if test="not(preceding-sibling::*[name() = $ename]) and not($associatedTransactions)">
                                                    <tr>
                                                        <th style="width: 20%; text-align: left;">
                                                            <xsl:choose>
                                                                <xsl:when test="$ename = ('transaction', 'ref')">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'UsedBy'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'Uses'"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </th>
                                                        <th style="width: 1%; text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'as'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                        <th style="width: 60%; text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'Name'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                        <th style="width: 19%; text-align: left;">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'Version'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                    </tr>
                                                </xsl:if>
                                                <xsl:if test="not(preceding-sibling::*[name() = $ename][@id = $xti][@effectiveDate = $xte])">
                                                    <tr>
                                                        <td style="text-align: left;">
                                                            <xsl:choose>
                                                                <xsl:when test="$ename = 'transaction'">
                                                                    <a href="{local:doHtmlName('TR',$xpfx,$xti,$xte,(),(),(),(),'.html',false())}" onclick="target='_blank';">
                                                                        <xsl:call-template name="doShorthandId">
                                                                            <xsl:with-param name="id" select="$xti"/>
                                                                        </xsl:call-template>
                                                                    </a>
                                                                </xsl:when>
                                                            </xsl:choose>
                                                        </td>
                                                        <td style="text-align: left;">
                                                            <xsl:choose>
                                                                <xsl:when test="$ename = 'transaction'">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'Transaction'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                            </xsl:choose>
                                                        </td>
                                                        <td style="text-align: left;">
                                                            <xsl:if test="$xsts">
                                                                <xsl:call-template name="showStatusDot">
                                                                    <xsl:with-param name="status" select="$xsts"/>
                                                                    <xsl:with-param name="title">
                                                                        <xsl:call-template name="getXFormsLabel">
                                                                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                            <xsl:with-param name="simpleTypeValue" select="$xsts"/>
                                                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                        </xsl:call-template>
                                                                    </xsl:with-param>
                                                                </xsl:call-template>
                                                                <xsl:text> </xsl:text>
                                                            </xsl:if>
                                                            <xsl:choose>
                                                                <xsl:when test="self::transaction">
                                                                    <xsl:call-template name="doName">
                                                                        <xsl:with-param name="ns" select="name"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:when test="string-length($xdn) &gt; 0">
                                                                    <xsl:value-of select="$xdn"/>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:value-of select="$xtn"/>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                            <xsl:if test="string-length($xvsl)>0">
                                                                <xsl:text> (</xsl:text>
                                                                <xsl:value-of select="@versionLabel"/>
                                                                <xsl:text>)</xsl:text>
                                                            </xsl:if>
                                                        </td>
                                                        <td style="text-align: left;">
                                                            <xsl:choose>
                                                                <xsl:when test="$ename = 'uses' and matches($xflx, '^\d')">
                                                                    <xsl:call-template name="showDate">
                                                                        <xsl:with-param name="date" select="$xflx"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:when test="$ename = 'uses' and $xflx">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="showDate">
                                                                        <xsl:with-param name="date" select="$xte"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </td>
                                                    </tr>
                                                    <xsl:choose>
                                                        <xsl:when test="following-sibling::*[name() = $ename][@id = $xti][@effectiveDate = $xte][@circularForId]">
                                                            <tr>
                                                                <td style="text-align: left;"/>
                                                                <td style="text-align: left;" colspan="3">
                                                                    <xsl:call-template name="showIcon">
                                                                        <xsl:with-param name="which">notice</xsl:with-param>
                                                                    </xsl:call-template>
                                                                    <xsl:text>&#160;</xsl:text>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'tmpCircularReference'"/>
                                                                        <xsl:with-param name="p1">
                                                                            <xsl:call-template name="doShorthandId">
                                                                                <xsl:with-param name="id" select="$xti"/>
                                                                            </xsl:call-template>
                                                                        </xsl:with-param>
                                                                    </xsl:call-template>
                                                                </td>
                                                            </tr>
                                                        </xsl:when>
                                                        <xsl:when test="following-sibling::*[name() = $ename][@id = $xti][@effectiveDate = $xte][@circularForName]">
                                                            <tr>
                                                                <td style="text-align: left;"/>
                                                                <td style="text-align: left;" colspan="3">
                                                                    <xsl:call-template name="showIcon">
                                                                        <xsl:with-param name="which">notice</xsl:with-param>
                                                                    </xsl:call-template>
                                                                    <xsl:text>&#160;</xsl:text>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'tmpCircularReference'"/>
                                                                        <xsl:with-param name="p1">
                                                                            <xsl:call-template name="doShorthandId">
                                                                                <xsl:with-param name="id" select="$xtn"/>
                                                                            </xsl:call-template>
                                                                        </xsl:with-param>
                                                                    </xsl:call-template>
                                                                </td>
                                                            </tr>
                                                        </xsl:when>
                                                    </xsl:choose>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <!-- relationship -->
            <!-- <relationship type="SPEC" model="" template="" flexibility=""/> -->
            <!-- 2DO model resolving comparable problem to transaction/@model -->
            <!-- 2DO implement links to templates/models if possible -->
            <xsl:if test="relationship">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Relationship'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:for-each select="relationship">
                            <xsl:variable name="reid" select="@ref"/>
                            <xsl:variable name="reed" select="@flexibility"/>
                            <xsl:variable name="rccontent" select="if (@type = 'DRIV') then $allScenarios//transaction[@id = $reid][@effectiveDate = $reed] else if (@type = 'ANSW') then $allQuestionnaires[@id = $reid][@effectiveDate = $reed] else ()" as="element()?"/>
                            <xsl:call-template name="getXFormsLabel">
                                <xsl:with-param name="simpleTypeKey" select="'QuestionnaireRelationshipTypes'"/>
                                <xsl:with-param name="simpleTypeValue" select="@type"/>
                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                            </xsl:call-template>
                            <xsl:text>: </xsl:text>
                            <xsl:choose>
                                <xsl:when test="@type = 'DRIV'">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Transaction'"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="@type= 'ANSW'">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Questionnaire'"/>
                                    </xsl:call-template>
                                </xsl:when>
                            </xsl:choose>
                            <xsl:text> </xsl:text>
                            <xsl:choose>
                                <xsl:when test="@template and $seeThisUrlLocation = ('live', 'live-vue')">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'tmpRelationshipLinked'"/>
                                        <xsl:with-param name="p1">
                                            <xsl:choose>
                                                <xsl:when test="@type = 'DRIV'">
                                                    <xsl:value-of select="local:doHtmlName('TR', @url, @ident, $reid, $reed, (), (), (), (), '.html', exists($rccontent))"/>
                                                </xsl:when>
                                                <xsl:when test="@type= 'ANSW'">
                                                    <xsl:variable name="rccontent" select="$allQuestionnaires[@id = $reid][@effectiveDate = $reed]" as="element()*"/>
                                                    <xsl:value-of select="local:doHtmlName('QQ', @url, @ident, $reid, $reed, (), (), (), (), '.html', exists($rccontent))"/>
                                                </xsl:when>
                                            </xsl:choose>
                                        </xsl:with-param>
                                        <xsl:with-param name="p2" select="$reid"/>
                                        <xsl:with-param name="p3" select="concat($rccontent/name[1], ' ')"/>
                                        <xsl:with-param name="p4">
                                            <xsl:choose>
                                                <xsl:when test="$reed castable as xs:dateTime">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="$reed"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'tmpRelationship'"/>
                                        <xsl:with-param name="p1" select="$reid"/>
                                        <xsl:with-param name="p2" select="concat($rccontent/name[1], ' ')"/>
                                        <xsl:with-param name="p3">
                                            <xsl:choose>
                                                <xsl:when test="$reed castable as xs:dateTime">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="$reed"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:apply-templates select="." mode="buildReferenceBox"/>
                            <xsl:if test="position() != last()">
                                <br/>
                            </xsl:if>
                        </xsl:for-each>
                    </td>
                </tr>
            </xsl:if>
            <!-- issues -->
            <xsl:call-template name="check4Issue">
                <xsl:with-param name="id" select="@id"/>
                <xsl:with-param name="effectiveDate" select="@effectiveDate"/>
                <xsl:with-param name="colspans" select="3"/>
            </xsl:call-template>
            <xsl:if test="subjectType">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'SubjectType'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:value-of select="string-join(subjectType/@code, ', ')"/>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="code">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Code'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:for-each select="code">
                            <div>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'codeCodeSystemNameShallBeX-v2'"/>
                                    <xsl:with-param name="p1" select="@code"/>
                                    <xsl:with-param name="p3">
                                        <xsl:choose>
                                            <xsl:when test="@canonicalUri">
                                                <xsl:value-of select="concat(@codeSystem, ' (', @canonicalUri, ')')"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="@codeSystem"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:with-param>
                                </xsl:call-template>
                                <xsl:if test="@displayName">
                                    <xsl:text> - </xsl:text>
                                    <xsl:value-of select="@displayName"/>
                                </xsl:if>
                            </div>
                        </xsl:for-each>
                    </td>
                </tr>
            </xsl:if>
            
            <tr style="vertical-align: top;">
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Available formats'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;" colspan="3">
                    <xsl:for-each select="$projectRestUriFHIR">
                        <xsl:text>FHIR </xsl:text>
                        <xsl:value-of select="tokenize(., '/')[last() - 2]"/>
                        <xsl:text> </xsl:text>
                        <a href="{.}Questionnaire/{encode-for-uri($tid)}--{replace($teff, '\D', '')}?_format=xml">
                            <xsl:call-template name="showIcon">
                                <xsl:with-param name="which">document</xsl:with-param>
                            </xsl:call-template>
                            xml</a>
                        <xsl:text> </xsl:text>
                        <a href="{.}Questionnaire/{encode-for-uri($tid)}--{replace($teff, '\D', '')}?_format=json">
                            <xsl:call-template name="showIcon">
                                <xsl:with-param name="which">document</xsl:with-param>
                            </xsl:call-template>
                            json</a>
                    </xsl:for-each>
                </td>
            </tr>
            
            <!-- render qqitems -->
            <tr style="vertical-align: top;">
                <td style="text-align: left;" colspan="4">
                    <xsl:if test="$switchCreateTreeTableHtml = 'true-not-yet-used'">
                        <div>
                            <button id="expandAll" type="button">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                </xsl:call-template>
                            </button>
                            <button id="collapseAll" type="button">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                </xsl:call-template>
                            </button>
                        </div>
                    </xsl:if>
                    <table id="transactionTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                        <tr>
                            <th class="columnName" style="text-align: left;" width="50%">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Name'"/>
                                </xsl:call-template>
                            </th>
                            <th class="columnDetails" style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Details'"/>
                                </xsl:call-template>
                            </th>
                            <th class="columnDetails" style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Cardinality'"/>
                                </xsl:call-template>
                            </th>
                            <th class="columnNoPrint">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Type'"/>
                                </xsl:call-template>
                            </th>
                            <th class="columnNoPrint">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Id'"/>
                                </xsl:call-template>
                            </th>
                        </tr>
                        <xsl:apply-templates select="item" mode="questionnaire">
                            <xsl:with-param name="level" select="1"/>
                            <xsl:with-param name="tid" select="$tid"/>
                            <xsl:with-param name="ted" select="$teff"/>
                        </xsl:apply-templates>
                    </table>
                </td>
            </tr>
        </table>
    </xsl:template>
    <xsl:template match="item" mode="questionnaire">
        <xsl:param name="level"/>
        <xsl:param name="tid"/>
        <xsl:param name="ted"/>
        <tr xmlns="http://www.w3.org/1999/xhtml">
            <td style="vertical-align: top;">
                <a id="_{$tid}-{replace($ted, '\D', '')}-{@id}"/>
                <table border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <xsl:call-template name="doIndentLevel">
                            <xsl:with-param name="level" select="$level"/>
                        </xsl:call-template>
                        <td style="vertical-align: top;">
                            <xsl:choose>
                                <xsl:when test="@type = 'group'">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which">folder</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="@type = 'display'">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which">info</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="showStatusDot">
                                        <xsl:with-param name="status" select="'draft'"/>
                                        <xsl:with-param name="title" select="''"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                        <td style="vertical-align: top;">
                            <xsl:call-template name="doDescription">
                                <xsl:with-param name="ns" select="text"/>
                                <xsl:with-param name="shortDesc" select="false()"/>
                            </xsl:call-template>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="vertical-align: top;">
                <table border="0" cellspacing="0" cellpadding="0">
                    <xsl:if test="@hiddenItem='true'">
                        <tr>
                            <td class="strong" colspan="2">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'hiddenItem'"/>
                                </xsl:call-template>
                            </td>
                        </tr>
                    </xsl:if>
                    <xsl:if test="@readOnly='true'">
                        <tr>
                            <td class="strong" colspan="2">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'readOnlyItem'"/>
                                </xsl:call-template>
                            </td>
                        </tr>
                    </xsl:if>
                    <xsl:for-each select="enableWhen">
                        <tr>
                            <td class="strong">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'enableWhen'"/>
                                </xsl:call-template>
                            </td>
                            <td>
                                <xsl:value-of select="@question"/>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="@operator"/>
                                <xsl:text> </xsl:text>
                                <xsl:apply-templates select="./node()" mode="enableWhen">
                                    <xsl:with-param name="trid" select="$tid"/>
                                    <xsl:with-param name="tred" select="$ted"/>
                                </xsl:apply-templates>
                            </td>
                        </tr>
                    </xsl:for-each>
                    <xsl:if test="unitOption">
                        <!-- <unitOption canonicalUri="http://unitsofmeasure.org" code="{beats}/min" displayName="/min"/> -->
                        <tr>
                            <td class="strong">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'unitOptions'"/>
                                </xsl:call-template>
                            </td>
                            <td>
                                <ul>
                                    <xsl:for-each select="unitOption">
                                        <li>
                                            <b>
                                                <xsl:value-of select="@displayName"/>
                                            </b>
                                            <xsl:text> - code </xsl:text>
                                            <span style="font-family: Courier, 'Courier New', monospace; ">
                                                <xsl:value-of select="@code"/>
                                            </span>
                                            <xsl:text> [</xsl:text>
                                            <xsl:value-of select="@canonicalUri"/>
                                            <xsl:text>]</xsl:text>
                                        </li>
                                    </xsl:for-each>
                                </ul>
                            </td>
                        </tr>
                    </xsl:if>
                    <xsl:if test="answerOption">
                        <tr>
                            <td class="strong">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'answerOptions'"/>
                                </xsl:call-template>
                            </td>
                            <td>
                                <xsl:for-each select="answerOption">
                                    <xsl:value-of select="*/@value"/>
                                    <xsl:if test="position() &lt; last()">
                                        <xsl:text>, </xsl:text>
                                    </xsl:if>
                                </xsl:for-each>
                            </td>
                        </tr>
                    </xsl:if>
                    <xsl:for-each select="answerValueSet">
                        <tr>
                            <td class="strong">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'answerValueset'"/>
                                </xsl:call-template>
                            </td>
                            <td>
                                <!-- xxxxxxx flexibility="2016-06-23T00:00:00" strength="required" statusCode="final"
                                    ref="2.16.840.1.113883.1.11.1" name="AdministrativeGender" displayName="Administrative Gender (HL7 V3)"/>-->
                                <xsl:if test="not(empty(@strength))">
                                    <span>
                                        <xsl:attribute name="title">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="concat('bindingStrength-', @strength, '-help')"/>
                                            </xsl:call-template>
                                        </xsl:attribute>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="concat('bindingStrength-', @strength)"/>
                                        </xsl:call-template>
                                    </span>
                                </xsl:if>
                                <xsl:text> </xsl:text>
                                <i>
                                    <a href="{local:doHtmlName('VS',@ref,@flexibility,'.html')}" onclick="target='_blank';">
                                        <xsl:value-of select="if (@displayName) then (@displayName) else (@ref)"/>
                                    </a>
                                </i>
                                <xsl:text> (</xsl:text>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'version'"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <xsl:choose>
                                    <xsl:when test="matches(@flexibility, '^\d{4}')">
                                        <xsl:call-template name="showDate">
                                            <xsl:with-param name="date" select="@flexibility"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                        </xsl:call-template>
                                    </xsl:otherwise>
                                </xsl:choose>
                                <xsl:text>)</xsl:text>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </td>
            <td class="card" style="text-align: left;">
                <xsl:variable name="rq">
                    <xsl:choose>
                        <xsl:when test="@required='true'">1</xsl:when>
                        <xsl:otherwise>0</xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="rp">
                    <xsl:choose>
                        <xsl:when test="@repeats='true'">*</xsl:when>
                        <xsl:otherwise>1</xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                <span>
                    <strong>
                        <xsl:value-of select="local:getCardConf($rq, $rp, (), ())"/>
                    </strong>
                </span>
            </td>
            <td style="vertical-align: top;">
                <xsl:value-of select="@type"/>
            </td>
            <td style="vertical-align: top;">
                <xsl:value-of select="@linkId"/>
            </td>
        </tr>
        <xsl:apply-templates select="item" mode="questionnaire">
            <xsl:with-param name="level" select="$level + 1"/>
            <xsl:with-param name="tid" select="$tid"/>
            <xsl:with-param name="ted" select="$ted"/>
        </xsl:apply-templates>
    </xsl:template>
    <xsl:template match="transaction">
        <xsl:variable name="node-id-parent" select="generate-id(parent::*)"/>
        <xsl:variable name="level" select="count(ancestor::scenario | ancestor::transaction) + 1"/>
        <xsl:variable name="trid" select="self::transaction/@id"/>
        <xsl:variable name="tred" select="self::transaction/@effectiveDate"/>
        <xsl:variable name="transactionAnchor" select="local:doHtmlAnchor($trid, $tred)"/>
        <xsl:variable name="node-id-transaction" select="generate-id(.)"/>
        <xsl:variable name="node-color" select="
                if (self::transaction[@type[. = 'group'] | transaction]) then
                    '#fff7f2'
                else
                    'white'"/>
        <!-- ==== Start of transaction (name, direction icon and id) ==== -->
        <tr data-tt-id="{$node-id-transaction}" data-tt-parent-id="{$node-id-parent}" xmlns="http://www.w3.org/1999/xhtml">
            <td class="columnName" style="background-color: {$node-color};" colspan="3">
                <a name="{$transactionAnchor}"/>
                <xsl:variable name="columnName">
                    <xsl:call-template name="showStatusDot">
                        <xsl:with-param name="status" select="@statusCode"/>
                        <xsl:with-param name="title">
                            <xsl:call-template name="getXFormsLabel">
                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                            </xsl:call-template>
                        </xsl:with-param>
                    </xsl:call-template>
                    <xsl:text>&#160;</xsl:text>
                    <xsl:choose>
                        <xsl:when test="self::transaction[@type[. = 'group'] | transaction]">
                            <xsl:call-template name="showIcon">
                                <xsl:with-param name="which">doublearrow</xsl:with-param>
                                <xsl:with-param name="tooltip">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Group'"/>
                                    </xsl:call-template>
                                </xsl:with-param>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                        </xsl:when>
                        <xsl:when test="self::transaction">
                            <xsl:call-template name="showDirection">
                                <xsl:with-param name="dir" select="@type"/>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                        </xsl:when>
                    </xsl:choose>
                    <xsl:call-template name="doName">
                        <xsl:with-param name="ns" select="name"/>
                    </xsl:call-template>
                </xsl:variable>
                <xsl:choose>
                    <xsl:when test="not($switchCreateTreeTableHtml = 'true')">
                        <table style="float: left;">
                            <tr>
                                <xsl:call-template name="doIndentLevel">
                                    <xsl:with-param name="level" select="$level"/>
                                    <xsl:with-param name="icon" select="false()"/>
                                </xsl:call-template>
                                <td>
                                    <xsl:copy-of select="$columnName"/>
                                </td>
                            </tr>
                        </table>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:copy-of select="$columnName"/>
                    </xsl:otherwise>
                </xsl:choose>
                <div style="float: right;">
                    <xsl:call-template name="doShorthandId">
                        <xsl:with-param name="id" select="$trid"/>
                    </xsl:call-template>
                    <!-- diagrams only for transation leaves -->
                    <xsl:if test="self::transaction[@type[. != 'group']] and string-length($projectRestUriDSDiagram) &gt; 0">
                        <a href="{$projectRestUriDSDiagram}&amp;transactionId={$trid}&amp;transactionEffectiveDate={encode-for-uri($tred)}&amp;format=svg" onclick="target='_blank';" style="margin-left: 5px;">
                            <xsl:attribute name="title">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'showDiagram'"/>
                                </xsl:call-template>
                            </xsl:attribute>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'showDiagram'"/>
                            </xsl:call-template>
                        </a>
                    </xsl:if>
                </div>
            </td>
        </tr>
        <!-- ==== Generics for any transaction type ==== -->
        <!-- id / versionLabel / effectiveDate / expirationDate -->
        <tr data-tt-id="{$node-id-transaction}-meta" data-tt-parent-id="{$node-id-transaction}" xmlns="http://www.w3.org/1999/xhtml">
            <td class="columnDetails"/>
            <td class="columnDetails" colspan="2">
                <table cellpadding="5">
                    <tr>
                        <td class="strong" style="padding-left: 0;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'EffectiveDate'"/>
                            </xsl:call-template>
                        </td>
                        <td>
                            <xsl:call-template name="showDate">
                                <xsl:with-param name="date" select="$tred"/>
                            </xsl:call-template>
                            <xsl:if test="@versionLabel">
                                <xsl:text> - </xsl:text>
                                <xsl:value-of select="@versionLabel"/>
                            </xsl:if>
                        </td>
                        <xsl:choose>
                            <xsl:when test="@expirationDate">
                                <td class="strong">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'ExpirationDate'"/>
                                    </xsl:call-template>
                                </td>
                                <td>
                                    <xsl:call-template name="showDate">
                                        <xsl:with-param name="date" select="@expirationDate"/>
                                    </xsl:call-template>
                                </td>
                            </xsl:when>
                            <xsl:otherwise>
                                <td>&#160;</td>
                                <td>&#160;</td>
                            </xsl:otherwise>
                        </xsl:choose>
                    </tr>
                    <xsl:if test="@model | @label">
                        <tr>
                            <xsl:if test="@model">
                                <td class="strong" style="padding-left: 0;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Model'"/>
                                    </xsl:call-template>
                                </td>
                                <td colspan="{if (@label) then 1 else 3}">
                                    <xsl:value-of select="@model"/>
                                </td>
                            </xsl:if>
                            <xsl:if test="@label">
                                <td class="strong">
                                    <xsl:if test="not(@model)">
                                        <xsl:attribute name="style">padding-left: 0;</xsl:attribute>
                                    </xsl:if>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Label'"/>
                                    </xsl:call-template>
                                </td>
                                <td colspan="{if (@model) then 1 else 3}">
                                    <xsl:value-of select="normalize-space(@label)"/>
                                </td>
                            </xsl:if>
                        </tr>
                    </xsl:if>
                </table>
            </td>
        </tr>
        <!-- ==== Specifics of description (groups loop into content, other transactions get documented internally) ==== -->
        <xsl:if test="@type[. = 'group'] | transaction">
            <xsl:if test="$switchCreateDocSVG = true()">
                <xsl:variable name="tgId" select="@id"/>
                <!-- If we created at least one SVG, assume its the functional variant -->
                <xsl:if test="count($allSvg/transaction[@id = $tgId]/*) &gt; 0">
                    <tr data-tt-id="{$node-id-transaction}-svg" data-tt-parent-id="{$node-id-transaction}" xmlns="http://www.w3.org/1999/xhtml">
                        <td class="columnDetails"/>
                        <td class="columnDetails tabtab" colspan="2">
                            <img src="{local:doHtmlName('TR',@id,@effectiveDate,'_functional.svg')}">
                                <xsl:attribute name="alt">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'needBrowserWithSvgSupport'"/>
                                    </xsl:call-template>
                                </xsl:attribute>
                            </img>
                        </td>
                    </tr>
                </xsl:if>
            </xsl:if>
        </xsl:if>
        <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
            <tr data-tt-id="{$node-id-transaction}-desc" data-tt-parent-id="{$node-id-transaction}" xmlns="http://www.w3.org/1999/xhtml">
                <td class="columnDetails"/>
                <td class="columnDetails strong" style="vertical-align: top; width: 5%;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Description'"/>
                    </xsl:call-template>
                </td>
                <td class="columnDetails">
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="desc"/>
                    </xsl:call-template>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="trigger">
            <tr data-tt-id="{$node-id-transaction}-trigger" data-tt-parent-id="{$node-id-transaction}" xmlns="http://www.w3.org/1999/xhtml">
                <td class="columnDetails"/>
                <td class="columnDetails strong" style="vertical-align: top; width: 5%;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'transactionTrigger'"/>
                    </xsl:call-template>
                </td>
                <td class="columnDetails">
                    <xsl:if test="trigger[@id]">
                        <div>
                            <span class="strong">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Id'"/>
                                </xsl:call-template>
                            </span>
                            <xsl:text>: </xsl:text>
                            <xsl:value-of select="trigger/@id[1]"/>
                        </div>
                    </xsl:if>
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="trigger"/>
                    </xsl:call-template>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="condition">
            <tr data-tt-id="{$node-id-transaction}-condition" data-tt-parent-id="{$node-id-transaction}" xmlns="http://www.w3.org/1999/xhtml">
                <td class="columnDetails"/>
                <td class="columnDetails strong" style="vertical-align: top; width: 5%;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'transactionCondition'"/>
                    </xsl:call-template>
                </td>
                <td class="columnDetails">
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="condition"/>
                    </xsl:call-template>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="dependencies">
            <tr data-tt-id="{$node-id-transaction}-dependencies" data-tt-parent-id="{$node-id-transaction}" xmlns="http://www.w3.org/1999/xhtml">
                <td class="columnDetails"/>
                <td class="columnDetails strong" style="vertical-align: top; width: 5%;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'transactionDependencies'"/>
                    </xsl:call-template>
                </td>
                <td class="columnDetails">
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="dependencies"/>
                    </xsl:call-template>
                </td>
            </tr>
        </xsl:if>
        <!-- ==== Specifics of description (groups loop into content, other transactions get documented internally) ==== -->
        <xsl:choose>
            <xsl:when test="@type[. = 'group'] | transaction">
                <xsl:apply-templates select="transaction"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:if test="actors/actor">
                    <tr data-tt-id="{$node-id-transaction}-actor" data-tt-parent-id="{$node-id-transaction}" xmlns="http://www.w3.org/1999/xhtml">
                        <td class="columnDetails"/>
                        <td class="columnDetails strong" style="vertical-align: top; width: 5%;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Actor'"/>
                            </xsl:call-template>
                        </td>
                        <td class="columnDetails" style="vertical-align: top;">
                            <xsl:for-each select="actors/actor">
                                <xsl:variable name="aid" select="@id"/>
                                <xsl:variable name="theActor" select="$allActors//actor[@id = $aid]"/>
                                <div>
                                    <xsl:attribute name="title">
                                        <xsl:call-template name="doDescription">
                                            <xsl:with-param name="ns" select="$theActor/desc"/>
                                        </xsl:call-template>
                                    </xsl:attribute>
                                    <xsl:choose>
                                        <xsl:when test="@role = ('sender', 'receiver')">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="concat('actorRole-', @role)"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="@role"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text> (</xsl:text>
                                    <xsl:choose>
                                        <xsl:when test="$theActor/@type = ('device', 'person', 'organization')">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="concat('actorType-', $theActor/@type)"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="$theActor/@type"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>) </xsl:text>
                                    <xsl:call-template name="doName">
                                        <xsl:with-param name="ns" select="$theActor/name"/>
                                    </xsl:call-template>
                                </div>
                            </xsl:for-each>
                        </td>
                    </tr>
                </xsl:if>
                <xsl:for-each select="representingTemplate[@sourceDataset | @ref]">
                    <xsl:variable name="dsid" select="@sourceDataset"/>
                    <xsl:variable name="dsed" select="(@sourceDatasetFlexibility[. castable as xs:dateTime], 'dynamic')[1]"/>
                    <xsl:variable name="dataset" select="local:getDataset(string($dsid), $dsed)" as="element()?"/>
                    <xsl:variable name="tmid" select="@ref"/>
                    <xsl:variable name="tmed" select="(@flexibility[. castable as xs:dateTime], 'dynamic')[1]"/>
                    <xsl:variable name="rccontent" as="element()?">
                        <xsl:call-template name="getRulesetContent">
                            <xsl:with-param name="ruleset" select="$tmid"/>
                            <xsl:with-param name="flexibility" select="$tmed"/>
                            <xsl:with-param name="sofar" select="()"/>
                        </xsl:call-template>
                    </xsl:variable>
                    <xsl:variable name="tmname">
                        <xsl:choose>
                            <xsl:when test="$rccontent[@displayName]">
                                <xsl:value-of select="$rccontent/@displayName"/>
                            </xsl:when>
                            <xsl:when test="$rccontent[@name]">
                                <xsl:value-of select="$rccontent/@name"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$tmid"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="reptc" select="."/>
                    <tr data-tt-id="{$node-id-transaction}-reptemp" data-tt-parent-id="{$node-id-transaction}" xmlns="http://www.w3.org/1999/xhtml">
                        <td class="columnDetails"/>
                        <td class="columnDetails strong" style="vertical-align: top;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Associations'"/>
                            </xsl:call-template>
                        </td>
                        <td class="columnDetails">
                            <xsl:if test="$dsid">
                                <div>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'dataSetDataSetForTransaction'"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <a href="{local:doHtmlName('TR',$trid,$tred,'.html')}" onclick="target='_blank';">
                                        <xsl:call-template name="doName">
                                            <xsl:with-param name="ns" select="$dataset/name"/>
                                        </xsl:call-template>
                                        <xsl:if test="$dataset[@versionLabel]">
                                            <xsl:text> </xsl:text>
                                            <xsl:value-of select="$dataset/@versionLabel"/>
                                        </xsl:if>
                                        <i>
                                            <xsl:text>(</xsl:text>
                                            <xsl:value-of select="$dsid"/>
                                            <xsl:text> / </xsl:text>
                                            <xsl:choose>
                                                <xsl:when test="$dsed castable as xs:dateTime">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="$dsed"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            <xsl:text>)</xsl:text>
                                        </i>
                                    </a>
                                </div>
                            </xsl:if>
                            <xsl:if test="$tmid">
                                <div>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Template'"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <a href="{local:doHtmlName('TM',$rccontent/(@id | @ref),$tmed,'.html')}" onclick="target='_blank';">
                                        <xsl:value-of select="$tmname"/>
                                        <xsl:text> </xsl:text>
                                        <i>
                                            <xsl:text>(</xsl:text>
                                            <xsl:if test="$rccontent">
                                                <xsl:value-of select="$rccontent/(@id | @ref)"/>
                                                <xsl:text> / </xsl:text>
                                            </xsl:if>
                                            <xsl:choose>
                                                <xsl:when test="$tmed castable as xs:dateTime">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="$tmed"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            <xsl:text>)</xsl:text>
                                        </i>
                                    </a>
                                </div>
                                <xsl:if test="$createDefaultInstancesForRepresentingTemplates = true()">
                                    <div>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'defaultInstance'"/>
                                        </xsl:call-template>
                                        <xsl:text> </xsl:text>
                                        <a href="{local:doHtmlName('TR',$trid,$tred,'_instance.html')}" onclick="target='_blank';">
                                            <xsl:value-of select="$tmname"/>
                                            <xsl:text> </xsl:text>
                                            <i>
                                                <xsl:text>(</xsl:text>
                                                <xsl:if test="$rccontent">
                                                    <xsl:value-of select="$rccontent/(@id | @ref)"/>
                                                    <xsl:text> / </xsl:text>
                                                </xsl:if>
                                                <xsl:choose>
                                                    <xsl:when test="$tmed castable as xs:dateTime">
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="$tmed"/>
                                                        </xsl:call-template>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                        </xsl:call-template>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                                <xsl:text>)</xsl:text>
                                            </i>
                                        </a>
                                    </div>
                                </xsl:if>
                            </xsl:if>
                        </td>
                    </tr>
                    <xsl:if test="$dataset and concept">
                        <!-- prepare toggling -->
                        <xsl:variable name="elid" select="local:randomString2(., ())"/>
                        <tr data-tt-id="{$node-id-transaction}-concepts" data-tt-parent-id="{$node-id-transaction}" xmlns="http://www.w3.org/1999/xhtml">
                            <td class="columnDetails"/>
                            <td class="columnDetails" colspan="2" style="vertical-align: top;">
                                <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                    <xsl:attribute name="class" select="'toggler'"/>
                                    <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                </xsl:if>
                                <span class="strong">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'ContainedConcepts'"/>
                                    </xsl:call-template>
                                </span>
                            </td>
                        </tr>
                        <!-- create the dataset filtered with concept mentioned in the representingTemplate only -->
                        <xsl:variable name="filtereddataset" as="element()">
                            <xsl:variable name="tmp1" as="element()">
                                <tmp xmlns="">
                                    <xsl:apply-templates select="$dataset/concept" mode="filter">
                                        <xsl:with-param name="representingTemplate" select="$reptc"/>
                                    </xsl:apply-templates>
                                </tmp>
                            </xsl:variable>
                            <filtereddataset xmlns="">
                                <xsl:copy-of select="* except concept"/>
                                <xsl:apply-templates select="$tmp1/concept" mode="eliminatedHiddenConcepts"/>
                            </filtereddataset>
                        </xsl:variable>
                        <tr data-tt-id="{$node-id-transaction}-contents" data-tt-parent-id="{$node-id-transaction}-concepts" xmlns="http://www.w3.org/1999/xhtml">
                            <td class="columnDetails"/>
                            <td class="columnDetails tabtab" colspan="2" style="vertical-align: top;">
                                <div id="{$elid}">
                                    <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                        <xsl:attribute name="style" select="'display: none;'"/>
                                    </xsl:if>
                                    <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                        <tr>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Concept'"/>
                                                </xsl:call-template>
                                            </th>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'cardinalityConformanceLabel'"/>
                                                </xsl:call-template>
                                            </th>
                                            <th>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Id'"/>
                                                </xsl:call-template>
                                            </th>
                                        </tr>
                                        <xsl:apply-templates select="$filtereddataset/concept" mode="scenarioview">
                                            <xsl:with-param name="level" select="0"/>
                                            <xsl:with-param name="trid" select="$trid"/>
                                            <xsl:with-param name="tred" select="$tred"/>
                                        </xsl:apply-templates>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </xsl:if>
                </xsl:for-each>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="concept" mode="scenarioview">
        <xsl:param name="level"/>
        <xsl:param name="trid"/>
        <xsl:param name="tred"/>
        <xsl:variable name="conditionals" as="element()">
            <conditionals xmlns="">
                <!-- copy the extra pre-processed conditions -->
                <xsl:copy-of select="conditionalConcept"/>
            </conditionals>
        </xsl:variable>
        <tr xmlns="http://www.w3.org/1999/xhtml">
            <td style="vertical-align: top;">
                <a id="_{$trid}-{replace($tred, '\D', '')}-{@id}"/>
                <table border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <xsl:call-template name="doIndentLevel">
                            <xsl:with-param name="level" select="$level"/>
                        </xsl:call-template>
                        <td style="vertical-align: top;">
                            <xsl:choose>
                                <xsl:when test="@type = 'group'">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which">folder</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="@type = 'item'">
                                    <xsl:call-template name="showStatusDot">
                                        <xsl:with-param name="status" select="@statusCode"/>
                                        <xsl:with-param name="title">
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                    <xsl:text>&#160;</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="@type"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                        <td style="vertical-align: top;">
                            <xsl:choose>
                                <xsl:when test="@conformance = 'NP'">
                                    <strike>
                                        <xsl:call-template name="doName">
                                            <xsl:with-param name="ns" select="name"/>
                                        </xsl:call-template>
                                    </strike>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="doName">
                                        <xsl:with-param name="ns" select="name"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </tr>
                </table>
            </td>
            <td class="card" style="text-align: left;">
                <b>
                    <xsl:value-of select="local:getCardConf(., $defaultLanguage)"/>
                </b>
            </td>
            <td style="vertical-align: top;">
                <div style="float: right;">
                    <xsl:choose>
                        <xsl:when test="@iddisplay">
                            <xsl:value-of select="@iddisplay"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="doShorthandId">
                                <xsl:with-param name="id" select="@id"/>
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:if test="string-length($projectRestUriDSDiagram) &gt; 0">
                        <a href="{$projectRestUriDSDiagram}&amp;id={@id|@ref}&amp;effectiveDate{encode-for-uri(@effectiveDate|@flexibility)}&amp;transactionId={$trid}&amp;transactionEffectiveDate={encode-for-uri($tred)}&amp;format=svg" onclick="target='_blank';" style="margin-left: 5px;">
                            <xsl:attribute name="title">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'showDiagram'"/>
                                </xsl:call-template>
                            </xsl:attribute>
                            <xsl:text>link</xsl:text>
                        </a>
                    </xsl:if>
                </div>
            </td>
        </tr>
        <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]] | operationalization">
            <tr xmlns="http://www.w3.org/1999/xhtml">
                <td style="vertical-align: top;"/>
                <td colspan="2">
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="desc"/>
                    </xsl:call-template>
                    <xsl:if test="count(operationalization) &gt; 0">
                        <xsl:value-of select="operationalization[1]"/>
                    </xsl:if>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="$conditionals[*]">
            <tr xmlns="http://www.w3.org/1999/xhtml">
                <td/>
                <td colspan="2" style="vertical-align: top;">
                    <xsl:apply-templates select="$conditionals"/>
                </td>
            </tr>
        </xsl:if>
        <!-- Obligations -->
        <xsl:if test="obligation">
            <tr xmlns="http://www.w3.org/1999/xhtml">
                <td style="vertical-align: top;"/>
                <td colspan="2">
                    <table cellspacing="0" cellpadding="0" style="width: 100%; border: 0;">
                        <tr>
                            <td class="tabtab">
                                <!---->
                                <xsl:call-template name="doObligation">
                                    <xsl:with-param name="ns" select="obligation"/>
                                </xsl:call-template>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </xsl:if>
        <xsl:if test="enableWhen">
            <tr xmlns="http://www.w3.org/1999/xhtml">
                <td/>
                <td colspan="2" style="vertical-align: top;">
                    <xsl:apply-templates select="." mode="enableWhen">
                        <xsl:with-param name="trid" select="$trid"/>
                        <xsl:with-param name="tred" select="$tred"/>
                    </xsl:apply-templates>
                </td>
            </tr>
        </xsl:if>
        <!--<tr>
            <td/>
            <td colspan="2" style="vertical-align: top; border-bottom: 1px solid #ECE9E4;">&#160;</td>
        </tr>-->
        <xsl:apply-templates select="concept" mode="scenarioview">
            <xsl:with-param name="level" select="$level + 1"/>
            <xsl:with-param name="trid" select="$trid"/>
            <xsl:with-param name="tred" select="$tred"/>
        </xsl:apply-templates>
    </xsl:template>
    <xsl:template match="conditionals">
        <xsl:if test="conditionalConcept">
            <table cellspacing="0" cellpadding="0" style="width: 100%; border: 0;" xmlns="http://www.w3.org/1999/xhtml">
                <tr>
                    <td class="tabtab">
                        <!---->
                        <table width="100%" border="0" cellspacing="3" cellpadding="2">
                            <tr>
                                <th style="width: 125px;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'cardinalityConformanceLabel'"/>
                                    </xsl:call-template>
                                </th>
                                <th style=" vertical-align: top;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'conditionLabel'"/>
                                    </xsl:call-template>
                                </th>
                            </tr>
                            <xsl:for-each select="conditionalConcept">
                                <tr>
                                    <td class="card" style="width: 125px; text-align: left;">
                                        <xsl:value-of select="local:getCardConf(., $defaultLanguage)"/>
                                    </td>
                                    <td style=" vertical-align: top;">
                                        <xsl:choose>
                                            <xsl:when test="desc">
                                                <xsl:call-template name="doDescription">
                                                    <xsl:with-param name="ns" select="desc"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:when test="string-length(text()) = 0">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'otherwise'"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="text()"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </td>
                                </tr>
                            </xsl:for-each>
                        </table>
                        <!---->
                    </td>
                </tr>
            </table>
        </xsl:if>
    </xsl:template>
    <xsl:template match="concept" mode="enableWhen">
        <xsl:param name="trid" select="ancestor::transaction[1]/@id"/>
        <xsl:param name="tred" select="ancestor::transaction[1]/@effectiveDate"/>
        <xsl:if test="enableWhen">
            <table cellspacing="0" cellpadding="0" style="width: 100%; border: 0;" xmlns="http://www.w3.org/1999/xhtml">
                <tr>
                    <td class="tabtab">
                        <table width="100%" border="0" cellspacing="3" cellpadding="2">
                            <tr>
                                <th>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'enableWhen'"/>
                                    </xsl:call-template>
                                    <xsl:if test="count(enableWhen) gt 1">
                                        <xsl:text>: </xsl:text>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="concat('enableBehavior', (@enableBehavior, 'undefined')[1])"/>
                                        </xsl:call-template>
                                    </xsl:if>
                                </th>
                            </tr>
                            <xsl:for-each select="enableWhen">
                                <xsl:variable name="theReffedConcept" select="../../concept[@id = current()/@question]"/>
                                <tr>
                                    <td style=" vertical-align: top;">
                                        <xsl:text>"</xsl:text>
                                        <a href="#_{$trid}-{replace($tred, '\D', '')}-{@question}" title="{string-join($theReffedConcept/ancestor-or-self::concept/name[1], ' / '), ' - ',@question}"><xsl:value-of select="($theReffedConcept/name, @question)[1]"/></a>
                                        <xsl:text>" </xsl:text>
                                        <xsl:value-of select="@operator"/>
                                        <xsl:text> </xsl:text>
                                        <xsl:apply-templates select="answerBoolean | answerDecimal | answerInteger | answerDate | answerDateTime | answerTime | answerString | answerCoding | answerQuantity" mode="enableWhen"/>
                                    </td>
                                </tr>
                            </xsl:for-each>
                        </table>
                        <!---->
                    </td>
                </tr>
            </table>
        </xsl:if>
    </xsl:template>
    <xsl:template match="answerBoolean | answerDecimal | answerInteger | answerDate | answerDateTime | answerTime | answerString" mode="enableWhen">
        <xsl:value-of select="@value"/>
    </xsl:template>
    <xsl:template match="answerCoding" mode="enableWhen">
        <xsl:variable name="theCSN" as="xs:string*">
            <xsl:call-template name="getIDDisplayName">
                <xsl:with-param name="root" select="@codeSystem"/>
            </xsl:call-template>
        </xsl:variable>
        
        <xsl:value-of select="@code"/>
        <xsl:text> </xsl:text>
        <span title="{$theCSN}"><xsl:value-of select="@codeSystem"/></span>
        <xsl:text> </xsl:text>
        <xsl:value-of select="@displayName"/>
        <xsl:if test="string-length(@canonicalUri) &gt; 0">
            <xsl:text> - FHIR: </xsl:text>
            <i>
                <xsl:value-of select="@canonicalUri"/>
            </i>
        </xsl:if>
    </xsl:template>
    <xsl:template match="answerQuantity" mode="enableWhen">
        <xsl:variable name="theCSN" as="xs:string*">
            <xsl:call-template name="getIDDisplayName">
                <xsl:with-param name="root" select="@codeSystem"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:value-of select="@comparator"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="@value"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="@unit"/>
        <xsl:if test="@code">
            <xsl:text> (</xsl:text>
                <xsl:value-of select="@code"/>
                <xsl:text> </xsl:text>
                <span title="{$theCSN}"><xsl:value-of select="@codeSystem"/></span>
                <xsl:if test="string-length(@canonicalUri) &gt; 0">
                    <xsl:text> - FHIR: </xsl:text>
                    <i>
                        <xsl:value-of select="@canonicalUri"/>
                    </i>
                </xsl:if>
            <xsl:text>)</xsl:text>
        </xsl:if>
    </xsl:template>
    <xsl:template match="attribute" mode="templateparticle">
        <xsl:param name="level"/>
        <!-- item label -->
        <xsl:param name="label" as="element()?"/>
        <xsl:param name="parent-id" as="xs:string?" required="yes"/>
        <xsl:param name="sofar" select="()"/>
        <xsl:param name="templateFormat" as="xs:string?"/>
        <xsl:variable name="itemlabel" as="element()?">
            <xsl:choose>
                <xsl:when test="item[string-length(@label) &gt; 0]">
                    <!-- use current item/@label -->
                    <item xmlns="" label="{replace(string(item/@label), '-', '‑')}">
                        <xsl:copy-of select="item/desc"/>
                    </item>
                </xsl:when>
                <!--<xsl:when test="$label[string-length(@label)&gt;0]">
                    <!-\- use inherited label if present -\->
                    <xsl:copy-of select="$label"/>
                </xsl:when>-->
                <xsl:otherwise>
                    <!-- use leave it empty -->
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!-- cache attribute isOptional, datatytpe, value, vocabulary -->
        <xsl:variable name="elmDatatype" select="parent::element/@datatype"/>
        <xsl:variable name="isOptional" select="@isOptional = 'true'" as="xs:boolean"/>
        <xsl:variable name="prohibited" select="@prohibited = 'true'" as="xs:boolean"/>
        <xsl:variable name="theDatatype" select="@datatype"/>
        <xsl:variable name="theStrength" select="@strength"/>
        <xsl:variable name="descriptions" select="desc"/>
        <xsl:variable name="vocabulary" select="vocabulary"/>
        <xsl:variable name="property" select="property"/>
        <xsl:for-each select="@name | @classCode | @contextConductionInd | @contextControlCode | @determinerCode | @extension | @independentInd | @institutionSpecified | @inversionInd | @mediaType | @moodCode | @negationInd | @nullFlavor | @operator | @qualifier | @representation | @root | @typeCode | @unit | @use">
            <!-- cache attribute name and value of attribute -->
            <xsl:variable name="theName" select="name()"/>
            <xsl:variable name="theAttName" select="
                    if (name() = 'name') then
                        (.)
                    else
                        (name())"/>
            <xsl:variable name="theAttValue" select="
                    if (name() = 'name') then
                        (../@value)
                    else
                        (.)"/>
            <xsl:variable name="node-id" select="concat(generate-id(.), '-', position())"/>
            <xsl:variable name="theDescription" as="item()*">
                <xsl:choose>
                    <xsl:when test="$prohibited">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'conformanceNotPresent'"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:when test="$theAttName = 'xsi:type' and (starts-with($elmDatatype, 'SD.TEXT') or starts-with($elmDatatype, 'StrucDoc.Text'))">
                        <!-- In DTr1, xsi:type for CDA Narrative Block is 'StrucDoc.Text', but DECOR carries 'SD.TEXT' -->
                        <xsl:value-of select="'StrucDoc.Text'"/>
                    </xsl:when>
                    <xsl:when test="$theAttName = 'xsi:type' and string-length($elmDatatype) > 0">
                        <!-- In DTr1, xsi:type should not be a flavorId, but the real datatype -->
                        <xsl:value-of select="tokenize($elmDatatype, '\.')[1]"/>
                    </xsl:when>
                    <xsl:when test="$theAttName = 'xsi:type' and string-length($theAttValue) > 0">
                        <!-- In DTr1, xsi:type should not be a flavorId, but the real datatype -->
                        <xsl:value-of select="tokenize($theAttValue, '\.')[1]"/>
                    </xsl:when>
                    <xsl:when test="contains($theAttValue, '|')">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'attribShallChoice'"/>
                            <xsl:with-param name="p1" select="$theAttName"/>
                        </xsl:call-template>
                        <ul xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:for-each select="tokenize($theAttValue, '\|')">
                                <li>
                                    <xsl:value-of select="."/>
                                </li>
                            </xsl:for-each>
                        </ul>
                    </xsl:when>
                    <xsl:when test="string-length($theAttValue) > 0">
                        <xsl:value-of select="$theAttValue"/>
                    </xsl:when>
                </xsl:choose>
            </xsl:variable>
            <tr style="vertical-align: top;" data-tt-id="{$node-id}" xmlns="http://www.w3.org/1999/xhtml">
                <xsl:if test="string-length($parent-id) > 0">
                    <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                </xsl:if>
                <td class="columnName" style="vertical-align: top;">
                    <xsl:if test="../@id">
                        <a name="{local:doHtmlAnchor(../@id, ())}"/>
                    </xsl:if>
                    <xsl:choose>
                        <xsl:when test="$switchCreateTreeTableHtml = 'true'">
                            <xsl:call-template name="outputPath">
                                <xsl:with-param name="pathname" select="concat('@', $theAttName)"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                            <table cellpadding="1" style="border: 0;">
                                <tr>
                                    <xsl:call-template name="doIndentLevel">
                                        <xsl:with-param name="level" select="$level"/>
                                    </xsl:call-template>
                                    <td>
                                        <xsl:call-template name="outputPath">
                                            <xsl:with-param name="pathname" select="concat('@', $theAttName)"/>
                                        </xsl:call-template>
                                    </td>
                                </tr>
                            </table>
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
                <td class="dt">
                    <!-- data type if given -->
                    <xsl:if test="string-length($theDatatype) &gt; 0">
                        <xsl:value-of select="$theDatatype"/>
                    </xsl:if>
                </td>
                <!-- cardinality 0..1 or 1..1 or not present -->
                <td class="card">
                    <xsl:choose>
                        <xsl:when test="$prohibited">
                            <xsl:text>0</xsl:text>
                        </xsl:when>
                        <xsl:when test="$isOptional">
                            <span>
                                <strong>
                                    <xsl:value-of select="local:getCardConf('0', '1', (), ())"/>
                                </strong>
                            </span>
                        </xsl:when>
                        <xsl:otherwise>
                            <span>
                                <strong>
                                    <xsl:value-of select="local:getCardConf('1', '1', (), ())"/>
                                </strong>
                            </span>
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
                <!-- conformance -->
                <td>
                    <xsl:choose>
                        <!-- choice -->
                        <xsl:when test="$prohibited">
                            <xsl:text>NP</xsl:text>
                        </xsl:when>
                        <xsl:when test="$theAttName = 'xsi:type' and string-length($elmDatatype) &gt; 0">
                            <xsl:text>F</xsl:text>
                        </xsl:when>
                        <xsl:when test="not($isOptional) and string-length($theAttValue) = 0">
                            <xsl:text>R</xsl:text>
                        </xsl:when>
                        <xsl:when test="string-length($theAttValue) = 0">
                            <xsl:text>&#160;</xsl:text>
                        </xsl:when>
                        <xsl:when test="not(contains($theAttValue, '|')) or not($theName = 'name')">
                            <xsl:text>F</xsl:text>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text>&#160;</xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
                <td style="vertical-align: top;">
                    <xsl:if test="empty($itemlabel)">
                        <xsl:attribute name="colspan" select="2"/>
                    </xsl:if>
                    <xsl:choose>
                        <xsl:when test="empty($theDescription)">
                            <xsl:call-template name="doDescription">
                                <xsl:with-param name="ns" select="$descriptions"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:copy-of select="$theDescription"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
                <!-- show item label -->
                <xsl:if test="$itemlabel[string-length(@label) &gt; 0]">
                    <td style="background-color: #FFEEEE;">
                        <span>
                            <xsl:attribute name="title">
                                <xsl:call-template name="doDescription">
                                    <xsl:with-param name="ns" select="$itemlabel/desc"/>
                                </xsl:call-template>
                            </xsl:attribute>
                            <!-- shorten the label if it does not contain any spaces -->
                            <xsl:choose>
                                <xsl:when test="matches($itemlabel/@label, '\s')">
                                    <xsl:value-of select="replace($itemlabel/@label, '-', '‑')"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="doLabelMiracle">
                                        <xsl:with-param name="labelcandidate" select="$itemlabel/@label"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </span>
                    </td>
                </xsl:if>
            </tr>
            <xsl:if test="not(empty($theDescription)) and $descriptions">
                <tr style="vertical-align: top;" data-tt-id="{$node-id}-desc" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                    <td style="background-color: white;" colspan="4">&#160;</td>
                    <td colspan="2">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="$descriptions"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- do vocabulary or name+value of attribute -->
            <xsl:if test="$theName = 'name' and count($vocabulary) &gt; 0">
                <!-- only attributes with a name may have a vocabulary or property -->
                <tr style="vertical-align: top;" data-tt-id="{$node-id}-voc" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                    <td style="background-color: white;" colspan="1">&#160;</td>
                    <td class="conf">
                        <xsl:text>CONF</xsl:text>
                    </td>
                    <td colspan="4">
                        <table width="100%" border="0" cellspacing="2" cellpadding="2">
                            <xsl:for-each select="$vocabulary">
                                <xsl:call-template name="doVocabularyAttributes">
                                    <xsl:with-param name="targetAttributeName" select="$theAttName"/>
                                    <xsl:with-param name="theStrength" select="$theStrength"/>
                                    <xsl:with-param name="templateFormat" select="$templateFormat"/>
                                </xsl:call-template>
                                <xsl:if test="position() != last()">
                                    <tr style="vertical-align: top;">
                                        <td>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'orWord'"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:if>
                            </xsl:for-each>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <xsl:apply-templates select="$property" mode="templateparticle">
                <xsl:with-param name="parent-id" select="$node-id"/>
                <xsl:with-param name="sofar" select="()"/>
            </xsl:apply-templates>
        </xsl:for-each>
        <xsl:apply-templates select=".[@id]" mode="doConnectedConcepts">
            <xsl:with-param name="parent-id" select="$parent-id"/>
        </xsl:apply-templates>
    </xsl:template>
    <xsl:template match="element | include | choice" mode="templateparticle">
        <xsl:param name="level"/>
        <xsl:param name="parent-id" as="xs:string?" required="yes"/>
        <!-- item label -->
        <xsl:param name="label" as="element()?"/>
        <xsl:param name="inheritedminimumMultiplicity"/>
        <xsl:param name="inheritedmaximumMultiplicity"/>
        <xsl:param name="inheritedConformance"/>
        <xsl:param name="inheritedIsMandatory"/>
        <xsl:param name="sofar" as="xs:string*" required="yes"/>
        <xsl:param name="templateFormat" as="xs:string?"/>
        <xsl:variable name="itemlabel" as="element()?">
            <xsl:choose>
                <xsl:when test="item[string-length(@label) &gt; 0]">
                    <!-- use current item/@label -->
                    <item xmlns="" label="{replace(string(item/@label), '-', '‑')}">
                        <xsl:copy-of select="item/desc"/>
                    </item>
                </xsl:when>
                <xsl:when test="$label[string-length(@label) &gt; 0]">
                    <!-- use inherited label if present -->
                    <xsl:copy-of select="$label"/>
                </xsl:when>
                <xsl:otherwise>
                    <!-- use leave it empty -->
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="node-id" select="generate-id(.)"/>
        <!-- solve references to concept defintions regarding multiplicity, conformance -->
        <!-- AH: deactivated. Not only does reference not exist anymore, it also disregards multiple connections through templateAssociation/concept -->
        <!--xsl:variable name="cid" select="references/@concept"/-->
        <xsl:variable name="cid" select="'bogus'"/>
        <xsl:variable name="tid" select="(ancestor-or-self::template/@id)[last()]"/>
        <xsl:variable name="tnm" select="(ancestor-or-self::template/@name)[last()]"/>
        <xsl:variable name="teff" select="(ancestor-or-self::template/@effectiveDate)[last()]"/>
        <xsl:variable name="templateIsNewest" select="$allTemplates/*/ref[template[@id = $tid][@effectiveDate = $teff]]/@newestForId"/>
        <xsl:variable name="rpt" select="$allScenarios//representingTemplate[@ref = $tid or @ref = $tnm][((not(@flexibility) or @flexibility = 'dynamic') and string($templateIsNewest[1]) = 'true') or @flexibility = $teff]"/>
        <!-- get the cardinalities conformances etc -->
        <xsl:variable name="minimumMultiplicity">
            <xsl:choose>
                <xsl:when test="string-length($inheritedminimumMultiplicity) &gt; 0">
                    <xsl:value-of select="$inheritedminimumMultiplicity"/>
                </xsl:when>
                <xsl:when test="string-length(@minimumMultiplicity) &gt; 0">
                    <xsl:value-of select="@minimumMultiplicity"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="()"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="maximumMultiplicity">
            <xsl:choose>
                <xsl:when test="string-length($inheritedmaximumMultiplicity) &gt; 0">
                    <xsl:value-of select="$inheritedmaximumMultiplicity"/>
                </xsl:when>
                <xsl:when test="string-length(@maximumMultiplicity) &gt; 0">
                    <xsl:value-of select="@maximumMultiplicity"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="()"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="isMandatory">
            <xsl:choose>
                <xsl:when test="string-length($inheritedIsMandatory) gt 0">
                    <xsl:value-of select="$inheritedIsMandatory"/>
                </xsl:when>
                <!--xsl:when test="string-length($rpt/concept[@id=$cid]/@isMandatory)>0">
                    <xsl:value-of select="$rpt/concept[@id=$cid]/@isMandatory"/>
                </xsl:when-->
                <xsl:when test="string-length(@isMandatory) &gt; 0">
                    <xsl:value-of select="@isMandatory"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="()"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="conformance">
            <xsl:choose>
                <xsl:when test="string-length($inheritedConformance) &gt; 0">
                    <xsl:value-of select="$inheritedConformance"/>
                </xsl:when>
                <!--xsl:when test="string-length($rpt/concept[@id=$cid]/@conformance)>0">
                    <xsl:value-of select="$rpt/concept[@id=$cid]/@conformance"/>
                </xsl:when-->
                <xsl:when test="string-length(@conformance) &gt; 0">
                    <xsl:value-of select="@conformance"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="()"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!-- original multiplicity and conformance, 2DO only if different from inherited cardinality -->
        <xsl:variable name="cardFont">
            <xsl:choose>
                <!-- if calc cards has been shown already, orig cardinality is shown in grey font only... -->
                <!--xsl:when test="count($cid)>0">
                                <xsl:text>gray</xsl:text>
                            </xsl:when-->
                <xsl:when test="0 = 1"/>
                <!-- ...black otherwise -->
                <xsl:otherwise>
                    <xsl:text>color: black;</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!-- get a possible include candidate -->
        <xsl:variable name="xref">
            <xsl:choose>
                <xsl:when test="self::element[@contains]">
                    <xsl:value-of select="@contains"/>
                </xsl:when>
                <xsl:when test="self::include">
                    <xsl:value-of select="@ref"/>
                </xsl:when>
                <xsl:otherwise>
                    <!-- deprecated -->
                    <xsl:value-of select="@include"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!-- get the flexibility -->
        <xsl:variable name="xflex" select="@flexibility"/>
        <xsl:variable name="exptmpid" select="@tmid"/>
        <xsl:variable name="exptmpdisplayName" select="@tmdisplayName"/>
        <xsl:variable name="exptmpeffectiveDate" select="@tmeffectiveDate"/>
        <xsl:variable name="exptmpstatusCode" select="@tmstatusCode"/>
        <xsl:variable name="exptmname" select="@tmname"/>
        <xsl:variable name="rccontent" as="element()*">
            <xsl:choose>
                <!-- Template API expands includes inside the include (does not do this for contains) -->
                <xsl:when test="self::include[@linkedartefactmissing = 'false']">
                    <template id="{$exptmpid}" name="{$exptmname}" displayName="{$exptmpdisplayName}" effectiveDate="{$exptmpeffectiveDate}" statusCode="{$exptmpstatusCode}" xmlns="">
                        <xsl:copy-of select="*"/>
                    </template>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="getRulesetContent">
                        <xsl:with-param name="ruleset" select="$xref"/>
                        <xsl:with-param name="flexibility" select="$xflex"/>
                        <xsl:with-param name="sofar" select="$sofar"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="theDatatype" select="@datatype"/>
        <xsl:variable name="theStrength" select="local:getBindingStrength(@strength)"/>
        <!-- make sure we have the id and not the name for file reference -->
        <xsl:variable name="xtid" select="
                if (string-length($exptmpid) &gt; 0) then
                    $exptmpid
                else
                    $rccontent/@id"/>
        <!-- get the template displayName or name, or the original reference as fallback -->
        <xsl:variable name="xtnm">
            <xsl:choose>
                <xsl:when test="$rccontent[@displayName]">
                    <xsl:value-of select="$rccontent/@displayName"/>
                </xsl:when>
                <xsl:when test="$rccontent/*[@name]">
                    <xsl:value-of select="$rccontent/@name"/>
                </xsl:when>
                <xsl:when test="$exptmpdisplayName">
                    <xsl:value-of select="$exptmpdisplayName"/>
                </xsl:when>
                <xsl:when test="$exptmname">
                    <xsl:value-of select="$exptmname"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$xref"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!-- this is an include or @contains, show where from included (ref) and create a link to it -->
        <xsl:variable name="ahref">
            <xsl:choose>
                <!--<xsl:when test="string-length($exptmpid)&gt;0">
                    <!-\- never create a link on transformations based on an already expanded template format -\->
                </xsl:when>-->
                <xsl:when test="$xflex castable as xs:dateTime">
                    <xsl:value-of select="local:doHtmlName('TM', $xtid, $xflex, '.html')"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="local:doHtmlName('TM', $xtid, 'dynamic', '.html')"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!-- 
            output 
            - on elements: name of element and card
            - include references: show from where included and original (black font) or overridden (grey font) cardinality
            - choices
        -->
        <!-- 
            this is an element with @name and @contains, show name and path (with possible where clause)
            or a include or a choice statement
        -->
        <xsl:choose>
            <xsl:when test="self::include">
                <tr class="include" data-tt-id="{$node-id}" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <td style="font-style: italic;" colspan="2">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Included'"/>
                        </xsl:call-template>
                    </td>
                    <!-- show cardinality -->
                    <td class="card">
                        <xsl:choose>
                            <xsl:when test="diff:*[@name = ('maximumMultiplicity', 'minimumMultiplicity')]">
                                <table class="ad-diffblock-horizontal">
                                    <tr class="ad-diff-green">
                                        <td class="ad-diff-topbox">
                                            <span style="{$cardFont}">
                                                <strong>
                                                    <xsl:value-of select="local:getCardConf($minimumMultiplicity, $maximumMultiplicity, (), ())"/>
                                                </strong>
                                            </span>
                                        </td>
                                    </tr>
                                    <xsl:variable name="diffMinimumMultiplicity">
                                        <xsl:choose>
                                            <xsl:when test="diff:*[@name='minimumMultiplicity']/@before">
                                                <xsl:value-of select="diff:*[@name='minimumMultiplicity']/@before"/>
                                            </xsl:when>
                                            <xsl:when test="diff:*[@name = 'minimumMultiplicity']">
                                                <xsl:value-of select="'&omitted;'"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="$minimumMultiplicity"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <xsl:variable name="diffMaximumMultiplicity">
                                        <xsl:choose>
                                            <xsl:when test="diff:*[@name='maximumMultiplicity']/@before">
                                                <xsl:value-of select="diff:*[@name='maximumMultiplicity']/@before"/>
                                            </xsl:when>
                                            <xsl:when test="diff:*[@name = 'maximumMultiplicity']">
                                                <xsl:value-of select="'&omitted;'"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="$maximumMultiplicity"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <tr class="ad-diff-red">
                                        <td class="ad-diff-bottombox">
                                            <span style="{$cardFont};">
                                                <strong>
                                                    <xsl:value-of select="local:getCardConf($diffMinimumMultiplicity, $diffMaximumMultiplicity, (), ())"/>
                                                </strong>
                                            </span>
                                        </td>
                                    </tr>
                                </table>
                            </xsl:when>
                            <xsl:otherwise>
                                <span style="{$cardFont}">
                                    <strong>
                                        <xsl:value-of select="local:getCardConf($minimumMultiplicity, $maximumMultiplicity, (), ())"/>
                                    </strong>
                                </span>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                    <!-- show conformance -->
                    <td>
                        <xsl:choose>
                            <xsl:when test="diff:*[@name = ('conformance', 'isMandatory')]">
                                <table class="ad-diffblock-horizontal">
                                    <tr class="ad-diff-green">
                                        <td class="ad-diff-topbox">
                                            <span style="{$cardFont}">
                                                <strong>
                                                    <xsl:choose>
                                                        <xsl:when test="string($isMandatory) = 'true'">
                                                            <xsl:text>M</xsl:text>
                                                        </xsl:when>
                                                        <!-- 2DO conditional -->
                                                        <xsl:otherwise>
                                                            <xsl:value-of select="$conformance"/>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </strong>
                                            </span>
                                        </td>
                                    </tr>
                                    <xsl:variable name="diffIsMandatory">
                                        <xsl:choose>
                                            <xsl:when test="diff:*[@name='isMandatory']/@before">
                                                <xsl:value-of select="diff:*[@name='isMandatory']/@before"/>
                                            </xsl:when>
                                            <xsl:when test="diff:*[@name = 'isMandatory']">
                                                <xsl:value-of select="'&omitted;'"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="$isMandatory"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <xsl:variable name="diffConformance">
                                        <xsl:choose>
                                            <xsl:when test="diff:*[@name='conformance']/@before">
                                                <xsl:value-of select="diff:*[@name='conformance']/@before"/>
                                            </xsl:when>
                                            <xsl:when test="diff:*[@name = 'conformance']">
                                                <xsl:value-of select="'&omitted;'"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="$conformance"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <tr class="ad-diff-red">
                                        <td class="ad-diff-bottombox">
                                            <span style="{$cardFont}; color:#EEE;">
                                                <strong>
                                                    <xsl:choose>
                                                        <xsl:when test="string($diffIsMandatory) = 'true'">
                                                            <xsl:text>M</xsl:text>
                                                        </xsl:when>
                                                        <xsl:when test="$diffIsMandatory = '&omitted;'">
                                                            <xsl:value-of select="'&omitted;'"/>
                                                        </xsl:when>
                                                        <!-- 2DO conditional -->
                                                        <xsl:otherwise>
                                                            <xsl:value-of select="$diffConformance"/>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </strong>
                                            </span>
                                        </td>
                                    </tr>
                                </table>
                            </xsl:when>
                            <xsl:otherwise>
                                <span style="color: {$cardFont};">
                                    <strong>
                                        <xsl:choose>
                                            <xsl:when test="string($isMandatory) = 'true'">
                                                <xsl:text>M</xsl:text>
                                            </xsl:when>
                                            <!-- 2DO conditional -->
                                            <xsl:otherwise>
                                                <xsl:value-of select="$conformance"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </strong>
                                </span>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                    <td colspan="2">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'fromLabel'"/>
                        </xsl:call-template>
                        <!-- jump to tab panel with templates to the right vocab and open the accordion -->
                        <a href="{$ahref}" onclick="target='_blank';">
                            <xsl:value-of select="$xtid"/>
                        </a>
                        <xsl:text> </xsl:text>
                        <i>
                            <xsl:value-of select="$xtnm"/>
                        </i>
                        <xsl:text> (</xsl:text>
                        <xsl:choose>
                            <xsl:when test="matches($xflex, '^\d{4}')">
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="$xflex"/>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:text>)</xsl:text>
                        <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
                            <br/>
                            <xsl:call-template name="doDescription">
                                <xsl:with-param name="ns" select="desc"/>
                            </xsl:call-template>
                        </xsl:if>
                    </td>
                </tr>
            </xsl:when>
            <xsl:when test="self::choice">
                <!-- this is a choice with -->
                <tr class="choice" data-tt-id="{$node-id}" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <td style="font-style: italic;" colspan="2">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'choiceLabel'"/>
                        </xsl:call-template>
                    </td>
                    <!-- show cardinality -->
                    <td class="card">
                        <span style="{$cardFont}">
                            <strong>
                                <xsl:value-of select="local:getCardConf($minimumMultiplicity, $maximumMultiplicity, (), ())"/>
                            </strong>
                        </span>
                    </td>
                    <!-- show conformance -->
                    <td/>
                    <td colspan="2">
                        <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
                            <div>
                                <xsl:call-template name="doDescription">
                                    <xsl:with-param name="ns" select="desc"/>
                                </xsl:call-template>
                            </div>
                        </xsl:if>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'choiceElements'"/>
                        </xsl:call-template>
                        <ul>
                            <xsl:for-each select="element | include">
                                <li>
                                    <xsl:choose>
                                        <xsl:when test="self::include | self::element[@contains]">
                                            <xsl:variable name="xref" select="@ref | @contains"/>
                                            <xsl:variable name="xflex">
                                                <xsl:choose>
                                                    <xsl:when test="matches(@flexibility, '^\d{4}')">
                                                        <xsl:value-of select="@flexibility"/>
                                                    </xsl:when>
                                                    <xsl:otherwise>dynamic</xsl:otherwise>
                                                </xsl:choose>
                                            </xsl:variable>
                                            <xsl:variable name="rccontent" as="element()*">
                                                <xsl:choose>
                                                    <!-- Template API expands includes inside the include (does not do this for contains) -->
                                                    <xsl:when test="self::include[@linkedartefactmissing = 'false']">
                                                        <template id="{@tmid}" name="{@tmname}" displayName="{@tmdisplayName}" effectiveDate="{@tmeffectiveDate}" statusCode="{@tmstatusCode}" xmlns="">
                                                            <xsl:copy-of select="*"/>
                                                        </template>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:call-template name="getRulesetContent">
                                                            <xsl:with-param name="ruleset" select="$xref"/>
                                                            <xsl:with-param name="flexibility" select="@flexibility"/>
                                                            <xsl:with-param name="sofar" select="()"/>
                                                        </xsl:call-template>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </xsl:variable>
                                            <xsl:variable name="tmid" select="
                                                    if ($rccontent/@id) then
                                                        ($rccontent/@id)[1]
                                                    else
                                                        if (@tmid) then
                                                            (@tmid)
                                                        else
                                                            ($xref)"/>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="
                                                        if (self::include) then
                                                            'including_linked_1'
                                                        else
                                                            ('containment_linked_1')"/>
                                                <xsl:with-param name="p1">
                                                    <xsl:choose>
                                                        <xsl:when test="@name">
                                                            <xsl:value-of select="@name"/>
                                                        </xsl:when>
                                                        <xsl:when test="string-length(($rccontent/element/@name)[1]) &gt; 0">
                                                            <xsl:value-of select="($rccontent/element/@name)[1]"/>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <!-- undetermined element -->
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'anElement'"/>
                                                            </xsl:call-template>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                            <a href="{local:doHtmlName('TM',$tmid,$xflex,'.html')}" onclick="target='_blank';">
                                                <xsl:choose>
                                                    <xsl:when test="$rccontent/@id">
                                                        <xsl:value-of select="($rccontent/@id)[1]"/>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:value-of select="$xref"/>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </a>
                                            <xsl:text> </xsl:text>
                                            <i>
                                                <xsl:choose>
                                                    <xsl:when test="$rccontent[@displayName]">
                                                        <xsl:value-of select="$rccontent/@displayName"/>
                                                    </xsl:when>
                                                    <xsl:when test="@tmdisplayName">
                                                        <xsl:value-of select="@tmdisplayName"/>
                                                    </xsl:when>
                                                    <xsl:when test="$rccontent[@name]">
                                                        <xsl:value-of select="$rccontent/@name"/>
                                                    </xsl:when>
                                                    <xsl:when test="@tmname">
                                                        <xsl:value-of select="@tmname"/>
                                                    </xsl:when>
                                                </xsl:choose>
                                            </i>
                                            <xsl:text> (</xsl:text>
                                            <xsl:choose>
                                                <xsl:when test="matches(@flexibility, '^\d{4}')">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="@flexibility"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            <xsl:text>)</xsl:text>
                                        </xsl:when>
                                        <xsl:when test="self::element">
                                            <xsl:call-template name="getWherePathFromNodeset">
                                                <xsl:with-param name="rccontent" select="."/>
                                                <xsl:with-param name="sofar" select="()"/>
                                                <xsl:with-param name="templateFormat" select="$templateFormat"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                    </xsl:choose>
                                </li>
                            </xsl:for-each>
                        </ul>
                    </td>
                </tr>
            </xsl:when>
            <xsl:otherwise>
                <!-- calculated where clauses are potentially hard to read. Only worry about where path if explicitly stated in the template -->
                <xsl:variable name="wherePath" select="@name" as="xs:string?">
                    <!--<xsl:choose>
                        <xsl:when test="@name and @contains">
                            <xsl:call-template name="getWherePathFromNodeset">
                                <xsl:with-param name="rccontent" select="."/>
                                <xsl:with-param name="sofar" select="()"/>
                                <xsl:with-param name="templateFormat" select="$templateFormat"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="@name"/>
                        </xsl:otherwise>
                    </xsl:choose>-->
                </xsl:variable>
                <xsl:variable name="hasawhere" select="contains($wherePath, '[')"/>
                <!-- this is a normal element -->
                <tr style="vertical-align: top; background-color: #FFEAEA;" data-tt-id="{$node-id}" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <xsl:choose>
                        <xsl:when test="$switchCreateTreeTableHtml = 'true'">
                            <td class="columnName">
                                <xsl:if test="@id">
                                    <a name="{local:doHtmlAnchor(@id, ())}"/>
                                </xsl:if>
                                <xsl:choose>
                                    <xsl:when test="$hasawhere">
                                        <xsl:call-template name="outputPath">
                                            <xsl:with-param name="pathname" select="substring-before($wherePath, '[')"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:call-template name="outputPath">
                                            <xsl:with-param name="pathname" select="$wherePath"/>
                                        </xsl:call-template>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                        </xsl:when>
                        <xsl:otherwise>
                            <td class="columnName">
                                <table cellpadding="1" style="border: none;">
                                    <xsl:attribute name="class">
                                        <xsl:text>ad-diffblock-horizontal </xsl:text>
                                        <xsl:if test="diff:insert[@type = 'element']">
                                            <xsl:text>ad-diff-xadded</xsl:text>
                                        </xsl:if>
                                        <xsl:if test="diff:delete[@type = 'element']">
                                            <xsl:text>ad-diff-xdeleted</xsl:text>
                                        </xsl:if>
                                    </xsl:attribute>
                                    <tr>
                                        <xsl:call-template name="doIndentLevel">
                                            <xsl:with-param name="level" select="$level"/>
                                        </xsl:call-template>
                                        <td>
                                            <xsl:choose>
                                                <xsl:when test="$hasawhere">
                                                    <xsl:call-template name="outputPath">
                                                        <xsl:with-param name="pathname" select="substring-before($wherePath, '[')"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="outputPath">
                                                        <xsl:with-param name="pathname" select="$wherePath"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>
                    <!-- do datatype -->
                    <td class="dt">
                        <xsl:choose>
                            <xsl:when test="diff:*[@name = ('datatype', 'strength')]">
                                <table class="ad-diffblock-horizontal">
                                    <tr class="ad-diff-green">
                                        <td class="ad-diff-topbox">
                                            <strong>
                                                <xsl:choose>
                                                    <xsl:when test="not(@datatype)">
                                                        <xsl:value-of select="'&omitted;'"/>
                                                    </xsl:when>
                                                    <xsl:when test="$templateFormat = 'hl7v3xml1' and $supportedDatatypes/dt[@type = $templateFormat][@name = $theDatatype]">
                                                        <a href="https://docs.art-decor.org/documentation/datatypes/DTr1_{$theDatatype}" alt="">
                                                            <xsl:value-of select="$theDatatype"/>
                                                        </a>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:value-of select="$theDatatype"/>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </strong>
                                            <xsl:if test="$theStrength">
                                                <xsl:text> </xsl:text>
                                                <a href="https://docs.art-decor.org/introduction/cda/#binding-strength" alt="">
                                                    <xsl:attribute name="title">
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'strengthIsX'"/>
                                                            <xsl:with-param name="p1" select="$theStrength"/>
                                                        </xsl:call-template>
                                                        <xsl:value-of select="local:showBindingStrength($theStrength, true())"/>
                                                    </xsl:attribute>
                                                    <xsl:value-of select="local:showBindingStrength($theStrength, false())"/>
                                                </a>
                                            </xsl:if>
                                        </td>
                                    </tr>
                                    <xsl:variable name="diffDatatype">
                                        <xsl:choose>
                                            <xsl:when test="diff:*[@name='datatype']/@before">
                                                <xsl:value-of select="diff:*[@name='datatype']/@before"/>
                                            </xsl:when>
                                            <xsl:when test="diff:*[@name = 'datatype']">
                                                <xsl:value-of select="'&omitted;'"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="$theDatatype"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <xsl:variable name="diffStrength">
                                        <xsl:choose>
                                            <xsl:when test="diff:*[@name='strength']/@before">
                                                <xsl:value-of select="diff:*[@name='strength']/@before"/>
                                            </xsl:when>
                                            <xsl:when test="diff:*[@name = 'strength']">
                                                <xsl:value-of select="'&omitted;'"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="local:getBindingStrength($theStrength)"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <tr class="ad-diff-red">
                                        <td class="ad-diff-bottombox">
                                            <strong>
                                                <xsl:choose>
                                                    <xsl:when test="$templateFormat = 'hl7v3xml1' and $supportedDatatypes/dt[@type = $templateFormat][@name = $diffDatatype]">
                                                        <a href="https://docs.art-decor.org/documentation/datatypes/DTr1_{$diffDatatype}" alt="">
                                                            <xsl:value-of select="$diffDatatype"/>
                                                        </a>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:value-of select="$diffDatatype"/>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </strong>
                                            <xsl:if test="@strength">
                                                <xsl:text>&#160;</xsl:text>
                                                <a href="https://docs.art-decor.org/introduction/cda/#binding-strength" alt="">
                                                    <xsl:attribute name="title">
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'strengthIsX'"/>
                                                            <xsl:with-param name="p1" select="$diffStrength"/>
                                                        </xsl:call-template>
                                                        <xsl:value-of select="local:showBindingStrength($diffStrength, true())"/>
                                                    </xsl:attribute>
                                                    <xsl:value-of select="local:showBindingStrength($diffStrength, false())"/>
                                                </a>
                                            </xsl:if>
                                        </td>
                                    </tr>
                                </table>
                            </xsl:when>
                            <xsl:otherwise>
                                <strong>
                                    <xsl:choose>
                                        <xsl:when test="$templateFormat = 'hl7v3xml1' and $supportedDatatypes/dt[@type = $templateFormat][@name = $theDatatype]">
                                            <a href="https://docs.art-decor.org/documentation/datatypes/DTr1_{$theDatatype}" alt="">
                                                <xsl:value-of select="$theDatatype"/>
                                            </a>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="$theDatatype"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </strong>
                                <xsl:if test="$theStrength">
                                    <xsl:text>&#160;</xsl:text>
                                    <a href="https://docs.art-decor.org/introduction/cda/#binding-strength" alt="">
                                        <xsl:attribute name="title">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'strengthIsX'"/>
                                                <xsl:with-param name="p1" select="$theStrength"/>
                                            </xsl:call-template>
                                            <xsl:value-of select="local:showBindingStrength($theStrength, true())"/>
                                        </xsl:attribute>
                                        <xsl:value-of select="local:showBindingStrength($theStrength, false())"/>
                                    </a>
                                </xsl:if>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                    <!-- show cardinality -->
                    <td class="card">
                        <span style="{$cardFont}">
                            <strong>
                                <xsl:value-of select="local:getCardConf($minimumMultiplicity, $maximumMultiplicity, (), ())"/>
                            </strong>
                        </span>
                    </td>
                    <!-- show conformance -->
                    <td>
                        <span style="color: {$cardFont}">
                            <strong>
                                <xsl:choose>
                                    <xsl:when test="string($isMandatory) = 'true'">
                                        <xsl:text>M</xsl:text>
                                    </xsl:when>
                                    <!-- 2DO conditional -->
                                    <xsl:otherwise>
                                        <xsl:value-of select="$conformance"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </strong>
                        </span>
                    </td>
                    <!-- show description or contains content -->
                    <td>
                        <xsl:choose>
                            <xsl:when test="desc/diff:update[@type = 'elementcontent']/desc">
                                <table class="ad-diffblock-horizontal">
                                    <tr class="ad-diff-green">
                                        <td class="ad-diff-topbox">
                                            <xsl:call-template name="doDescription">
                                                <xsl:with-param name="ns" select="desc"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                    <tr class="ad-diff-red">
                                        <td class="ad-diff-bottombox">
                                            <xsl:call-template name="doDescription">
                                                <xsl:with-param name="ns" select="desc/diff:update[@type = 'elementcontent']/desc"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </table>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="doDescription">
                                    <xsl:with-param name="ns" select="desc"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                        <!-- show error message if minimumMultiplicity=0 and isMandatory=true -->
                        <xsl:if test="$minimumMultiplicity = '0' and $isMandatory = 'true'">
                            <p>
                                <table style="border: 0;">
                                    <xsl:call-template name="doMessage">
                                        <xsl:with-param name="level" select="'warning'"/>
                                        <xsl:with-param name="msg">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'issueIfIsMandatoryTrueMinimumMultiplicityGreaterThanZero'"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </table>
                            </p>
                        </xsl:if>
                        <!-- put containment information directly here instead of in an own row (ref old-style ART template viewer -->
                        <xsl:if test="@contains">
                            <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
                                <br/>
                            </xsl:if>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Contains'"/>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <xsl:choose>
                                <xsl:when test="$rccontent[@id] or @linkedartefactmissing = 'false'">
                                    <a href="{$ahref}" onclick="target='_blank';">
                                        <xsl:value-of select="$xtid"/>
                                    </a>
                                    <xsl:text> </xsl:text>
                                    <i>
                                        <xsl:value-of select="$xtnm"/>
                                    </i>
                                    <xsl:text> (</xsl:text>
                                    <xsl:choose>
                                        <xsl:when test="matches($xflex, '^\d{4}')">
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$xflex"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>)</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'cannotFindRuleSet'"/>
                                                    <xsl:with-param name="p1" select="$xref"/>
                                                    <xsl:with-param name="p2">
                                                        <xsl:choose>
                                                            <xsl:when test="$xflex castable as xs:dateTime">
                                                                <xsl:value-of select="$xflex"/>
                                                            </xsl:when>
                                                            <xsl:otherwise>
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                                </xsl:call-template>
                                                            </xsl:otherwise>
                                                        </xsl:choose>
                                                    </xsl:with-param>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:if test="diff:update[@name = 'contains']">
                                <table class="ad-diffblock-horizontal">
                                    <tr class="ad-diff-green">
                                        <td class="ad-diff-topbox">
                                            <xsl:value-of select="$xtid"/>
                                        </td>
                                    </tr>
                                    <tr class="ad-diff-red">
                                        <td class="ad-diff-bottombox">
                                            <xsl:value-of select="diff:update[@name='contains']/@before"/>
                                        </td>
                                    </tr>
                                </table>
                            </xsl:if>
                        </xsl:if>
                    </td>
                    <!-- show item label -->
                    <td style="background-color: #FFEEEE;">
                        <xsl:if test="$itemlabel[string-length(@label) &gt; 0]">
                            <span>
                                <xsl:attribute name="title">
                                    <xsl:call-template name="doDescription">
                                        <xsl:with-param name="ns" select="$itemlabel/desc"/>
                                    </xsl:call-template>
                                </xsl:attribute>
                                <!-- shorten the label if it does not contain any spaces -->
                                <xsl:choose>
                                    <xsl:when test="matches($itemlabel/@label, '\s')">
                                        <xsl:value-of select="replace($itemlabel/@label, '-', '‑')"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:call-template name="doLabelMiracle">
                                            <xsl:with-param name="labelcandidate" select="$itemlabel/@label"/>
                                        </xsl:call-template>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </span>
                            <!--
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'xInBraces'"/>
                                <xsl:with-param name="p1" select="$itemlabel"/>
                            </xsl:call-template>
                            -->
                        </xsl:if>
                    </td>
                </tr>
                <xsl:if test="$hasawhere">
                    <tr style="vertical-align: top; background-color: #FFEAEA;" data-tt-id="{$node-id}-where" data-tt-parent-id="{$node-id}" xmlns="http://www.w3.org/1999/xhtml">
                        <td colspan="5" style="background-color: #FFEAEA;">
                            <xsl:call-template name="outputPath">
                                <xsl:with-param name="pathname" select="concat('[', substring-after($wherePath, '['))"/>
                            </xsl:call-template>
                            <!--<table cellpadding="1" style="border: none;">
                                <tr>
                                    <xsl:call-template name="doIndentLevel">
                                        <xsl:with-param name="level" select="$level + 1"/>
                                        <xsl:with-param name="icon" select="false()"/>
                                    </xsl:call-template>
                                    <td>
                                        <xsl:call-template name="outputPath">
                                            <xsl:with-param name="pathname" select="concat('[', substring-after($wherePath, '['))"/>
                                        </xsl:call-template>
                                    </td>
                                </tr>
                            </table>-->
                        </td>
                        <td/>
                    </tr>
                </xsl:if>
            </xsl:otherwise>
        </xsl:choose>
        <!-- do target id (element id as a target for a concept) -->
        <xsl:apply-templates select=".[@id]" mode="doConnectedConcepts">
            <xsl:with-param name="parent-id" select="$node-id"/>
        </xsl:apply-templates>
        <!-- 
            do all subsequent attributes first. 
            If this is an expanded template we could encounter the template contents inline.
             Simple parsing it here would result in duplicates
        -->
        <xsl:apply-templates select="attribute[not(parent::include)]" mode="templateparticle">
            <xsl:with-param name="level" select="$level + 1"/>
            <xsl:with-param name="parent-id" select="$node-id"/>
            <xsl:with-param name="sofar" select="()"/>
            <xsl:with-param name="templateFormat" select="$templateFormat"/>
        </xsl:apply-templates>
        <!-- 
            do constraints.
            If this is an expanded template we could encounter the template contents inline.
            Simple parsing it here would result in duplicates
        -->
        <xsl:apply-templates select="constraint[not(parent::include) or string-length($adram)>0]" mode="templateparticle">
            <xsl:with-param name="parent-id" select="$node-id"/>
            <xsl:with-param name="sofar" select="()"/>
            <xsl:with-param name="templateFormat" select="$templateFormat"/>
        </xsl:apply-templates>
        <!-- do vocabularies -->
        <xsl:choose>
            <xsl:when test="$templateFormat = 'hl7v3xml1' and count(vocabulary) = 1 and not(vocabulary[@valueSet or @domain])">
                <xsl:variable name="theElementIsMandatory" as="xs:boolean">
                    <xsl:choose>
                        <xsl:when test="$isMandatory = 'true'">
                            <xsl:value-of select="true()"/>
                        </xsl:when>
                        <!-- If nullFlavor is prohibited or some attribute (not xsi:type or xsi:nil) is required then the element is effectively mandatory -->
                        <xsl:when test="
                                .[@isMandatory = 'true'] |
                                attribute[@name = 'nullFlavor'][@prohibited = 'true'][not(@value)] |
                                attribute[not(@name = ('nullFlavor', 'xsi:type') or @nullFlavor)][not(@prohibited = 'true')][not(@isOptional = 'true')]">
                            <xsl:value-of select="true()"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="false()"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="theCode" select="vocabulary/@code"/>
                <xsl:variable name="theCodeSystem" select="vocabulary/@codeSystem"/>
                <xsl:variable name="theDisplayName">
                    <xsl:choose>
                        <xsl:when test="@displayName">
                            <xsl:value-of select="@displayName"/>
                        </xsl:when>
                        <xsl:when test="@code and @codeSystem">
                            <xsl:value-of select="($allValueSets/*/valueSet/conceptList/concept[@code = $theCode and @codeSystem = $theCodeSystem]/@displayName)[1]"/>
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="vocattrcount" select="count(vocabulary/@*)"/>
                <xsl:for-each select="vocabulary/@*">
                    <!-- cache attribute name and value of attribute -->
                    <xsl:variable name="theAttName" select="name(.)"/>
                    <xsl:variable name="theAttValue" select="."/>
                    <tr style="vertical-align: top;" data-tt-id="{generate-id(.)}-voc-{position()}" xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                        <td>
                            <xsl:choose>
                                <xsl:when test="$switchCreateTreeTableHtml = 'true'">
                                    <xsl:call-template name="outputPath">
                                        <xsl:with-param name="pathname" select="concat('@', $theAttName)"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <table cellpadding="1" style="border: 0;">
                                        <tr>
                                            <xsl:call-template name="doIndentLevel">
                                                <xsl:with-param name="level" select="$level + 1"/>
                                            </xsl:call-template>
                                            <td>
                                                <!--<xsl:text>@</xsl:text>-->
                                                <xsl:call-template name="outputPath">
                                                    <xsl:with-param name="pathname" select="concat('@', $theAttName)"/>
                                                </xsl:call-template>
                                            </td>
                                        </tr>
                                    </table>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                        <xsl:choose>
                            <xsl:when test="position() = 1">
                                <td rowspan="{$vocattrcount}" class="conf">
                                    <xsl:text>CONF</xsl:text>
                                </td>
                            </xsl:when>
                        </xsl:choose>
                        <!-- cardinality is 1..1 when theElementIsMandatory = true() -->
                        <td class="card">
                            <span style="{$cardFont}">
                                <strong>
                                    <xsl:choose>
                                        <xsl:when test="$theElementIsMandatory">
                                            <xsl:value-of select="local:getCardConf('1', '1', (), ())"/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="local:getCardConf('0', '1', (), ())"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </strong>
                            </span>
                        </td>
                        <!-- conformance -->
                        <td>
                            <strong>
                                <xsl:choose>
                                    <!-- choice -->
                                    <xsl:when test="contains($theAttValue, '|')">
                                        <xsl:text>&#160;</xsl:text>
                                    </xsl:when>
                                    <xsl:when test="string-length($theAttValue) &gt; 0">
                                        <xsl:text>F</xsl:text>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:text>&#160;</xsl:text>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </strong>
                        </td>
                        <td colspan="2">
                            <xsl:choose>
                                <!-- choice -->
                                <xsl:when test="contains($theAttValue, '|')">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'attribShallChoice'"/>
                                        <xsl:with-param name="p1" select="$theAttName"/>
                                    </xsl:call-template>
                                    <ul>
                                        <xsl:for-each select="tokenize($theAttValue, '\|')">
                                            <li>
                                                <xsl:value-of select="."/>
                                            </li>
                                        </xsl:for-each>
                                    </ul>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="$theAttValue"/>
                                    <xsl:if test="string-length($theDisplayName) &gt; 0 and name(.) = 'code'">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'xInBraces'"/>
                                            <xsl:with-param name="p1" select="$theDisplayName"/>
                                        </xsl:call-template>
                                    </xsl:if>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:if test="$theAttName = 'codeSystem'">
                                <xsl:variable name="theName">
                                    <xsl:call-template name="getIDDisplayName">
                                        <xsl:with-param name="root" select="$theCodeSystem"/>
                                    </xsl:call-template>
                                </xsl:variable>
                                <xsl:if test="string-length($theName) &gt; 0">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'xInBraces'"/>
                                        <xsl:with-param name="p1" select="$theName"/>
                                    </xsl:call-template>
                                </xsl:if>
                            </xsl:if>
                        </td>
                    </tr>
                </xsl:for-each>
            </xsl:when>
            <xsl:when test="vocabulary">
                <tr style="vertical-align: top;" data-tt-id="{generate-id(.)}-voc" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                    <td style="background-color: white;" colspan="1">&#160;</td>
                    <td class="conf">
                        <xsl:text>CONF</xsl:text>
                    </td>
                    <td colspan="4">
                        <table width="100%" border="0" cellspacing="2" cellpadding="2">
                            <xsl:for-each select="vocabulary">
                                <xsl:call-template name="doVocabularyAttributes">
                                    <xsl:with-param name="targetAttributeName" select="'code'"/>
                                    <xsl:with-param name="theStrength" select="$theStrength"/>
                                    <xsl:with-param name="templateFormat" select="$templateFormat"/>
                                </xsl:call-template>
                                <xsl:if test="position() != last()">
                                    <tr style="vertical-align: top;">
                                        <td>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'orWord'"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:if>
                            </xsl:for-each>
                        </table>
                    </td>
                </tr>
            </xsl:when>
        </xsl:choose>
        <!-- do properties. If this is an expanded template we could encounter the template contents inline. Parsing it here would result in duplicates -->
        <xsl:apply-templates select="property[not(parent::include)]" mode="templateparticle">
            <xsl:with-param name="parent-id" select="$node-id"/>
            <xsl:with-param name="sofar" select="()"/>
            <xsl:with-param name="templateFormat" select="$templateFormat"/>
        </xsl:apply-templates>
        <!-- do text -->
        <xsl:if test="text">
            <tr style="vertical-align: top; background-color: #FFEEEE;" data-tt-id="{generate-id(.)}-text" xmlns="http://www.w3.org/1999/xhtml">
                <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                <td style="background-color: white;" colspan="1">&#160;</td>
                <td class="conf">
                    <xsl:text>CONF</xsl:text>
                </td>
                <td colspan="4" style="background-color: white;">
                    <table width="100%" border="0" cellspacing="2" cellpadding="2">
                        <xsl:for-each select="text">
                            <tr style="vertical-align: top;">
                                <td>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'elementContentShallBe'"/>
                                        <xsl:with-param name="p1" select="text()"/>
                                    </xsl:call-template>
                                </td>
                            </tr>
                            <xsl:if test="position() != last()">
                                <tr style="vertical-align: top;">
                                    <td>
                                        <xsl:text>-</xsl:text>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'orWord'"/>
                                        </xsl:call-template>
                                        <xsl:text>-</xsl:text>
                                    </td>
                                </tr>
                            </xsl:if>
                        </xsl:for-each>
                    </table>
                </td>
            </tr>
        </xsl:if>
        <!-- @closed, only displaying closed, to avoid clutter... -->
        <xsl:if test="string(@isClosed) = 'true'">
            <tr style="vertical-align: top;" data-tt-id="{generate-id(.)}-closed" xmlns="http://www.w3.org/1999/xhtml">
                <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                <td style="background-color: white;" colspan="1">&#160;</td>
                <td style="vertical-align: top; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'openClosedLabel'"/>
                    </xsl:call-template>
                </td>
                <td colspan="4" class="tabtab">
                    <xsl:choose>
                        <xsl:when test="string(@isClosed) = 'true'">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'elementIsClosed'"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'elementIsOpen'"/>
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
            </tr>
        </xsl:if>
        <xsl:apply-templates select="example" mode="templateparticle">
            <xsl:with-param name="parent-id" select="$node-id"/>
            <xsl:with-param name="sofar" select="()"/>
            <xsl:with-param name="templateFormat" select="$templateFormat"/>
        </xsl:apply-templates>
        <xsl:if test="diff:delete[@name = ('example')]">
            <tr xmlns="http://www.w3.org/1999/xhtml">
                <td/>
                <td>
                    <table class="ad-diffblock-horizontal">
                        <tr class="ad-diff-red">
                            <td class="ad-diff-singlebox">
                                <strike>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Example'"/>
                                    </xsl:call-template>
                                </strike>
                            </td>
                        </tr>
                    </table>
                </td>
                <td colspan="2"/>
            </tr>
        </xsl:if>
        <xsl:choose>
            <xsl:when test="self::include">
                <xsl:choose>
                    <xsl:when test="$sofar[. = concat($rccontent/@id, '-', $rccontent/@effectiveDate)]">
                        <tr style="vertical-align: top;" data-tt-id="{generate-id(.)}-incmissing" xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                            <td style="background-color: white;" colspan="1">&#160;</td>
                            <td style="background-color: #FFEEEE;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'tmpInclude'"/>
                                </xsl:call-template>
                            </td>
                            <td style="text-align: left;" colspan="4">
                                <xsl:call-template name="showIcon">
                                    <xsl:with-param name="which">notice</xsl:with-param>
                                </xsl:call-template>
                                <xsl:text>&#160;</xsl:text>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'tmpCircularReferenceNotExpanding'"/>
                                    <xsl:with-param name="p1" select="$rccontent/@id"/>
                                </xsl:call-template>
                            </td>
                        </tr>
                    </xsl:when>
                    <xsl:when test="$rccontent[@id]">
                        <!--<xsl:apply-templates select="$rccontent/*/(element | assert | report | defineVariable | include | choice)" mode="templateparticle">
                            <xsl:with-param name="sofar" select="()"/>
                            <xsl:with-param name="templateFormat" select="$templateFormat"/>
                        </xsl:apply-templates>-->
                        <!-- get a possible new item label -->
                        <xsl:variable name="newitemlabel" as="element()?">
                            <xsl:choose>
                                <xsl:when test="$rccontent/item[string-length(@label) &gt; 0]">
                                    <!-- use current item/@label -->
                                    <item xmlns="" label="{replace(string($rccontent/item/@label), '-', '‑')}">
                                        <xsl:copy-of select="$rccontent/item/desc"/>
                                    </item>
                                </xsl:when>
                                <xsl:when test="$label[string-length(@label) &gt; 0]">
                                    <!-- use inherited label if present -->
                                    <xsl:copy-of select="$label"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <!-- use leave it empty -->
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:variable>
                        <xsl:apply-templates select="$rccontent/(element | attribute | include | choice | assert | report | let | defineVariable | constraint | property)" mode="templateparticle">
                            <xsl:with-param name="level" select="$level"/>
                            <xsl:with-param name="label" select="$newitemlabel"/>
                            <xsl:with-param name="inheritedminimumMultiplicity" select="$minimumMultiplicity"/>
                            <xsl:with-param name="inheritedmaximumMultiplicity" select="$maximumMultiplicity"/>
                            <xsl:with-param name="inheritedConformance" select="$conformance"/>
                            <xsl:with-param name="inheritedIsMandatory" select="$isMandatory"/>
                            <xsl:with-param name="parent-id" select="$node-id"/>
                            <xsl:with-param name="sofar" select="$sofar, concat($rccontent/@id, '-', $rccontent/@effectiveDate)"/>
                            <xsl:with-param name="templateFormat" select="$templateFormat"/>
                        </xsl:apply-templates>
                    </xsl:when>
                    <xsl:otherwise>
                        <tr style="vertical-align: top;" data-tt-id="{generate-id(.)}-incmissing" xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:attribute name="data-tt-parent-id" select="$node-id"/>
                            <td style="background-color: white;" colspan="1">&#160;</td>
                            <td style="background-color: #FFEEEE;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'tmpInclude'"/>
                                </xsl:call-template>
                            </td>
                            <td colspan="4">
                                <table style="border: 0;">
                                    <xsl:call-template name="doMessage">
                                        <xsl:with-param name="msg">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'cannotFindRuleSet'"/>
                                                <xsl:with-param name="p1" select="$xref"/>
                                                <xsl:with-param name="p2">
                                                    <xsl:choose>
                                                        <xsl:when test="$xflex castable as xs:dateTime">
                                                            <xsl:value-of select="$xflex"/>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                            </xsl:call-template>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </table>
                            </td>
                        </tr>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="element | include | choice | assert | report | let | defineVariable" mode="templateparticle">
                    <xsl:with-param name="level" select="$level + 1"/>
                    <xsl:with-param name="label" select="$itemlabel"/>
                    <xsl:with-param name="parent-id" select="$node-id"/>
                    <xsl:with-param name="sofar" select="$sofar"/>
                    <xsl:with-param name="templateFormat" select="$templateFormat"/>
                </xsl:apply-templates>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <!-- Only render constraint in the requested language. Revert to first other language if missing -->
    <xsl:template match="constraint" mode="templateparticle">
        <xsl:param name="parent-id" as="xs:string?" required="yes"/>
        <xsl:if test=".[@language = $defaultLanguage] or (not(preceding-sibling::constraint) and not(../constraint[@language = $defaultLanguage]))">
            <tr style="vertical-align: top; background-color: #FAFAD2;" data-tt-id="{generate-id(.)}-constr" xmlns="http://www.w3.org/1999/xhtml">
                <xsl:if test="string-length($parent-id) > 0">
                    <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                </xsl:if>
                <td style="background-color: white;" colspan="1">&#160;</td>
                <td class="conf">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'constraintLabel'"/>
                    </xsl:call-template>
                </td>
                <td style="background-color: #FAFAD2;" colspan="4">
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="."/>
                    </xsl:call-template>
                </td>
            </tr>
        </xsl:if>
    </xsl:template>
    <xsl:template match="property" mode="templateparticle">
        <xsl:param name="parent-id" as="xs:string?" required="yes"/>
        <tr style="vertical-align: top;" data-tt-id="{generate-id(.)}-prop" xmlns="http://www.w3.org/1999/xhtml">
            <xsl:if test="string-length($parent-id) > 0">
                <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
            </xsl:if>
            <td style="background-color: white;" colspan="1">&#160;</td>
            <td class="conf">
                <xsl:text>CONF</xsl:text>
            </td>
            <td colspan="4">
                <table width="100%" border="0" cellspacing="2" cellpadding="2">
                    <xsl:for-each select="@*">
                        <xsl:variable name="tdcontent">
                            <xsl:choose>
                                <xsl:when test="name(.) = 'value'">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'attribIs'"/>
                                            <xsl:with-param name="p1" select="concat('@', name(.))"/>
                                            <xsl:with-param name="p2" select="."/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:when>
                                <xsl:when test="name(.) = 'unit'">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'attribIs'"/>
                                            <xsl:with-param name="p1" select="concat('@', name(.))"/>
                                            <xsl:with-param name="p2" select="."/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:when>
                                <xsl:when test="name(.) = 'currency'">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'attribIs'"/>
                                            <xsl:with-param name="p1" select="name(.)"/>
                                            <xsl:with-param name="p2" select="."/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:when>
                                <xsl:when test="name(.) = 'fractionDigits'">
                                    <td>
                                        <xsl:choose>
                                            <xsl:when test="string-length(.) = 0">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'attribFracDigits'"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:when test="ends-with(., '!$')">
                                                <!-- exact fraction digits -->
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'attribFracDigitsExact'"/>
                                                    <xsl:with-param name="p1" select="substring-before(., '!')"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:when test="ends-with(., '.')">
                                                <!-- max fraction digits -->
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'attribFracDigitsMax'"/>
                                                    <xsl:with-param name="p1" select="substring-before(., '.')"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <!-- minimum no of digits -->
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'attribFracDigitsMin'"/>
                                                    <xsl:with-param name="p1" select="."/>
                                                </xsl:call-template>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </td>
                                </xsl:when>
                                <xsl:when test="name(.) = 'minInclude'">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'attribMinIncludeIs'"/>
                                            <xsl:with-param name="p1" select="name(.)"/>
                                            <xsl:with-param name="p2" select="."/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:when>
                                <xsl:when test="name(.) = 'maxInclude'">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'attribMaxIncludeIs'"/>
                                            <xsl:with-param name="p1" select="name(.)"/>
                                            <xsl:with-param name="p2" select="."/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:when>
                                <xsl:when test="name(.) = 'minLength'">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'attribMinLengthIs'"/>
                                            <xsl:with-param name="p1" select="name(.)"/>
                                            <xsl:with-param name="p2" select="."/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:when>
                                <xsl:when test="name(.) = 'maxLength'">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'attribMaxLengthIs'"/>
                                            <xsl:with-param name="p1" select="name(.)"/>
                                            <xsl:with-param name="p2" select="."/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:when>
                                <xsl:otherwise>
                                    <td>?</td>
                                    <!-- Don't silently fail this...question marks hard to spot in large specifications -->
                                    <xsl:call-template name="logMessage">
                                        <xsl:with-param name="level" select="$logERROR"/>
                                        <xsl:with-param name="msg">
                                            <xsl:text>+++ Found unrecognized property attribute @</xsl:text>
                                            <xsl:value-of select="name(.)"/>
                                            <xsl:text>="</xsl:text>
                                            <xsl:value-of select="."/>
                                            <xsl:text>" in template id "</xsl:text>
                                            <xsl:value-of select="ancestor::template/@id"/>
                                            <xsl:text>"</xsl:text>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:variable>
                        <xsl:if test="count($tdcontent) &gt; 0">
                            <tr style="vertical-align: top;">
                                <xsl:copy-of select="$tdcontent"/>
                            </tr>
                        </xsl:if>
                        <xsl:if test="position() != last()">
                            <tr style="vertical-align: top;">
                                <td>
                                    <xsl:text>-</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'andWord'"/>
                                    </xsl:call-template>
                                    <xsl:text>-</xsl:text>
                                </td>
                            </tr>
                        </xsl:if>
                    </xsl:for-each>
                </table>
            </td>
        </tr>
    </xsl:template>
    <!-- Render template associations -->
    <xsl:template match="*" mode="doConnectedConcepts">
        <xsl:param name="parent-id" as="xs:string?" required="yes"/>
        <xsl:param name="tid" select="(ancestor-or-self::template/@id)[last()]"/>
        <xsl:param name="tnm" select="(ancestor-or-self::template/@name)[last()]"/>
        <xsl:param name="teff" select="(ancestor-or-self::template/@effectiveDate)[last()]"/>
        <!-- do target id (attribute/element id as a target for a concept) -->
        <xsl:if test="@id">
            <xsl:variable name="theId" select="@id"/>
            <!-- As discussed: this is purely of technical 'under water' nature and holds no information to anyone except perhaps the developer/author of the Decor file -->
            <!--tr>
                <td style="background-color: white;"> </td>
                <td>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'idAsTarget'"/>
                    </xsl:call-template>
                </td>
                <td colspan="4">
                    <xsl:value-of select="$theId"/>
                </td>
            </tr-->
            <!--
                <origconcept datasetId="2.16.840.1.113883.2.4.3.11.60.20.77.1.2" datasetEffectiveDate="2013-12-01T00:00:00" 
                            ref="2.16.840.1.113883.2.4.3.11.60.20.77.2.2.9528" effectiveDate="2013-12-01T00:00:00" 
                            elementId="2.16.840.1.113883.2.4.3.11.60.20.77.9.135" path="Voorschrift / Patientgegevens" 
                            refdisplay="mp-dataelement800-9528">
                    <concept id="2.16.840.1.113883.2.4.3.11.60.20.77.2.2.9528" effectiveDate="2013-12-01T00:00:00">
                        <name language="nl-NL">Geboortegegevens</name>
                        <name language="en-US">Birth data</name>
                        <desc language="nl-NL">Algemene gegevens over de geboorte van de persoon</desc>
                        <desc language="en-US">General data on the persons' birth</desc>
                    </concept>
                </origconcept>
            -->
            <xsl:variable name="associatedConcepts" select="$allTemplateAssociation/*/templateAssociation[@templateId = $tid][@effectiveDate = $teff]/concept[@elementId = $theId] | ancestor::include[1]/staticAssociations/origconcept[@elementId = $theId] | .[not(ancestor::include)]/ancestor::template/staticAssociations/origconcept[@elementId = $theId]" as="element()*"/>
            <!-- do template associations -->
            <xsl:variable name="renderedConcepts" as="element()*">
                <xsl:for-each-group select="$associatedConcepts" group-by="concat(@ref, @effectiveDate)">
                    <xsl:variable name="deid" select="current-group()[1]/@ref"/>
                    <xsl:variable name="deed" select="current-group()[1]/@effectiveDate"/>
                    <xsl:variable name="concept" select="
                            if (current-group()[self::origconcept]) then
                                (current-group()/self::origconcept[name])[1]
                            else
                                local:getConceptFlat($deid, $deed)" as="element()?"/>
                    <xsl:variable name="dataset" select="local:getDatasetForConcept($deid, $deed)"/>
                    <xsl:variable name="destatus" as="item()?">
                        <xsl:choose>
                            <xsl:when test="@conceptStatusCode">
                                <xsl:value-of select="current-group()[1]/@conceptStatusCode"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$concept/@statusCode"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="deversionlabel">
                        <xsl:choose>
                            <xsl:when test="@conceptVersionLabel">
                                <xsl:value-of select="current-group()[1]/@conceptVersionLabel"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$concept/@versionLabel"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="dsid">
                        <xsl:choose>
                            <xsl:when test="@datasetId">
                                <xsl:value-of select="current-group()[1]/@datasetId"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$dataset/@id"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="dsef">
                        <xsl:choose>
                            <xsl:when test="@datasetEffectiveDate">
                                <xsl:value-of select="current-group()[1]/@datasetEffectiveDate"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$dataset/@effectiveDate"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="dspath">
                        <xsl:choose>
                            <xsl:when test="@path">
                                <xsl:value-of select="current-group()[1]/@path"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:for-each select="$dataset//concept[@id = $concept/(@id | @ref)][@effectiveDate = $concept/(@effectiveDate | @flexibility)]/ancestor::concept">
                                    <xsl:call-template name="doName">
                                        <!-- will not exist on RetrieveTemplate expanded templates -->
                                        <xsl:with-param name="ns" select="local:getConceptFlat(@id, @effectiveDate)/name"/>
                                    </xsl:call-template>
                                    <xsl:text> / </xsl:text>
                                </xsl:for-each>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="dsname">
                        <xsl:choose>
                            <xsl:when test="current-group()[1]/datasetName">
                                <xsl:call-template name="doName">
                                    <!-- will not exist on RetrieveTemplate expanded templates -->
                                    <xsl:with-param name="ns" select="current-group()[1]/datasetName"/>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:when test="@datasetName">
                                <xsl:value-of select="current-group()[1]/@datasetName"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="doName">
                                    <!-- will not exist on RetrieveTemplate expanded templates -->
                                    <xsl:with-param name="ns" select="$dataset/name"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="dsstatus" as="item()?">
                        <xsl:choose>
                            <xsl:when test="@datasetStatusCode">
                                <xsl:value-of select="current-group()[1]/@datasetStatusCode"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$dataset/@statusCode"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="dsversionlabel">
                        <xsl:choose>
                            <xsl:when test="@datasetVersionLabel">
                                <xsl:value-of select="current-group()[1]/@datasetVersionLabel"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$dataset/@versionLabel"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="deiddisplay">
                        <xsl:choose>
                            <xsl:when test="@refdisplay[not(. = '')]">
                                <xsl:value-of select="current-group()[1]/@refdisplay"/>
                            </xsl:when>
                            <xsl:when test="$concept[@iddisplay]">
                                <xsl:value-of select="($concept/@iddisplay)[1]"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="doShorthandId">
                                    <xsl:with-param name="id" select="$deid"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="outerposition" select="position()"/>
                    <!--<xsl:if test="empty($concept)">
                        <tr style="background-color: #F4FFF4;" class="missingAssociation">
                            <td style="vertical-align: top; width: 1%;">
                                <xsl:call-template name="showIcon">
                                    <xsl:with-param name="which">target</xsl:with-param>
                                    <xsl:with-param name="tooltip">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'targetOfConceptIds'"/>
                                        </xsl:call-template>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </td>
                            <td style="width: 25%; vertical-align: top;" colspan="3">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'theReferencedConceptAsOfCannotBeFound'"/>
                                    <xsl:with-param name="p1" select="$deid"/>
                                    <xsl:with-param name="p2">
                                        <xsl:call-template name="showDate">
                                            <xsl:with-param name="date" select="$deed"/>
                                        </xsl:call-template>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </td>
                        </tr>
                    </xsl:if>-->
                    <xsl:for-each select="$concept">
                        <tr style="background-color: #F4FFF4;">
                            <td style="width: 25%; vertical-align: top;">
                                <a href="{local:doHtmlName('DS', $projectPrefix, $dsid, $dsef, $deid, $deed, (), (), '.html', false())}" onclick="target='_blank';">
                                    <xsl:copy-of select="$deiddisplay"/>
                                </a>
                            </td>
                            <td style="vertical-align: top;">
                                <xsl:if test="string-length($dspath) > 0">
                                    <xsl:attribute name="title" select="$dspath"/>
                                </xsl:if>
                                <xsl:if test="string-length($destatus) > 0">
                                    <xsl:call-template name="showStatusDot">
                                        <xsl:with-param name="status" select="$destatus"/>
                                        <xsl:with-param name="title">
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="$destatus"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                    <xsl:text>&#160;</xsl:text>
                                </xsl:if>
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="$concept/name"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="$deversionlabel"/>
                            </td>
                            <td style="width: 35%; vertical-align: top;">
                                <xsl:if test="string-length($dsstatus) > 0">
                                    <xsl:call-template name="showStatusDot">
                                        <xsl:with-param name="status" select="$dsstatus"/>
                                        <xsl:with-param name="title">
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="$dsstatus"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                    <xsl:text>&#160;</xsl:text>
                                </xsl:if>
                                <xsl:copy-of select="$dsname"/>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="$dsversionlabel"/>
                                <xsl:if test="current-group()[1][not(@ident = $projectPrefix)]">
                                    <xsl:text> </xsl:text>
                                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                </xsl:if>
                            </td>
                        </tr>
                    </xsl:for-each>
                </xsl:for-each-group>
            </xsl:variable>
            
            <xsl:if test="$renderedConcepts[not(@class = 'missingAssociation')]">
                <tr style="vertical-align: top;" data-tt-id="{generate-id(.)}-assoc" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <td style="background-color: white;">&#160;</td>
                    <td colspan="5" class="tabtab" style="background-color: #F4FFF4;">
                        <!--<xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'targetOfConceptIds'"/>
                        </xsl:call-template>-->
                        <table width="100%" border="0" cellspacing="2" cellpadding="2">
                            <tr>
                                <td style="vertical-align: top; width: 20px" rowspan="{count($renderedConcepts[not(@class = 'missingAssociation')]) + 1}">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which">target</xsl:with-param>
                                        <xsl:with-param name="tooltip">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'targetOfConceptIds'"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </td>
                            </tr>
                            <xsl:copy-of select="$renderedConcepts[not(@class = 'missingAssociation')]"/>
                        </table>
                    </td>
                </tr>
            </xsl:if>
        </xsl:if>
    </xsl:template>
    <xsl:template name="doVocabularyAttributes">
        <xsl:param name="targetAttributeName"/>
        <xsl:param name="theStrength"/>
        <xsl:param name="templateFormat" as="xs:string?"/>
        <xsl:variable name="xvsref" select="@valueSet"/>
        <xsl:variable name="xvsflex" select="
                if (@flexibility) then
                    (@flexibility)
                else
                    ('dynamic')"/>
        <xsl:variable name="xvs">
            <xsl:call-template name="getValueset">
                <xsl:with-param name="reference" select="$xvsref"/>
                <xsl:with-param name="flexibility" select="$xvsflex"/>
            </xsl:call-template>
        </xsl:variable>
        <!-- possible candidates for information in already expanded template format -->
        <xsl:variable name="expvsid" select="@vsid"/>
        <xsl:variable name="expvsdisplayName" select="@vsdisplayName"/>
        <xsl:variable name="expvsname" select="@vsname"/>
        <xsl:for-each select="@*">
            <xsl:variable name="tdcontent" as="element()*">
                <xsl:choose>
                    <xsl:when test="name(.) = 'valueSet'">
                        <xsl:variable name="xvsid">
                            <xsl:choose>
                                <xsl:when test="string-length($expvsid) = 0">
                                    <xsl:value-of select="$xvsref"/>
                                </xsl:when>
                                <xsl:when test="string-length($expvsid) &gt; 0">
                                    <xsl:value-of select="$expvsid"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="($xvs/valueSet)[1]/@id"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:variable>
                        <xsl:variable name="xvsname">
                            <xsl:choose>
                                <xsl:when test="string-length(($xvs/valueSet)[1]/@displayName) &gt; 0">
                                    <xsl:value-of select="($xvs/valueSet)[1]/@displayName"/>
                                </xsl:when>
                                <xsl:when test="$expvsdisplayName">
                                    <xsl:value-of select="$expvsdisplayName"/>
                                </xsl:when>
                                <xsl:when test="$expvsname">
                                    <xsl:value-of select="$expvsname"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="($xvs/valueSet)[1]/@name"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:variable>
                        <xsl:variable name="ahref">
                            <xsl:choose>
                                <xsl:when test="string-length($xvsid) = 0">
                                    <xsl:value-of select="''"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="local:doHtmlName('VS', $xvsid, $xvsflex, '.html')"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:variable>
                        <td xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:variable name="vs" select="."/>
                            <xsl:choose>
                                <xsl:when test="$theStrength = 'preferred'">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeFromValueSetPreferred'"/>
                                        <xsl:with-param name="p1" select="$targetAttributeName"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="$theStrength = 'example'">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeFromValueSetExample'"/>
                                        <xsl:with-param name="p1" select="$targetAttributeName"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="$theStrength = ('CWE', 'extensible')">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeShouldBeFromValueSet'"/>
                                        <xsl:with-param name="p1" select="$targetAttributeName"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeShallBeFromValueSet'"/>
                                        <xsl:with-param name="p1" select="$targetAttributeName"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                            <!-- link to vocab html, if any -->
                            <xsl:choose>
                                <xsl:when test="string-length($ahref) &gt; 0">
                                    <a href="{$ahref}" onclick="target='_blank';">
                                        <xsl:value-of select="$xvsid"/>
                                    </a>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="$xvsid"/>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text> </xsl:text>
                            <!--xsl:if test="string-length(parent::*/@flexibility)>0">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'flexibilityLabel'"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="parent::*/@flexibility"/>
                            </xsl:if-->
                            <xsl:if test="string-length($xvsname) &gt; 0">
                                <i>
                                    <xsl:value-of select="$xvsname"/>
                                    <xsl:text>&#160;</xsl:text>
                                </i>
                            </xsl:if>
                            <xsl:text>(</xsl:text>
                            <xsl:choose>
                                <xsl:when test="matches($xvsflex, '^\d{4}')">
                                    <xsl:call-template name="showDate">
                                        <xsl:with-param name="date" select="$xvsflex"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text>)</xsl:text>
                            <!-- show "value set not found" message if not found -->
                            <xsl:if test="false()">
                                <!-- outcommented temporarily KH 20180418 -->
                                <xsl:if test="count($valueSetReferenceErrors/*/error[@id = $vs]) &gt; 0">
                                    <table style="border: 0;">
                                        <xsl:call-template name="doMessage">
                                            <xsl:with-param name="msg">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'CannotFindValueSet'"/>
                                                    <xsl:with-param name="p1" select="$vs"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </table>
                                </xsl:if>
                            </xsl:if>
                        </td>
                    </xsl:when>
                    <xsl:when test="name(.) = 'code'">
                        <td xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:choose>
                                <xsl:when test="contains($templateFormat, 'hl7v2')">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeorsoShallBeX-v2'"/>
                                        <xsl:with-param name="p1" select="'Identifier'"/>
                                        <xsl:with-param name="p2" select="."/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeorsoShallBeX'"/>
                                        <xsl:with-param name="p1" select="$targetAttributeName"/>
                                        <xsl:with-param name="p2" select="."/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </xsl:when>
                    <xsl:when test="name(.) = 'codeSystem' and not(contains($templateFormat, 'hl7v2') and ../@codeSystemName)">
                        <td xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:choose>
                                <xsl:when test="contains($templateFormat, 'hl7v2')">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeorsoShallBeX-v2'"/>
                                        <xsl:with-param name="p1" select="'Name of Coding System'"/>
                                        <xsl:with-param name="p2" select="."/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeSystemShallBeX'"/>
                                        <xsl:with-param name="p1" select="."/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </xsl:when>
                    <xsl:when test="name(.) = 'codeSystem'"/>
                    <xsl:when test="name(.) = 'displayName'">
                        <td xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:choose>
                                <xsl:when test="contains($templateFormat, 'hl7v2')">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeorsoShallBeX-v2'"/>
                                        <xsl:with-param name="p1" select="'Text'"/>
                                        <xsl:with-param name="p2" select="."/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'displayNameShallBeX'"/>
                                        <xsl:with-param name="p1" select="."/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </xsl:when>
                    <xsl:when test="name(.) = 'codeSystemName'">
                        <td xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:choose>
                                <xsl:when test="contains($templateFormat, 'hl7v2')">
                                    <!-- Assumption: @codeSystemName contains the V2 code system mnemonic -->
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeorsoShallBeX-v2'"/>
                                        <xsl:with-param name="p1" select="'Name of Coding System'"/>
                                        <xsl:with-param name="p2" select="."/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeSystemNameShallBeX'"/>
                                        <xsl:with-param name="p1" select="."/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </xsl:when>
                    <xsl:when test="name(.) = 'codeSystemVersion'">
                        <td xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:choose>
                                <xsl:when test="contains($templateFormat, 'hl7v2')">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeorsoShallBeX-v2'"/>
                                        <xsl:with-param name="p1" select="'Coding System Version ID'"/>
                                        <xsl:with-param name="p2" select="."/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'codeSystemVersionShallBeX'"/>
                                        <xsl:with-param name="p1" select="."/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </xsl:when>
                    <xsl:when test="name(.) = 'domain'">
                        <td xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'domainIsX'"/>
                                <xsl:with-param name="p1" select="."/>
                            </xsl:call-template>
                        </td>
                    </xsl:when>
                    <!--<xsl:when test="name(.)='strength'">
                        <td>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'strengthIsX'"/>
                                <xsl:with-param name="p1" select="."/>
                            </xsl:call-template>
                        </td>
                    </xsl:when>-->
                    <xsl:when test="name(.) = 'flexibility'">
                        <!-- Skip. Is handled within other when leaves -->
                    </xsl:when>
                    <xsl:when test="name(.) = ('vsid', 'vsname', 'vsdisplayName', 'vseffectiveDate', 'vsstatusCode', 'linkedartefactmissing')">
                        <!-- Relax and skip: as this may be included in already exapnded template representations -->
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:call-template name="logMessage">
                            <xsl:with-param name="level" select="$logERROR"/>
                            <xsl:with-param name="msg">
                                <xsl:text>+++ Found unknown vocabulary attribute </xsl:text>
                                <xsl:value-of select="name(.)"/>
                                <xsl:text>="</xsl:text>
                                <xsl:value-of select="."/>
                                <xsl:text>" template id "</xsl:text>
                                <xsl:value-of select="ancestor::template/@id"/>
                                <xsl:text>"</xsl:text>
                            </xsl:with-param>
                        </xsl:call-template>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:if test="count($tdcontent) &gt; 0">
                <tr style="vertical-align: top;" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:copy-of select="$tdcontent"/>
                </tr>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>
    <xsl:template match="example" mode="templateparticle">
        <xsl:param name="parent-id" as="xs:string?" required="yes"/>
        <xsl:param name="fWidth" as="xs:string" select="'10em'"/>
        <!-- 
            show example pretty printed
            if parent is template then different td's are used compared to in-element examples
        -->
        <xsl:variable name="expclass">
            <xsl:choose>
                <xsl:when test="@type = 'valid'">
                    <!-- a valid example, render it green -->
                    <xsl:text>explabelgreen</xsl:text>
                </xsl:when>
                <xsl:when test="@type = 'error'">
                    <!-- an invalid example, render it red -->
                    <xsl:text>explabelred</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <!-- normal rendering otherwise -->
                    <xsl:text>explabelblue</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="difftrclass">
            <xsl:choose>
                <xsl:when test="diff:insert[@name = ('example')]">
                    <xsl:text>ad-diff-green</xsl:text>
                </xsl:when>
                <xsl:when test="diff:delete[@name = ('example')]">
                    <xsl:text>ad-diff-red</xsl:text>
                </xsl:when>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="difftdclass">
            <xsl:if test="diff:*[@name = ('example')]">
                <xsl:text>ad-diff-singlebox</xsl:text>
            </xsl:if>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="parent::template">
                <tr class="explabel {$difftrclass}" style="vertical-align: top;" xmlns="http://www.w3.org/1999/xhtml">
                    <th class="{$difftdclass}" style="width: {$fWidth}; text-align: left;">
                        <xsl:choose>
                            <xsl:when test="@type = 'error'">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'ExampleInvalid'"/>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Example'"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                    </th>
                    <td class="{$expclass}" colspan="3">
                        <table class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                            <tr class="desclabel" data-tt-id="example-{generate-id(.)}">
                                <td class="togglertreetable" style="height: 1.5em;">
                                    <span class="expcaption">
                                        <xsl:choose>
                                            <xsl:when test="@caption">
                                                <xsl:value-of select="@caption"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Example'"/>
                                                </xsl:call-template>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </span>
                                </td>
                            </tr>
                            <tr data-tt-id="exampleBody-{generate-id(.)}" data-tt-parent-id="example-{generate-id(.)}">
                                <td>
                                    <span style="font-family: Courier, 'Courier New', monospace; ">
                                        <xsl:apply-templates mode="explrender"/>
                                    </span>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </xsl:when>
            <xsl:otherwise>
                <tr class="explabel {$difftrclass}" style="vertical-align: top;" data-tt-id="{generate-id(.)}-exmpl" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <td style="background-color: white;" colspan="1">&#160;</td>
                    <td class="{$difftdclass}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Example'"/>
                        </xsl:call-template>
                    </td>
                    <td class="{$expclass}" colspan="4">
                        <xsl:if test="@caption">
                            <div class="expcaption">
                                <xsl:value-of select="@caption"/>
                            </div>
                        </xsl:if>
                        <span style="font-family: Courier, 'Courier New', monospace; ">
                            <xsl:apply-templates mode="explrender"/>
                        </span>
                    </td>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
        <!-- -->
    </xsl:template>
    <xsl:template name="doIndentLevel">
        <xsl:param name="level"/>
        <xsl:param name="icon" select="true()" as="xs:boolean"/>
        <xsl:for-each select="1 to $level - 1">
            <td style="vertical-align: top;" xmlns="http://www.w3.org/1999/xhtml">
                <xsl:call-template name="showIcon">
                    <xsl:with-param name="which">treeblank</xsl:with-param>
                </xsl:call-template>
            </td>
        </xsl:for-each>
        <xsl:if test="$level &gt; 0 and $icon">
            <td style="vertical-align: top;" xmlns="http://www.w3.org/1999/xhtml">
                <xsl:call-template name="showIcon">
                    <xsl:with-param name="which">treetree</xsl:with-param>
                </xsl:call-template>
            </td>
        </xsl:if>
    </xsl:template>
    <xsl:template name="doShowIssues">
        <!-- correction for printing, no extended h3 tag when printing, some more when HTML rendering -->
        <xsl:param name="extendedh3" select="true()"/>
        <!-- 
            create a new nodeset with
            all issues that are not closed and not cancelled wrapped in <open>
            and all other issues wrapped in <closed>
        -->
        <xsl:variable name="newnodeset">
            <issues xmlns="">
                <xsl:for-each select="$allIssues/issue">
                    <xsl:variable name="startDate" select="min((tracking | assignment)/xs:dateTime(@effectiveDate))"/>
                    <xsl:variable name="newestTrackingOrAssignment" select="max((tracking | assignment)/xs:dateTime(@effectiveDate))"/>
                    <xsl:variable name="currentStatus" select="((tracking | assignment)[@statusCode][@effectiveDate = max(../(tracking | assignment)[@statusCode]/xs:dateTime(@effectiveDate))]/@statusCode)[1]"/>
                    <xsl:variable name="newestTracking" select="(tracking[@effectiveDate = max(../tracking/xs:dateTime(@effectiveDate))])[1]"/>
                    <xsl:variable name="newestAssignment" select="(assignment[@effectiveDate = max(../assignment/xs:dateTime(@effectiveDate))])[1]"/>
                    <xsl:variable name="assignedTo" select="$newestAssignment/@to"/>
                    <xsl:variable name="assignedName" select="$newestAssignment/@name"/>
                    <xsl:variable name="elmName">
                        <xsl:choose>
                            <xsl:when test="$currentStatus = ('closed', 'cancelled')">closed</xsl:when>
                            <xsl:otherwise>open</xsl:otherwise>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:element name="{$elmName}">
                        <xsl:attribute name="currentStatus" select="$currentStatus"/>
                        <xsl:attribute name="startDate" select="$startDate"/>
                        <xsl:attribute name="newestTrackingOrAssignment" select="$newestTrackingOrAssignment"/>
                        <xsl:if test="exists($newestTracking)">
                            <xsl:attribute name="newestTracking" select="$newestTracking/@effectiveDate"/>
                        </xsl:if>
                        <xsl:if test="exists($newestAssignment)">
                            <xsl:attribute name="newestAssignment" select="$newestAssignment/@effectiveDate"/>
                            <xsl:attribute name="assignedTo" select="$assignedTo"/>
                            <xsl:attribute name="assignedName" select="$assignedName"/>
                        </xsl:if>
                        <xsl:copy-of select="."/>
                    </xsl:element>
                </xsl:for-each>
            </issues>
        </xsl:variable>
        <!-- 
            emit issues
            grouped by assigned vs not assigned (existence of assignment)
            sorted by assignee (@to)
            sorted by status code (all trackings)
            1 new open
            2 inprogress feedback 
            3 closed rejected deferred cancelled
            sorted by tracking[1]/@effectiveDate
            sorted by @displayName
        -->
        <table width="100%" border="0" cellspacing="0" cellpadding="0" xmlns="http://www.w3.org/1999/xhtml">
            <!-- issuesAlreadyAssigned -->
            <tr>
                <td colspan="2">
                    <h2>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'issuesAlreadyAssigned'"/>
                        </xsl:call-template>
                    </h2>
                </td>
            </tr>
            <xsl:for-each-group select="$newnodeset/*/open[@assignedTo]" group-by="@assignedTo">
                <tr>
                    <td colspan="2">
                        <h3>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'actuallyAssignedTo'"/>
                                <xsl:with-param name="p1" select="@assignedTo"/>
                                <xsl:with-param name="p2" select="@assignedName"/>
                            </xsl:call-template>
                        </h3>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <xsl:for-each select="current-group()/issue">
                            <xsl:sort select="parent::*/@currentStatus"/>
                            <xsl:sort select="parent::*/@startDate"/>
                            <xsl:sort select="@displayName"/>
                            <xsl:apply-templates select=".">
                                <xsl:with-param name="extendedh3" select="$extendedh3"/>
                            </xsl:apply-templates>
                        </xsl:for-each>
                    </td>
                </tr>
            </xsl:for-each-group>
            <!-- issuesNotYetAssigned -->
            <tr>
                <td colspan="2">
                    <h2>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'issuesNotYetAssigned'"/>
                        </xsl:call-template>
                    </h2>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <xsl:for-each select="$newnodeset/*/open[not(@assignedTo)]/issue">
                        <xsl:sort select="parent::*/@currentStatus"/>
                        <xsl:sort select="parent::*/@startDate"/>
                        <xsl:sort select="@displayName"/>
                        <xsl:apply-templates select=".">
                            <xsl:with-param name="extendedh3" select="$extendedh3"/>
                        </xsl:apply-templates>
                    </xsl:for-each>
                </td>
            </tr>
            <!-- issuesNotActive -->
            <tr>
                <td colspan="2">
                    <h2>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'issuesNotActive'"/>
                        </xsl:call-template>
                    </h2>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <xsl:for-each select="$newnodeset/*/closed/issue">
                        <xsl:sort select="parent::*/@currentStatus"/>
                        <xsl:sort select="@displayName"/>
                        <xsl:apply-templates select=".">
                            <xsl:with-param name="extendedh3" select="$extendedh3"/>
                        </xsl:apply-templates>
                    </xsl:for-each>
                </td>
            </tr>
        </table>
        <table width="100%" border="0" cellspacing="3" cellpadding="2" xmlns="http://www.w3.org/1999/xhtml">
            <xsl:if test="$allIssues/labels/label">
                <tr>
                    <td colspan="2">
                        <h2>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'definedLabels'"/>
                            </xsl:call-template>
                        </h2>
                        <table width="100%">
                            <thead>
                                <tr>
                                    <th>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'definedColor'"/>
                                        </xsl:call-template>
                                    </th>
                                    <th>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'definedCode'"/>
                                        </xsl:call-template>
                                    </th>
                                    <th>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'definedName'"/>
                                        </xsl:call-template>
                                    </th>
                                    <th>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Description'"/>
                                        </xsl:call-template>
                                    </th>
                                    <th>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'IsUsed'"/>
                                        </xsl:call-template>
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <xsl:for-each select="$allIssues/labels/label">
                                    <xsl:sort select="@code"/>
                                    <xsl:apply-templates select="." mode="definition"/>
                                </xsl:for-each>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="$allMissingLabels/wrap/missingCode">
                <tr>
                    <td colspan="2">
                        <h2>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'usedButUndefinedLabels'"/>
                            </xsl:call-template>
                        </h2>
                        <table width="100%">
                            <thead>
                                <tr>
                                    <th>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'definedCode'"/>
                                        </xsl:call-template>
                                    </th>
                                    <th>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Issue'"/>
                                        </xsl:call-template>
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <xsl:for-each select="$allMissingLabels/wrap/missingCode">
                                    <tr>
                                        <td>
                                            <xsl:value-of select="@labelCode"/>
                                        </td>
                                        <td>
                                            <xsl:text>(</xsl:text>
                                            <xsl:call-template name="doShorthandId">
                                                <xsl:with-param name="id" select="@ref"/>
                                            </xsl:call-template>
                                            <xsl:text>) </xsl:text>
                                            <xsl:value-of select="@refName"/>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </xsl:if>
        </table>
    </xsl:template>
    <xsl:template match="issue">
        <!--
            correction for printing, no extended h3 tag when printing 
            new 2014-03-13: don't show issue tracking or assignments with content, only headings and link to live issue in ART.
        -->
        <xsl:param name="extendedh3" select="true()"/>
        <xsl:variable name="issueId" select="@id"/>
        <xsl:variable name="newestTracking" select="max(tracking/xs:dateTime(@effectiveDate))"/>
        <xsl:variable name="newestAssignment" select="max(assignment/xs:dateTime(@effectiveDate))"/>
        <xsl:variable name="newestTrackingOrAssignment" select="max((tracking | assignment)/xs:dateTime(@effectiveDate))"/>
        <xsl:variable name="currentStatus" select="((tracking | assignment)[@statusCode][@effectiveDate = max(../(tracking | assignment)[@statusCode]/xs:dateTime(@effectiveDate))]/@statusCode)[1]"/>
        <xsl:variable name="issuename">
            <xsl:choose>
                <xsl:when test="string-length(@displayName) &gt; 0">
                    <xsl:value-of select="@displayName"/>
                </xsl:when>
                <xsl:otherwise>
                    <span style="color: grey;" xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'notLabeled'"/>
                        </xsl:call-template>
                    </span>
                </xsl:otherwise>
            </xsl:choose>
            <!--
                <xsl:text> (</xsl:text>
                <xsl:value-of select="@type"/>
                <xsl:text>)</xsl:text>
            -->
        </xsl:variable>
        <a xmlns="http://www.w3.org/1999/xhtml">
            <xsl:attribute name="name">
                <xsl:call-template name="doShorthandId">
                    <xsl:with-param name="id" select="$issueId"/>
                </xsl:call-template>
            </xsl:attribute>
        </a>
        <div class="AccordionPanel" xmlns="http://www.w3.org/1999/xhtml">
            <div class="AccordionPanelTab">
                <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                    <h3>
                        <xsl:variable name="theStatus" select="(tracking[@effectiveDate = $newestTracking]/@statusCode)[last()]"/>
                        <xsl:call-template name="showStatusDot">
                            <xsl:with-param name="status" select="$theStatus"/>
                            <xsl:with-param name="title">
                                <xsl:call-template name="getXFormsLabel">
                                    <xsl:with-param name="simpleTypeKey" select="'IssueStatusCodeLifeCycle'"/>
                                    <xsl:with-param name="simpleTypeValue" select="$theStatus"/>
                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                </xsl:call-template>
                            </xsl:with-param>
                        </xsl:call-template>
                        <xsl:text>&#160;(</xsl:text>
                        <xsl:call-template name="doShorthandId">
                            <xsl:with-param name="id" select="$issueId"/>
                        </xsl:call-template>
                        <xsl:text>)&#160;</xsl:text>
                        <xsl:copy-of select="$issuename"/>
                    </h3>
                    <xsl:if test="$extendedh3 = true()">
                        <!-- is this issue already assigned to someone, if so, get the last assignment -->
                        <xsl:variable name="assignedTo">
                            <xsl:choose>
                                <xsl:when test="string-length(assignment[@effectiveDate = $newestAssignment]/@name) &gt; 0">
                                    <xsl:value-of select="assignment[@effectiveDate = $newestAssignment]/@name"/>
                                </xsl:when>
                                <xsl:when test="string-length(assignment[@effectiveDate = $newestAssignment]/@to) &gt; 0">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'entityNumber'"/>
                                        <xsl:with-param name="p1" select="assignment[@effectiveDate = $newestAssignment]/@to"/>
                                    </xsl:call-template>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:variable>
                        <div class="comment">
                            <xsl:call-template name="showIssueType">
                                <xsl:with-param name="it" select="@type"/>
                            </xsl:call-template>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'issueIdX'"/>
                                <xsl:with-param name="p1" select="$issueId"/>
                            </xsl:call-template>
                            <br/>
                            <xsl:choose>
                                <xsl:when test="string-length($assignedTo) = 0">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'notAssignedYet'"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'lastAssignedTo'"/>
                                        <xsl:with-param name="p1" select="$assignedTo"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </xsl:if>
                </div>
            </div>
            <div class="AccordionPanelContent">
                <table width="100%" border="0" cellspacing="3" cellpadding="2">
                    <tr>
                        <th style="border:1px solid #C0C0C0; width: 107pt; text-align: left;">
                            <strong>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Issue'"/>
                                </xsl:call-template>
                            </strong>
                        </th>
                        <td style="background-color: #F6F3EE;" colspan="2">
                            <xsl:copy-of select="$issuename"/>
                        </td>
                    </tr>
                    <tr style="vertical-align: top;">
                        <th style="text-align: left;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Id'"/>
                            </xsl:call-template>
                        </th>
                        <td style="background-color: #F6F3EE;" colspan="2">
                            <xsl:call-template name="doShorthandId">
                                <xsl:with-param name="id" select="$issueId"/>
                            </xsl:call-template>
                        </td>
                    </tr>
                    <tr style="vertical-align: top;">
                        <th style="text-align: left;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Type'"/>
                            </xsl:call-template>
                        </th>
                        <td style="background-color: #F6F3EE;" colspan="2">
                            <xsl:call-template name="showIssueType">
                                <xsl:with-param name="it" select="@type"/>
                            </xsl:call-template>
                        </td>
                    </tr>
                    <tr style="vertical-align: top;">
                        <th style="text-align: left;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Status'"/>
                            </xsl:call-template>
                        </th>
                        <td style="background-color: #F6F3EE;" colspan="2">
                            <xsl:call-template name="showStatusDot">
                                <xsl:with-param name="status" select="$currentStatus"/>
                                <xsl:with-param name="title">
                                    <xsl:call-template name="getXFormsLabel">
                                        <xsl:with-param name="simpleTypeKey" select="'IssueStatusCodeLifeCycle'"/>
                                        <xsl:with-param name="simpleTypeValue" select="$currentStatus"/>
                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                    </xsl:call-template>
                                </xsl:with-param>
                            </xsl:call-template>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:call-template name="getXFormsLabel">
                                <xsl:with-param name="simpleTypeKey" select="'IssueStatusCodeLifeCycle'"/>
                                <xsl:with-param name="simpleTypeValue" select="$currentStatus"/>
                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                            </xsl:call-template>
                            <xsl:if test="count(assignment) &gt; 0">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'commaAssigned'"/>
                                </xsl:call-template>
                            </xsl:if>
                        </td>
                    </tr>
                    <tr style="vertical-align: top;">
                        <th style="text-align: left;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Priority'"/>
                            </xsl:call-template>
                        </th>
                        <td style="background-color: #F6F3EE;" colspan="2">
                            <xsl:variable name="iprio" select="tracking[@effectiveDate = $newestTracking]/@priority"/>
                            <xsl:choose>
                                <xsl:when test="$iprio = 'HH'">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'highest'"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="$iprio = 'H'">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'high'"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="$iprio = 'L'">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'low'"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="$iprio = 'LL'">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'lowest'"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'normal'"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </tr>
                    <xsl:if test="((tracking | assignment)[@effectiveDate = $newestTrackingOrAssignment]/@labels)[last()] != ''">
                        <tr style="vertical-align: top;">
                            <th style="text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Labels'"/>
                                </xsl:call-template>
                            </th>
                            <td style="background-color: #F6F3EE;" colspan="2">
                                <xsl:call-template name="showLabels">
                                    <xsl:with-param name="labels" select="((tracking | assignment)[@effectiveDate = $newestTrackingOrAssignment]/@labels)[last()]"/>
                                </xsl:call-template>
                            </td>
                        </tr>
                    </xsl:if>
                    <xsl:for-each select="object">
                        <xsl:variable name="objectId" select="@id" as="xs:string"/>
                        <xsl:variable name="objectDate" select="@effectiveDate" as="xs:string?"/>
                        <xsl:variable name="object" select="($allDECOR//*[not(self::object)][@id = $objectId][@effectiveDate = $objectDate or string-length($objectDate) = 0])[1]" as="element()?"/>
                        <tr style="vertical-align: top;">
                            <th style="vertical-align: top; text-align: left;">
                                <xsl:if test="position() = 1">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'objectsLabel'"/>
                                    </xsl:call-template>
                                </xsl:if>
                            </th>
                            <td style="background-color: #F6F3EE;" colspan="2">
                                <xsl:choose>
                                    <xsl:when test="empty($object)">
                                        <span style="color: red; font-style: italic;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'compileTimeObjectReferenceTargetMissing'"/>
                                            </xsl:call-template>
                                        </span>
                                        <xsl:text>&#160;</xsl:text>
                                        <xsl:call-template name="doShorthandId">
                                            <xsl:with-param name="id" select="$objectId"/>
                                        </xsl:call-template>
                                        <xsl:if test="$objectDate castable as xs:dateTime">
                                            <xsl:text>&#160;(</xsl:text>
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$objectDate"/>
                                            </xsl:call-template>
                                            <xsl:text>)</xsl:text>
                                        </xsl:if>
                                        <xsl:if test="@name | @displayName">
                                            <xsl:text> </xsl:text>
                                            <xsl:value-of select="(@displayName, @name)[1]"/>
                                        </xsl:if>
                                    </xsl:when>
                                    <xsl:when test="@type = 'VS'">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueOnVS'"/>
                                        </xsl:call-template>
                                        <xsl:text>&#160;</xsl:text>
                                        <a href="{local:doHtmlName('VS', $objectId, ($objectDate[. castable as xs:dateTime], 'dynamic')[1], '.html')}" onclick="target='_blank';">
                                            <xsl:call-template name="doShorthandId">
                                                <xsl:with-param name="id" select="$object/@id"/>
                                            </xsl:call-template>
                                            <xsl:if test="$objectDate">
                                                <xsl:text>&#160;(</xsl:text>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="$objectDate"/>
                                                </xsl:call-template>
                                                <xsl:text>)</xsl:text>
                                            </xsl:if>
                                        </a>
                                    </xsl:when>
                                    <xsl:when test="@type = 'CS'">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueOnCS'"/>
                                        </xsl:call-template>
                                        <xsl:text>&#160;</xsl:text>
                                        <xsl:call-template name="doShorthandId">
                                            <xsl:with-param name="id" select="$object/@id"/>
                                        </xsl:call-template>
                                        <xsl:if test="$objectDate">
                                            <xsl:text>&#160;(</xsl:text>
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$objectDate"/>
                                            </xsl:call-template>
                                            <xsl:text>)</xsl:text>
                                        </xsl:if>
                                    </xsl:when>
                                    <xsl:when test="@type = 'DE'">
                                        <xsl:variable name="dsid" select="$object/ancestor::dataset/@id"/>
                                        <xsl:variable name="dseff" select="$object/ancestor::dataset/@effectiveDate"/>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueOnDE'"/>
                                        </xsl:call-template>
                                        <xsl:text>&#160;</xsl:text>
                                        <a href="{local:doHtmlName('DS', $projectPrefix, $dsid, $dseff, $objectId, $objectDate, (), (), '.html', false())}" onclick="target='_blank';">
                                            <xsl:call-template name="doShorthandId">
                                                <xsl:with-param name="id" select="$objectId"/>
                                            </xsl:call-template>
                                            <xsl:text>&#160;</xsl:text>
                                            <xsl:text>"</xsl:text>
                                            <xsl:call-template name="doName">
                                                <xsl:with-param name="ns" select="$object/name"/>
                                            </xsl:call-template>
                                            <xsl:text>"</xsl:text>
                                        </a>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'fromDatasetLabel'"/>
                                        </xsl:call-template>
                                        <xsl:text>"</xsl:text>
                                        <xsl:call-template name="doName">
                                            <xsl:with-param name="ns" select="$object/ancestor::dataset/name"/>
                                        </xsl:call-template>
                                        <xsl:text>"</xsl:text>
                                        <xsl:text>&#160;</xsl:text>
                                        <xsl:call-template name="showDate">
                                            <xsl:with-param name="date" select="$object/ancestor::dataset/@effectiveDate"/>
                                        </xsl:call-template>
                                        <xsl:if test="count($object/ancestor::concept) &gt; 0">
                                            <br/>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'pathToElement'"/>
                                            </xsl:call-template>
                                            <xsl:text>: </xsl:text>
                                            <xsl:for-each select="$object/ancestor::concept">
                                                <xsl:call-template name="doName">
                                                    <xsl:with-param name="ns" select="name"/>
                                                </xsl:call-template>
                                                <xsl:if test="position() != last()">
                                                    <xsl:text> / </xsl:text>
                                                </xsl:if>
                                            </xsl:for-each>
                                        </xsl:if>
                                    </xsl:when>
                                    <xsl:when test="@type = 'DS'">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueOnDS'"/>
                                        </xsl:call-template>
                                        <xsl:text>&#160;</xsl:text>
                                        <a href="{local:doHtmlName('DS',$objectId,$objectDate,'.html')}">
                                            <xsl:call-template name="doName">
                                                <xsl:with-param name="ns" select="$object/name"/>
                                            </xsl:call-template>
                                            <xsl:text>&#160;</xsl:text>
                                            <xsl:call-template name="doShorthandId">
                                                <xsl:with-param name="id" select="$objectId"/>
                                            </xsl:call-template>
                                            <xsl:if test="$objectDate">
                                                <xsl:text>&#160;(</xsl:text>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="$objectDate"/>
                                                </xsl:call-template>
                                                <xsl:text>)</xsl:text>
                                            </xsl:if>
                                        </a>
                                    </xsl:when>
                                    <xsl:when test="@type = 'TM'">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueOnTM'"/>
                                        </xsl:call-template>
                                        <xsl:text>&#160;</xsl:text>
                                        <a href="{local:doHtmlName('TM', $objectId, ($objectDate[. castable as xs:dateTime], 'dynamic')[1], '.html')}" onclick="target='_blank';">
                                            <xsl:value-of select="($object/@displayName, $object/@name)[1]"/>
                                            <xsl:text>&#160;</xsl:text>
                                            <xsl:call-template name="doShorthandId">
                                                <xsl:with-param name="id" select="$objectId"/>
                                            </xsl:call-template>
                                            <xsl:if test="$objectDate">
                                                <xsl:text>&#160;(</xsl:text>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="$objectDate"/>
                                                </xsl:call-template>
                                                <xsl:text>)</xsl:text>
                                            </xsl:if>
                                        </a>
                                    </xsl:when>
                                    <!-- Type is EL is BS. Template element/attribute ids are only unique within the template, 
                                        so any id could return multiple template elements/attributes -->
                                    <xsl:when test="@type = 'EL'">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueOnEL'"/>
                                        </xsl:call-template>
                                        <xsl:text>&#160;</xsl:text>
                                        <xsl:if test="exists($object/@name)">
                                            <xsl:value-of select="$object/@name"/>
                                            <xsl:text>&#160;</xsl:text>
                                        </xsl:if>
                                        <xsl:call-template name="doShorthandId">
                                            <xsl:with-param name="id" select="$objectId"/>
                                        </xsl:call-template>
                                        <xsl:if test="$objectDate">
                                            <xsl:text>&#160;(</xsl:text>
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$objectDate"/>
                                            </xsl:call-template>
                                            <xsl:text>)</xsl:text>
                                        </xsl:if>
                                    </xsl:when>
                                    <xsl:when test="@type = ('SC', 'TR')">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueOnSC'"/>
                                        </xsl:call-template>
                                        <xsl:text>&#160;</xsl:text>
                                        <a href="{local:doHtmlName('tabScenarios', (), (), '.html', true())}">
                                            <xsl:call-template name="doName">
                                                <xsl:with-param name="ns" select="$object/name"/>
                                            </xsl:call-template>
                                            <xsl:text>&#160;</xsl:text>
                                            <xsl:call-template name="doShorthandId">
                                                <xsl:with-param name="id" select="$objectId"/>
                                            </xsl:call-template>
                                            <xsl:if test="$objectDate castable as xs:dateTime">
                                                <xsl:text>&#160;(</xsl:text>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="$objectDate"/>
                                                </xsl:call-template>
                                                <xsl:text>)</xsl:text>
                                            </xsl:if>
                                        </a>
                                    </xsl:when>
                                    <xsl:when test="@type = 'IS'">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'issueOnIS'"/>
                                        </xsl:call-template>
                                        <xsl:text>&#160;</xsl:text>
                                        <a href="{local:doHtmlName('tabIssues', $projectPrefix, (), (), $objectId, $objectDate, (), (), '.html', true())}" onclick="target='_blank';">
                                            <xsl:if test="exists($object/@displayName)">
                                                <xsl:value-of select="$object/@displayName"/>
                                                <xsl:text>&#160;</xsl:text>
                                            </xsl:if>
                                            <xsl:call-template name="doShorthandId">
                                                <xsl:with-param name="id" select="$objectId"/>
                                            </xsl:call-template>
                                            <xsl:if test="$objectDate">
                                                <xsl:text>&#160;(</xsl:text>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="$objectDate"/>
                                                </xsl:call-template>
                                                <xsl:text>)</xsl:text>
                                            </xsl:if>
                                        </a>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="@type"/>
                                        <xsl:text>&#160;</xsl:text>
                                        <xsl:choose>
                                            <xsl:when test="exists($object/name)">
                                                <xsl:call-template name="doName">
                                                    <xsl:with-param name="ns" select="$object/name"/>
                                                </xsl:call-template>
                                                <xsl:text>&#160;</xsl:text>
                                            </xsl:when>
                                            <xsl:when test="exists($object/@displayName)">
                                                <xsl:value-of select="$object/@displayName"/>
                                                <xsl:text>&#160;</xsl:text>
                                            </xsl:when>
                                            <xsl:when test="exists($object/@name)">
                                                <xsl:value-of select="$object/@name"/>
                                                <xsl:text>&#160;</xsl:text>
                                            </xsl:when>
                                        </xsl:choose>
                                        <xsl:call-template name="doShorthandId">
                                            <xsl:with-param name="id" select="$objectId"/>
                                        </xsl:call-template>
                                        <xsl:if test="$objectDate castable as xs:dateTime">
                                            <xsl:text>&#160;(</xsl:text>
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$objectDate"/>
                                            </xsl:call-template>
                                            <xsl:text>)</xsl:text>
                                        </xsl:if>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                        </tr>
                    </xsl:for-each>
                    <!-- new 2014-03-13: don't show tracking|assignment with content, only live link to ART -->
                    <!--<xsl:for-each select="tracking | assignment">
                        <xsl:sort select="xs:dateTime(@effectiveDate)" order="descending"/>
                        <xsl:choose>
                            <xsl:when test="name() = 'tracking'">
                                <tr style="vertical-align: top;">
                                    <th style="width: 137px; text-align: center;">
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">tracking</xsl:with-param>
                                        </xsl:call-template>
                                    </th>
                                    <th style="text-align: left;" colspan="2">
                                        <xsl:call-template name="showStatusDot">
                                            <xsl:with-param name="status" select="@statusCode"/>
                                            <xsl:with-param name="title">
                                                <xsl:call-template name="getXFormsLabel">
                                                    <xsl:with-param name="simpleTypeKey" select="'IssueStatusCodeLifeCycle'"/>
                                                    <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'trackingStatus'"/>
                                            <xsl:with-param name="p1">
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="@effectiveDate"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                            <xsl:with-param name="p2">
                                                <xsl:call-template name="getXFormsLabel">
                                                    <xsl:with-param name="simpleTypeKey" select="'IssueStatusCodeLifeCycle'"/>
                                                    <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </th>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>&#160;</td>
                                    <th style="width: 107px; text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'authorLabel'"/>
                                        </xsl:call-template>
                                    </th>
                                    <td style="background-color: #F6F3EE;">
                                        <xsl:value-of select="author/text()"/>
                                    </td>
                                </tr>
                                <xsl:if test="@labels">
                                    <tr style="vertical-align: top;">
                                        <td>&#160;</td>
                                        <th style="width: 107px; text-align: left;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Labels'"/>
                                            </xsl:call-template>
                                        </th>
                                        <td style="background-color: #F6F3EE;">
                                            <xsl:call-template name="showLabels">
                                                <xsl:with-param name="labels" select="@labels"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
                                    <tr style="vertical-align: top;">
                                        <td>&#160;</td>
                                        <th style="vertical-align: top; width: 107px; text-align: left;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Description'"/>
                                            </xsl:call-template>
                                        </th>
                                        <td class="descitem">
                                            <xsl:choose>
                                                <xsl:when test="@statusCode = 'new'">
                                                    <span style="color: grey;">
                                                        <xsl:call-template name="doDescription">
                                                            <xsl:with-param name="ns" select="desc"/>
                                                        </xsl:call-template>
                                                    </span>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="doDescription">
                                                        <xsl:with-param name="ns" select="desc"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </td>
                                    </tr>
                                </xsl:if>
                            </xsl:when>
                            <xsl:when test="name() = 'assignment'">
                                <!-\- 
                                    <assignment to="6" effectiveDate="2011-12-11T00:00:00">Redactieraad perinatologie
                                      <author id="1">Kai Heitmann</author>
                                      <desc language="nl-NL">Op welke manier wordt deze value set uitgebreid?</desc>
                                    </assignment>
                                -\->
                                <tr style="vertical-align: top;">
                                    <th style="width: 137px; text-align: center;">
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">arrowright</xsl:with-param>
                                        </xsl:call-template>
                                    </th>
                                    <th colspan="2" style="background-color: #F6F3EE;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'assignedToEntity'"/>
                                            <xsl:with-param name="p1" select="@name"/>
                                            <xsl:with-param name="p2" select="@to"/>
                                        </xsl:call-template>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'onDate'"/>
                                            <xsl:with-param name="p1">
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="@effectiveDate"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                        </xsl:call-template>
                                    </th>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>&#160;</td>
                                    <th style="width: 107px;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'authorLabel'"/>
                                        </xsl:call-template>
                                    </th>
                                    <td style="background-color: #F6F3EE;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'assignedByEntity'"/>
                                            <xsl:with-param name="p1" select="author/text()"/>
                                            <xsl:with-param name="p2" select="author/@id"/>
                                        </xsl:call-template>
                                    </td>
                                </tr>
                                <xsl:if test="@labels">
                                    <tr style="vertical-align: top;">
                                        <td>&#160;</td>
                                        <th style="width: 107px; text-align: left;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Labels'"/>
                                            </xsl:call-template>
                                        </th>
                                        <td style="background-color: #F6F3EE;">
                                            <xsl:call-template name="showLabels">
                                                <xsl:with-param name="labels" select="@labels"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <xsl:if test="string-length(normalize-space(desc)) &gt; 0">
                                    <tr style="vertical-align: top;">
                                        <td>&#160;</td>
                                        <th style="width: 107px; vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Description'"/>
                                            </xsl:call-template>
                                        </th>
                                        <td class="descitem">
                                            <xsl:choose>
                                                <xsl:when test="@statusCode = 'new'">
                                                    <span style="color: grey;">
                                                        <xsl:call-template name="doDescription">
                                                            <xsl:with-param name="ns" select="desc"/>
                                                        </xsl:call-template>
                                                    </span>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="doDescription">
                                                        <xsl:with-param name="ns" select="desc"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </td>
                                    </tr>
                                </xsl:if>
                            </xsl:when>
                        </xsl:choose>
                    </xsl:for-each>-->
                    <xsl:if test="string-length($artdecordeeplinkprefix) &gt; 0">
                        <tr style="vertical-align: top;">
                            <th style="vertical-align: top; text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Details'"/>
                                </xsl:call-template>
                            </th>
                            <td style="background-color: #F6F3EE;" colspan="2">
                                <xsl:call-template name="showIcon">
                                    <xsl:with-param name="which">arrowright</xsl:with-param>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <a href="{$artdecordeeplinkprefix}decor-issues--{$projectPrefix}?issueId={@id}&amp;serclosed=true&amp;language={$defaultLanguage}">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'DetailsLink'"/>
                                    </xsl:call-template>
                                </a>
                            </td>
                        </tr>
                    </xsl:if>
                    <!-- Email link -->
                    <xsl:if test="string-length($projectContactEmail) &gt; 0">
                        <tr valign="middle">
                            <td>
                                <xsl:call-template name="showIcon">
                                    <xsl:with-param name="which">flag</xsl:with-param>
                                </xsl:call-template>
                            </td>
                            <td colspan="2">
                                <xsl:variable name="theHref">
                                    <!-- email address -->
                                    <xsl:text>mailto:</xsl:text>
                                    <xsl:value-of select="$projectContactEmail"/>
                                    <!-- subject -->
                                    <xsl:text>?subject=</xsl:text>
                                    <xsl:variable name="subj">
                                        <xsl:text>New comment on issue #</xsl:text>
                                        <xsl:value-of select="@id"/>
                                        <xsl:text>&#160;</xsl:text>
                                        <xsl:value-of select="$issuename" disable-output-escaping="yes"/>
                                        <xsl:text> (Project: </xsl:text>
                                        <xsl:value-of select="$projectName" disable-output-escaping="yes"/>
                                        <xsl:text>)</xsl:text>
                                    </xsl:variable>
                                    <xsl:value-of select="$subj" disable-output-escaping="yes"/>
                                </xsl:variable>
                                <i>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'notTheInteractiveVersion-1'"/>
                                    </xsl:call-template>
                                    <a href="{$theHref}">
                                        <xsl:text>email</xsl:text>
                                    </a>
                                    <xsl:text> </xsl:text>
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which">mail</xsl:with-param>
                                    </xsl:call-template>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'notTheInteractiveVersion-2'"/>
                                    </xsl:call-template>
                                </i>
                            </td>
                        </tr>
                    </xsl:if>
                </table>
            </div>
        </div>
    </xsl:template>
    <xsl:template name="showLabels">
        <xsl:param name="labels"/>
        <xsl:if test="$labels != ''">
            <xsl:for-each select="tokenize($labels, ' ')">
                <xsl:variable name="labelCode" select="."/>
                <xsl:variable name="labelName">
                    <xsl:choose>
                        <xsl:when test="$allIssues/labels/label[@code = $labelCode]">
                            <xsl:value-of select="$allIssues/labels/label[@code = $labelCode]/@name"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$labelCode"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="labelColor">
                    <xsl:choose>
                        <xsl:when test="$allIssues/labels/label[@code = $labelCode]">
                            <xsl:value-of select="$allIssues/labels/label[@code = $labelCode]/@color"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <!-- default color is white. Could read the DECOR.xsd schema for this to be configurable -->
                            <xsl:value-of select="'white'"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                <div class="issuelabel-outer" title="{$labelName}" xmlns="http://www.w3.org/1999/xhtml">
                    <div class="issuelabel-color" style="background-color: {$labelColor};">&#160;</div>
                    <div class="issuelabel-text">
                        <xsl:value-of select="concat('&#160;(', $labelCode, ')&#160;', $labelName, '&#160;')"/>
                    </div>
                </div>
            </xsl:for-each>
        </xsl:if>
    </xsl:template>
    <xsl:template match="label" mode="definition">
        <!-- correction for printing, no extended h3 tag when printing -->
        <xsl:param name="extendedh3" select="true()"/>
        <xsl:variable name="labelCode" select="@code"/>
        <xsl:variable name="isUsed" select="exists(ancestor::issues[last()]//(tracking | assignment)[count(index-of(tokenize(@labels, ' '), $labelCode)) &gt;= 1])"/>
        <tr xmlns="http://www.w3.org/1999/xhtml">
            <td>
                <a name="labelCode{@code}"/>
                <div class="issuelabel-color" style="background-color: {@color};">&#160;</div>
                <div class="issuelabel-text">
                    <xsl:value-of select="@color"/>
                </div>
            </td>
            <td>
                <xsl:value-of select="@code"/>
            </td>
            <td>
                <xsl:value-of select="@name"/>
            </td>
            <td>
                <xsl:call-template name="doDescription">
                    <xsl:with-param name="ns" select="desc"/>
                </xsl:call-template>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="$isUsed">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'yes'"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'no'"/>
                        </xsl:call-template>
                    </xsl:otherwise>
                </xsl:choose>
            </td>
        </tr>
    </xsl:template>
    <xsl:template match="assert | report | let | defineVariable" mode="templateparticle">
        <xsl:param name="parent-id" as="xs:string?" required="yes"/>
        <xsl:variable name="node-id" select="concat(generate-id(.), '-defvar')"/>
        <xsl:choose>
            <xsl:when test="name() = 'defineVariable'">
                <xsl:variable name="rowspans" select="count(@path | code[@code[string-length() > 0] | @codeSystem[string-length() > 0]] | use) + 1"/>
                <tr style="vertical-align: top;" data-tt-id="{$node-id}" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <td style="background-color: white;" colspan="1">&#160;</td>
                    <td class="defvar" rowspan="{$rowspans}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Variable'"/>
                        </xsl:call-template>
                    </td>
                    <td style="background-color: #FFEEEE;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'name'"/>
                        </xsl:call-template>
                    </td>
                    <td colspan="2">
                        <xsl:value-of select="@name"/>
                    </td>
                    <td style="background-color: white;">&#160;</td>
                </tr>
                <xsl:if test="string-length(@path) &gt; 0">
                    <tr style="vertical-align: top;" data-tt-id="{$node-id}-path" xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:if test="string-length($parent-id) > 0">
                            <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                        </xsl:if>
                        <td style="background-color: white;" colspan="1">&#160;</td>
                        <td style="background-color: #FFEEEE;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'contextPath'"/>
                            </xsl:call-template>
                        </td>
                        <td colspan="2">
                            <xsl:value-of select="@path"/>
                        </td>
                        <td style="background-color: white;">&#160;</td>
                    </tr>
                </xsl:if>
                <xsl:if test="string-length(code/@code) &gt; 0 or string-length(code/@codeSystem) &gt; 0">
                    <tr style="vertical-align: top;" data-tt-id="{$node-id}-code" xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:if test="string-length($parent-id) > 0">
                            <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                        </xsl:if>
                        <td style="background-color: white;" colspan="1">&#160;</td>
                        <td style="background-color: #FFEEEE;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'code'"/>
                            </xsl:call-template>
                        </td>
                        <td colspan="2">
                            <xsl:if test="code/@code">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'code'"/>
                                </xsl:call-template>
                                <span class="pptext">
                                    <xsl:value-of select="code/@code"/>
                                </span>
                            </xsl:if>
                            <xsl:if test="code/@codeSystem">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'codeSystem'"/>
                                </xsl:call-template>
                                <span class="pptext">
                                    <xsl:value-of select="code/@codeSystem"/>
                                </span>
                            </xsl:if>
                        </td>
                        <td style="background-color: white;">&#160;</td>
                    </tr>
                </xsl:if>
                <xsl:if test="count(use) &gt; 0">
                    <tr style="vertical-align: top;" data-tt-id="{$node-id}-use" xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:if test="string-length($parent-id) > 0">
                            <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                        </xsl:if>
                        <td style="background-color: white;" colspan="1">&#160;</td>
                        <td style="background-color: #FFEEEE;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'use'"/>
                            </xsl:call-template>
                        </td>
                        <td colspan="2">
                            <xsl:value-of select="use/@path"/>
                            <xsl:if test="use/@as">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'as'"/>
                                </xsl:call-template>
                                <xsl:value-of select="use/@as"/>
                            </xsl:if>
                        </td>
                        <td style="background-color: white;">&#160;</td>
                    </tr>
                </xsl:if>
            </xsl:when>
            <xsl:when test="self::assert | self::report">
                <xsl:variable name="rowspans" select="count(@flag | @see) + 3"/>
                <xsl:variable name="node-id" select="concat(generate-id(.), '-', local-name(.))"/>
                <tr style="vertical-align: top;" data-tt-id="{$node-id}" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <td style="background-color: white;" colspan="1">&#160;</td>
                    <td class="stron" rowspan="{$rowspans}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Schematron'"/>
                        </xsl:call-template>
                        <xsl:text>&#160;</xsl:text>
                        <xsl:value-of select="name()"/>
                    </td>
                    <td style="background-color: #FFEEEE;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'roleLabel'"/>
                        </xsl:call-template>
                    </td>
                    <td colspan="2">
                        <xsl:choose>
                            <xsl:when test="@role = 'error'">
                                <xsl:call-template name="showIcon">
                                    <xsl:with-param name="which">red</xsl:with-param>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:when test="@role = 'warning'">
                                <xsl:call-template name="showIcon">
                                    <xsl:with-param name="which">orange</xsl:with-param>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="showIcon">
                                    <xsl:with-param name="which">yellow</xsl:with-param>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:text>&#160;</xsl:text>
                        <xsl:value-of select="@role"/>
                    </td>
                    <td style="background-color: white;">&#160;</td>
                </tr>
                <xsl:if test="@flag">
                    <tr data-tt-id="{$node-id}-flag" xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:if test="string-length($parent-id) > 0">
                            <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                        </xsl:if>
                        <td style="background-color: white;" colspan="1">&#160;</td>
                        <td style="background-color: #FFEEEE;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'flagLabel'"/>
                            </xsl:call-template>
                        </td>
                        <td colspan="2">
                            <xsl:value-of select="@flag"/>
                        </td>
                        <td style="background-color: white;">&#160;</td>
                    </tr>
                </xsl:if>
                <xsl:if test="@see">
                    <tr data-tt-id="{$node-id}-see" xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:if test="string-length($parent-id) > 0">
                            <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                        </xsl:if>
                        <td style="background-color: white;" colspan="1">&#160;</td>
                        <td style="background-color: #FFEEEE;">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'seeLabel'"/>
                            </xsl:call-template>
                        </td>
                        <td colspan="2">
                            <a href="{@see}" onclick="target='_blank';">
                                <xsl:value-of select="@see"/>
                            </a>
                        </td>
                        <td style="background-color: white;">&#160;</td>
                    </tr>
                </xsl:if>
                <tr style="vertical-align: top;" data-tt-id="{$node-id}-test" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <td style="background-color: white;" colspan="1">&#160;</td>
                    <td style="background-color: #FFEEEE;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Test'"/>
                        </xsl:call-template>
                    </td>
                    <td colspan="2">
                        <xsl:value-of select="@test"/>
                    </td>
                    <td style="background-color: white;">&#160;</td>
                </tr>
                <tr style="vertical-align: top;" data-tt-id="{$node-id}-message" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <td style="background-color: white;" colspan="1">&#160;</td>
                    <td style="background-color: #FFEEEE;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Message'"/>
                        </xsl:call-template>
                    </td>
                    <td colspan="2">
                        <xsl:for-each select="text() | (* except item)">
                            <xsl:choose>
                                <xsl:when test="string-length(.) &gt; 0">
                                    <!--div-->
                                    <span class="pptext">
                                        <xsl:value-of select="."/>
                                    </span>
                                    <!--/div-->
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="doPrettyPrintInternal">
                                        <xsl:with-param name="newlines" select="'false'"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:for-each>
                    </td>
                    <td style="background-color: white;">&#160;</td>
                </tr>
            </xsl:when>
            <xsl:when test="self::let">
                <xsl:variable name="rowspans" select="count(@*)"/>
                <tr style="vertical-align: top;" data-tt-id="{generate-id(.)}-let" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <td style="background-color: white;" colspan="1">&#160;</td>
                    <td class="defvar" rowspan="{$rowspans}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Variable'"/>
                        </xsl:call-template>
                        <xsl:text>&#160;</xsl:text>
                        <xsl:value-of select="name()"/>
                    </td>
                    <td style="background-color: #FFEEEE;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'nameLabel'"/>
                        </xsl:call-template>
                    </td>
                    <td colspan="2">
                        <xsl:value-of select="@name"/>
                    </td>
                    <td style="background-color: white;">&#160;</td>
                </tr>
                <tr style="vertical-align: top;" data-tt-id="{generate-id(.)}-label" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:if test="string-length($parent-id) > 0">
                        <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                    </xsl:if>
                    <td style="background-color: white;" colspan="1">&#160;</td>
                    <td style="background-color: #FFEEEE;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'valueLabel'"/>
                        </xsl:call-template>
                    </td>
                    <td colspan="2">
                        <xsl:value-of select="@value"/>
                    </td>
                    <td style="background-color: white;">&#160;</td>
                </tr>
                <xsl:for-each select="@* except (@name | @value)">
                    <tr style="vertical-align: top;" data-tt-id="{generate-id(.)}-other" xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:if test="string-length($parent-id) > 0">
                            <xsl:attribute name="data-tt-parent-id" select="$parent-id"/>
                        </xsl:if>
                        <td style="background-color: white;" colspan="1">&#160;</td>
                        <td style="background-color: #FFEEEE;">
                            <xsl:value-of select="name(.)"/>
                        </td>
                        <td colspan="2">
                            <xsl:value-of select="."/>
                        </td>
                        <td style="background-color: white;">&#160;</td>
                    </tr>
                </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="logMessage">
                    <xsl:with-param name="level" select="$logERROR"/>
                    <xsl:with-param name="msg">
                        <xsl:text>+++ Found unhandled element in definition "</xsl:text>
                        <xsl:value-of select="name()"/>
                        <xsl:text>" template id "</xsl:text>
                        <xsl:value-of select="ancestor::template/@id"/>
                        <xsl:text>"</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="completeCodeSystem | concept | include | exclude | exception" mode="valueset">
        <xsl:param name="language"/>
        <xsl:param name="doNesting" select="true()" as="xs:boolean"/>
        <xsl:param name="doOrdinal" as="xs:integer"/>
        <xsl:param name="doCodeSystemVersion" as="xs:integer"/>
        <xsl:param name="doDesignation" as="xs:integer"/>
        <xsl:param name="doDesc" as="xs:integer"/>
        <xsl:variable name="theCode" select="@code"/>
        <xsl:variable name="theCS" select="@codeSystem"/>
        <xsl:variable name="theName">
            <xsl:variable name="n" select="ancestor::valueSet/sourceCodeSystem[@id = $theCS]/@identifierName"/>
            <xsl:choose>
                <xsl:when test="$n">
                    <xsl:value-of select="$n"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="getIDDisplayName">
                        <xsl:with-param name="root" select="$theCS"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="theLevel">
            <xsl:choose>
                <xsl:when test="@level castable as xs:integer">
                    <xsl:value-of select="@level"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="0"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="theType" select="@type"/>
        <xsl:variable name="css-margin" select="concat('padding-left: ', number($theLevel) * 15, 'px;')"/>
        <xsl:variable name="nodeType" select="local-name()"/>
        <xsl:variable name="parentId" as="xs:string?">
            <xsl:variable name="theParentLevel" select="$theLevel - 1"/>
            <xsl:if test="$doNesting and $theParentLevel &gt;= 0">
                <xsl:choose>
                    <xsl:when test="self::concept">
                        <xsl:value-of select="generate-id(preceding-sibling::concept[@level = $theParentLevel][1])"/>
                    </xsl:when>
                    <xsl:when test="self::include">
                        <xsl:value-of select="generate-id(preceding-sibling::include[@level = $theParentLevel][1])"/>
                    </xsl:when>
                    <xsl:when test="self::exclude">
                        <xsl:value-of select="generate-id(preceding-sibling::exclude[@level = $theParentLevel][1])"/>
                    </xsl:when>
                    <xsl:when test="self::exception">
                        <xsl:value-of select="generate-id(preceding-sibling::exception[@level = $theParentLevel][1])"/>
                    </xsl:when>
                </xsl:choose>
            </xsl:if>
        </xsl:variable>
        <xsl:variable name="node-id" select="generate-id(.)"/>
        <tr data-tt-id="{$node-id}" xmlns="http://www.w3.org/1999/xhtml">
            <xsl:if test="$parentId">
                <xsl:attribute name="data-tt-parent-id" select="$parentId"/>
            </xsl:if>
            <!-- Level / Type -->
            <td style="vertical-align: top;">
                <xsl:choose>
                    <xsl:when test="self::concept | self::exception">
                        <!-- level/type -->
                        <xsl:value-of select="$theLevel"/>
                        <xsl:text>&#8209;</xsl:text>
                        <xsl:choose>
                            <xsl:when test="$theType">
                                <xsl:value-of select="$theType"/>
                            </xsl:when>
                            <xsl:otherwise>(?)</xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text>&#160;</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <!-- Code / intensional instruction -->
            <xsl:choose>
                <xsl:when test="self::concept | self::exception">
                    <td style="vertical-align: top;" class="columnName">
                        <div class="concepttype{$theType} {$nodeType}" style="{$css-margin}">
                            <xsl:value-of select="$theCode"/>
                        </div>
                    </td>
                </xsl:when>
                <xsl:when test="self::completeCodeSystem | self::include">
                    <td style="vertical-align: top;" class="columnName">
                        <div style="{$css-margin}">
                            <xsl:call-template name="showIcon">
                                <xsl:with-param name="which">circleplus</xsl:with-param>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'IntensionalInclude'"/>
                            </xsl:call-template>
                        </div>
                    </td>
                </xsl:when>
                <xsl:when test="self::exclude">
                    <td style="vertical-align: top;" class="columnName">
                        <div style="{$css-margin}">
                            <xsl:call-template name="showIcon">
                                <xsl:with-param name="which">circleminus</xsl:with-param>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'IntensionalExclude'"/>
                            </xsl:call-template>
                        </div>
                    </td>
                </xsl:when>
            </xsl:choose>
            <!-- DisplayName -->
            <td style="vertical-align: top;" class="columnName">
                <xsl:choose>
                    <xsl:when test="self::concept | self::exception">
                        <div class="concepttype{$theType} {$nodeType}" style="{$css-margin}">
                            <xsl:value-of select="@displayName"/>
                        </div>
                    </xsl:when>
                    <xsl:when test="self::include[@op] | self::exclude[@op]">
                        <i>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="concat('Intensional-', @op)"/>
                                <xsl:with-param name="p1" select="@code"/>
                                <xsl:with-param name="p2" select="string(@displayName)"/>
                            </xsl:call-template>
                        </i>
                    </xsl:when>
                    <xsl:when test="self::include[@ref] | self::exclude[@ref]">
                        <i>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'valueSet'"/>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <xsl:value-of select="self::include/@ref"/>
                            <xsl:value-of select="self::exclude/@ref"/>
                            <xsl:if test="self::include[@flexibility] | self::exclude[@flexibility]">
                                <xsl:text> </xsl:text>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Flexibility'"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="self::include/@flexibility"/>
                                <xsl:value-of select="self::exclude/@flexibility"/>
                            </xsl:if>
                        </i>
                    </xsl:when>
                    <xsl:when test="(self::completeCodeSystem | self::include | self::exclude)[@codeSystem][filter]">
                        <i>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'CompleteCodeSystemFiltered'"/>
                            </xsl:call-template>
                        </i>
                    </xsl:when>
                    <xsl:when test="(self::completeCodeSystem | self::include | self::exclude)[@codeSystem]">
                        <i>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'CompleteCodeSystemAll'"/>
                            </xsl:call-template>
                        </i>
                    </xsl:when>
                </xsl:choose>
                <!-- <filter property="33" op="equal" value="456"/> -->
                <xsl:if test="filter">
                    <ul>
                        <xsl:for-each select="filter">
                            <li>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'Property'"/>
                                </xsl:call-template>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="@property"/>
                                <xsl:text> </xsl:text>
                                <xsl:value-of select="@op"/>
                                <xsl:text> "</xsl:text>
                                <xsl:value-of select="@value"/>
                                <xsl:text>"</xsl:text>
                            </li>
                        </xsl:for-each>
                    </ul>
                </xsl:if>
            </td>
            <xsl:if test="$doOrdinal = 1">
                <td style="vertical-align: top; text-align: left;">
                    <div class="concepttype{$theType} {$nodeType}" style="{$css-margin}">
                        <xsl:value-of select="@ordinal"/>
                    </div>
                </td>
            </xsl:if>
            <!-- CodeSystem -->
            <td style="vertical-align: top;">
                <xsl:choose>
                    <xsl:when test="string-length($theName) &gt; 0">
                        <xsl:value-of select="$theName"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$theCS"/>
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <xsl:if test="$doCodeSystemVersion = 1">
                <td style="vertical-align: top;">
                    <xsl:value-of select="@codeSystemVersion"/>
                </td>
            </xsl:if>
            <!-- Designations -->
            <xsl:if test="$doDesignation = 1">
                <td style="vertical-align: top;" class="columnName">
                    <xsl:for-each select="designation[@language = $language or not(@language)]">
                        <div class="concepttype{$theType} {$nodeType}" style="{$css-margin}">
                            <xsl:choose>
                                <!-- check for flags for ART-DECOR well known languages -->
                                <xsl:when test="@language = ('de-DE', 'nl-NL', 'en-US')">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which" select="@language"/>
                                        <xsl:with-param name="tooltip" select="@language"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                </xsl:when>
                                <xsl:when test="@language">
                                    <i>
                                        <xsl:text>(</xsl:text>
                                        <xsl:value-of select="@language"/>
                                        <xsl:text>) </xsl:text>
                                    </i>
                                </xsl:when>
                            </xsl:choose>
                            <xsl:if test="@type">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="concat('designation_', @type)"/>
                                </xsl:call-template>
                                <xsl:text>: </xsl:text>
                            </xsl:if>
                            <xsl:value-of select="@displayName"/>
                        </div>
                    </xsl:for-each>
                </td>
            </xsl:if>
            <!-- Desc -->
            <xsl:if test="$doDesc = 1">
                <td style="vertical-align: top;">
                    <xsl:choose>
                        <xsl:when test="desc">
                            <xsl:call-template name="doDescription">
                                <xsl:with-param name="ns" select="desc[@language = $language or not(@language)][1]"/>
                            </xsl:call-template>
                        </xsl:when>
                    </xsl:choose>
                </td>
            </xsl:if>
        </tr>
    
        <!-- First draft and test of display of concept associations in value sets KH 20180311 -->
        <xsl:variable name="conceptAssociation">
            <conceptAssociation id="2.16.840.1.113883.2.6.60.4.24.2" displayName="Form Codes BMP-&gt;EDQM" effectiveDate="2018-03-07T00:00:00" statusCode="draft">
                <desc language="en-US">Mapping between Form Codes BMP and Form Codes EDQM</desc>
                <source ref="2.16.840.1.113883.2.6.60.4.11.22" flexibility="2017-04-12T16:10:14" displayName="Form Codes BMP"/>
                <target ref="2.16.840.1.113883.2.6.60.4.11.27" flexibility="2014-03-26T00:00:00" displayName="Form Codes EDQM"/>
                <group>
                    <source codeSystem="2.16.840.1.113883.2.6.60.4.5.4"/>
                    <target codeSystem="0.4.0.127.0.16.1.1.2.1"/>
                    <element code="AMP">
                        <target code="15002000" displayName="Ampulle">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="APA">
                        <target code="30001000" displayName="Ampulle">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ASO">
                        <target code="50019000" displayName="Augen-/Ohrensalbe">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ATO">
                        <target code="50018000" displayName="Augen-/Ohrentropfen, Lösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ATO">
                        <target code="50018500" displayName="Augen-/Ohrentropfen, Suspension">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ATR">
                        <target code="10604500" displayName="Augentropfen, Emulsion">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ATR">
                        <target code="10604000" displayName="Augentropfen, Lösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ATR">
                        <target code="10605000" displayName="Augentropfensuspension">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="AUB">
                        <target code="10610000" displayName="Augenbad">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="AUG">
                        <target code="10602000" displayName="Augengel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="AUS">
                        <target code="10603000" displayName="Augensalbe">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="BAD">
                        <target code="10501000" displayName="Badezusatz">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="BAL">
                        <target code="10504000" displayName="Salbe">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="BAN">
                        <target code="10525000" displayName="imprägnierter Verband">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="BEU">
                        <target code="30004000" displayName="Beutel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="BEU">
                        <target code="15005000" displayName="Beutel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="BEU">
                        <target code="15045000" displayName="Beutel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="BEU">
                        <target code="30054000" displayName="Beutel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="BIN">
                        <target code="10525000" displayName="imprägnierter Verband">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="BTR">
                        <target code="10222000" displayName="Brausetablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="CRE">
                        <target code="10502000" displayName="Creme">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DFL">
                        <target code="15060000" displayName="Durchstechflasche">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DFL">
                        <target code="30069000" displayName="Durchstechflasche">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DKA">
                        <target code="30007000" displayName="Blisterpackung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DKA">
                        <target code="15007000" displayName="k.A.">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DKA">
                        <target code="10220000" displayName="überzogene Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DOS">
                        <target code="30060000" displayName="Spraydose">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DRA">
                        <target code="10220000" displayName="überzogene Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DRM">
                        <target code="10225000" displayName="magensaftresistente Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DSC">
                        <target code="10507000" displayName="Schaum zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DSC">
                        <target code="30035000" displayName="Dosierpumpe">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DSC">
                        <target code="30036000" displayName="Dosierventil">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DSS">
                        <target code="30060000" displayName="Spraydose">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="EDP">
                        <target code="30046000" displayName="Pipette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="EIN">
                        <target code="10513000" displayName="Lösung zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="EIN">
                        <target code="10512000" displayName="Flüssigkeit zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="EIN">
                        <target code="10515000" displayName="Suspension zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ELI">
                        <target code="10512000" displayName="Flüssigkeit zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ELI">
                        <target code="10104000" displayName="Flüssigkeit zum Einnehmen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="EMU">
                        <target code="10516000" displayName="Emulsion zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ESS">
                        <target code="10512000" displayName="Flüssigkeit zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ESS">
                        <target code="10104000" displayName="Flüssigkeit zum Einnehmen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ESU">
                        <target code="11013000" displayName="Zäpfchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FBE">
                        <target code="50029700">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FBW">
                        <target code="10512000" displayName="Flüssigkeit zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FDA">
                        <target code="10220000" displayName="überzogene Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FER">
                        <target code="30051000" displayName="Fertigspritze">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FET">
                        <target code="10504000" displayName="Salbe">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FLA">
                        <target code="30008000" displayName="Flasche">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FLU">
                        <target code="10512000" displayName="Flüssigkeit zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FLU">
                        <target code="10104000" displayName="Flüssigkeit zum Einnehmen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FTA">
                        <target code="10221000" displayName="Filmtablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FSE">
                        <target code="10507000" displayName="Schaum zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="FMR">
                        <target code="10225000" displayName="magensaftresistente Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="GEL">
                        <target code="10503000" displayName="Gel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="GLO">
                        <target code="10231000" displayName="Streukügelchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="GLO">
                        <target code="15040000" displayName="Streukügelchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="GRA">
                        <target code="10204000" displayName="Granulat">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="GSE">
                        <target code="10113000" displayName="Granulat zur Herstellung einer Suspension zum Einnehmen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="GUL">
                        <target code="10301000" displayName="Gurgellösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="HKP">
                        <target code="10210000" displayName="Hartkapsel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="HVW">
                        <target code="10217000" displayName="Hartkapsel mit veränderter Wirkstofffreisetzung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IFA">
                        <target code="11210500" displayName="Infusionslösung im Applikationssystem">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IFB">
                        <target code="11210500" displayName="Infusionslösung im Applikationssystem">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IFF">
                        <target code="11210500" displayName="Infusionslösung im Applikationssystem">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IFK">
                        <target code="11213000" displayName="Konzentrat zur Herstellung einer Infusionslösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IFL">
                        <target code="13053000" displayName="Injektionslösung in einem Applikationssystem">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IFS">
                        <target code="50060300" displayName="Injektionslösung in einer Fertigspritze">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IHA">
                        <target code="20020000" displayName="zur Inhalation">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IHP">
                        <target code="11109000" displayName="Pulver zur Inhalation">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IIL">
                        <target code="50060000" displayName="Injektions-/Infusionslösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IKA">
                        <target code="11113000" displayName="Kapsel zur Herstellung eines Dampfs zur Inhalation">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ILO">
                        <target code="11201000" displayName="Injektionslösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IMP">
                        <target code="11301000" displayName="Implantat">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IMP">
                        <target code="15025000" displayName="Implantat">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IMP">
                        <target code="20015500" displayName="zur Implantation">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="INF">
                        <target code="11210000" displayName="Infusionslösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="INH">
                        <target code="20020000" displayName="zur Inhalation">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="INL">
                        <target code="50081000" displayName="Lösung zur Inhalation">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="INS">
                        <target code="10202000" displayName="Teeaufgusspulver">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ISU">
                        <target code="11202000" displayName="Injektionssuspension">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="IUP">
                        <target code="20044000" displayName="intrauterine Anwendung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KANN">
                        <target code="30012000" displayName="Kanüle">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KAP">
                        <target code="12100" displayName="Capsule">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KDA">
                        <target code="10214000" displayName="Weichkapsel zum Zerbeißen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KDA">
                        <target code="10230000" displayName="Lutschpastille">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KGU">
                        <target code="10229000" displayName="wirkstoffhaltiges Kaugummi">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KKS">
                        <target code="11013000" displayName="Zäpfchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KLT">
                        <target code="11011000" displayName="Tablette zur Herstellung einer Rektallösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KMP">
                        <target code="10212000" displayName="magensaftresistente Hartkapsel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KMR">
                        <target code="10212000" displayName="magensaftresistente Hartkapsel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KOM">
                        <target code="10525000" displayName="imprägnierter Verband">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KSS">
                        <target code="11013000" displayName="Zäpfchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KSU">
                        <target code="11013000" displayName="Zäpfchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="KTA">
                        <target code="10228000" displayName="Kautablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="LIQ">
                        <target code="10512000" displayName="Flüssigkeit zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="LOE">
                        <target code="10512000" displayName="Flüssigkeit zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="LOT">
                        <target code="10504000" displayName="Salbe">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="LSE">
                        <target code="10105000" displayName="Lösung zum Einnehmen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="LTA">
                        <target code="10220000" displayName="überzogene Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="LUT">
                        <target code="10321000" displayName="Lutschtablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="MTA">
                        <target code="10220000" displayName="überzogene Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="MUW">
                        <target code="10310000" displayName="Mundwasser">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="NAG">
                        <target code="10802000" displayName="Nasengel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="NAS">
                        <target code="10810000" displayName="Nasenspray, Emulsion">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="NDS">
                        <target code="50037250" displayName="Nasenspray, Lösung im Einzeldosisbehältnis">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="NSA">
                        <target code="10803000" displayName="Nasensalbe">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="NTR">
                        <target code="10806000" displayName="Nasentropfen, Emulsion">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="OCU">
                        <target code="11303300" displayName="Matrix zur Implantation">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="OHT">
                        <target code="10706000" displayName="Ohrentropfen, Emulsion">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="OHT">
                        <target code="10704000" displayName="Ohrentropfen, Lösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="OHT">
                        <target code="10705000" displayName="Ohrentropfen, Suspension">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="OVU">
                        <target code="10913000" displayName="Schaumovula">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PAS">
                        <target code="10323000" displayName="Pastille">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PFL">
                        <target code="15042000" displayName="Pflaster">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PFL">
                        <target code="15036000" displayName="Pflaster">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PFL">
                        <target code="10506000" displayName="wirkstoffhaltiges Pflaster">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PFT">
                        <target code="10519000" displayName="transdermales Pflaster">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PIF">
                        <target code="11212000" displayName="Pulver zur Herstellung einer Infusionslösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PPL">
                        <target code="30035000" displayName="Dosierpumpe">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PSE">
                        <target code="10111000" displayName="Pulver zur Herstellung einer Suspension zum Einnehmen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PST">
                        <target code="10505000" displayName="Paste zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PUD">
                        <target code="10517000" displayName="Pulver zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PUL">
                        <target code="10517000" displayName="Pulver zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="RET">
                        <target code="10226000" displayName="Retardtablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="RGR">
                        <target code="10207000" displayName="Retardgranulat">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="RKA">
                        <target code="11014000" displayName="Rektalkapsel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="RUT">
                        <target code="10226000" displayName="Retardtablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SAL">
                        <target code="10504000" displayName="Salbe">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SCH">
                        <target code="10507000" displayName="Schaum zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SEI">
                        <target code="10507000" displayName="Schaum zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SHA">
                        <target code="10508000" displayName="Shampoo">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SIR">
                        <target code="10117000" displayName="Sirup">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SMF">
                        <target code="10236100" displayName="Schmelzfilm">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SMT">
                        <target code="10223000" displayName="Schmelztablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SMU">
                        <target code="11013000" displayName="Zäpfchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SPA">
                        <target code="30001000" displayName="Ampulle">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SPF">
                        <target code="30044000" displayName="Sprühkopf">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SPF">
                        <target code="30061000" displayName="Sprühpumpe">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SPF">
                        <target code="30062000" displayName="Sprühventil">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SPL">
                        <target code="12113000" displayName="Spüllösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SPR">
                        <target code="30060000" displayName="Spraydose">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SRI">
                        <target code="15052000" displayName="Spritze">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SSU">
                        <target code="11013000" displayName="Zäpfchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="STA">
                        <target code="30001000" displayName="Ampulle">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="STB">
                        <target code="15048000" displayName="Stäbchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SUP">
                        <target code="11013000" displayName="Zäpfchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SUT">
                        <target code="10318000" displayName="Sublingualtablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SUV">
                        <target code="11102000" displayName="Suspension für einen Vernebler">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SWA">
                        <target code="12119000" displayName="wirkstoffhaltiges Schwämmchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SWA">
                        <target code="15046000" displayName="Schwämmchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TAB">
                        <target code="10219000" displayName="Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TMR">
                        <target code="15054000" displayName="Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TRA">
                        <target code="30001000" displayName="Ampulle">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TEE">
                        <target code="10122000" displayName="Arzneitee">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TEI">
                        <target code="10101000" displayName="Tropfen zum Einnehmen, Lösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TEI">
                        <target code="10102000" displayName="Tropfen zum Einnehmen, Suspension">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TIN">
                        <target code="10512000" displayName="Flüssigkeit zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TKA">
                        <target code="30057000" displayName="Einzeldosisbehältnis">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TMR">
                        <target code="10225000" displayName="magensaftresistente Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TON">
                        <target code="10512000" displayName="Flüssigkeit zur Anwendung auf der Haut">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TPN">
                        <target code="10914000" displayName="Wirkstoffhaltiger Vaginaltampon">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TPN">
                        <target code="15033000" displayName="Tampon">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TRT">
                        <target code="30001000" displayName="Ampulle">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TRO">
                        <target code="10101000" displayName="Tropfen zum Einnehmen, Lösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TSA">
                        <target code="10118000" displayName="Pulver zur Herstellung eines Sirups">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TUB">
                        <target code="15058000" displayName="Tube">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TUE">
                        <target code="10525000" displayName="imprägnierter Verband">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="TUP">
                        <target code="30017000" displayName="Verschluss mit Tupfer">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="UTA">
                        <target code="10220000" displayName="überzogene Tablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VAL">
                        <target code="10905000" displayName="Vaginallösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VAR">
                        <target code="10915000" displayName="vaginales Wirkstofffreisetzungssystem">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VCR">
                        <target code="10901000" displayName="Vaginalcreme">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VER">
                        <target code="15021000" displayName="Verband">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VER">
                        <target code="10525000" displayName="imprägnierter Verband">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VGE">
                        <target code="10902000" displayName="Vaginalgel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VKA">
                        <target code="10910000" displayName="Hartkapsel zur vaginalen Anwendung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VKA">
                        <target code="10911000" displayName="Weichkapsel zur vaginalen Anwendung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VLI">
                        <target code="10525000" displayName="imprägnierter Verband">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VOV">
                        <target code="10913000" displayName="Schaumovula">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VSU">
                        <target code="10909000" displayName="Vaginalzäpfchen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="VTA">
                        <target code="10912000" displayName="Vaginaltablette">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="WAT">
                        <target code="10525000" displayName="imprägnierter Verband">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="WGA">
                        <target code="10525000" displayName="imprägnierter Verband">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="WGA">
                        <target code="20010000" displayName="zum Auftragen auf die Wunde">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="WKA">
                        <target code="10211000" displayName="Weichkapsel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="XNC">
                        <target code="10502000" displayName="Creme">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="XTC">
                        <target code="10502000" displayName="Creme">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ZAM">
                        <target code="30001000" displayName="Ampulle">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ZCR">
                        <target code="10409000" displayName="Zahnpaste">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ZGE">
                        <target code="10409000" displayName="Zahnpaste">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ZKA">
                        <target code="10214000" displayName="Weichkapsel zum Zerbeißen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="ZPA">
                        <target code="10409000" displayName="Zahnpaste">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="AUC">
                        <target code="10601000" displayName="Augencreme">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="DIS">
                        <target code="11208500" displayName="Depot-Injektionssuspension">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="HPI">
                        <target code="11110000" displayName="Hartkapsel mit Pulver zur Inhalation">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PEN">
                        <target code="50060200" displayName="Injektionslösung im Fertigpen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="LUP">
                        <target code="10230000" displayName="Lutschpastille">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="WKM">
                        <target code="10213000" displayName="magensaftresistente Weichkapsel">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="GMR">
                        <target code="10206000" displayName="magensaftresistentes Granulat">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="MRG">
                        <target code="10206000" displayName="magensaftresistentes Granulat">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PIK">
                        <target code="50043000" displayName="Pulver für ein Konzentrat zur Herstellung einer Infusionslösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PII">
                        <target code="50053500" displayName="Pulver zur Herstellung einer Injektions-/Infusionslösung">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="PLE">
                        <target code="10110000" displayName="Pulver zur Herstellung einer Lösung zum Einnehmen">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="RSC">
                        <target code="11004000" displayName="Rektalschaum">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                    <element code="SAM">
                        <target code="10314005" displayName="Salbe zur Anwendung in der Mundhöhle">
                            <equivalence code="equivalent"/>
                        </target>
                    </element>
                </group>
            </conceptAssociation>
        </xsl:variable>
        <xsl:if test="false() and $conceptAssociation//element[@code=$theCode]">
            <xsl:variable name="mapc" select="$conceptAssociation//element[@code=$theCode]/target"/>
            <xsl:for-each select="$mapc">
                <xsl:variable name="mapcs" select="./ancestor::group/target/@codeSystem"/>
                <xsl:variable name="mapcsname">
                    <xsl:call-template name="getIDDisplayName">
                        <xsl:with-param name="root" select="$mapcs"/>
                    </xsl:call-template>
                </xsl:variable>
                <xsl:variable name="node-id2" select="generate-id(.)"/>
                <tr xmlns="http://www.w3.org/1999/xhtml" data-tt-id="{$node-id2}">
                    <xsl:if test="$parentId">
                        <xsl:attribute name="data-tt-parent-id" select="$parentId"/>
                    </xsl:if>
                    <td style="vertical-align: top;"/>
                    <td style="background-color: #eee; align: right">
                        <xsl:text>&#x21a6; </xsl:text>
                        <xsl:value-of select="./@code"/>
                    </td>
                    <td style="background-color: #eee; align: right">
                        <xsl:value-of select="./@displayName"/>
                    </td>
                    <!-- designations -->
                    <xsl:if test="$doOrdinal = 1">
                        <td style="background-color: #eee; align: right"> </td>
                    </xsl:if>
                    <!-- codeSystem -->
                    <td style="background-color: #eee; align: right">
                        <xsl:choose>
                            <xsl:when test="string-length($mapcsname)>0">
                                <xsl:value-of select="$mapcsname"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$mapcs"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                    <!-- designations -->
                    <xsl:if test="$doDesignation = 1">
                        <td style="background-color: #eee; align: right"> </td>
                    </xsl:if>
                    <!-- descriptions -->
                    <xsl:if test="$doDesc = 1">
                        <td style="background-color: #eee; align: right"> </td>
                    </xsl:if>
                </tr>
            </xsl:for-each>
        </xsl:if>
    </xsl:template>
    <xsl:template match="codedConcept" mode="codesystem">
        <xsl:param name="language"/>
        <xsl:param name="doStatus" as="xs:integer"/>
        <xsl:param name="doNesting" select="true()" as="xs:boolean"/>
        <xsl:param name="doEffective" as="xs:integer"/>
        <xsl:param name="doExpiration" as="xs:integer"/>
        <xsl:param name="doOrdinal" as="xs:integer"/>
        <xsl:param name="doDesignation" as="xs:integer"/>
        <xsl:param name="doDesc" as="xs:integer"/>
        <xsl:variable name="theCode" select="@code"/>
        <xsl:variable name="theLevel">
            <xsl:choose>
                <xsl:when test="@level castable as xs:integer">
                    <xsl:value-of select="@level"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="0"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        
        <xsl:variable name="theType" select="@type"/>
        <xsl:variable name="css-margin" select="concat('padding-left: ', number($theLevel) * 15, 'px;')"/>
        <xsl:variable name="nodeType" select="local-name()"/>
        <xsl:variable name="parentId" as="xs:string?">
            <xsl:variable name="theParentLevel" select="$theLevel - 1"/>
            <xsl:if test="$doNesting and $theParentLevel &gt;= 0">
                <xsl:choose>
                    <xsl:when test="self::codedConcept">
                        <xsl:value-of select="generate-id(preceding-sibling::codedConcept[@level = $theParentLevel][1])"/>
                    </xsl:when>
                </xsl:choose>
            </xsl:if>
        </xsl:variable>
        <xsl:variable name="node-id" select="generate-id(.)"/>
        <tr data-tt-id="{$node-id}" xmlns="http://www.w3.org/1999/xhtml">
            <xsl:if test="$parentId">
                <xsl:attribute name="data-tt-parent-id" select="$parentId"/>
            </xsl:if>
            <!-- Level / Type -->
            <td style="vertical-align: top;">
                <!-- level/type -->
                <xsl:value-of select="$theLevel"/>
                <xsl:text>&#8209;</xsl:text>
                <xsl:choose>
                    <xsl:when test="$theType">
                        <xsl:value-of select="$theType"/>
                    </xsl:when>
                    <xsl:otherwise>(?)</xsl:otherwise>
                </xsl:choose>
            </td>
            <!-- Status -->
            <xsl:if test="$doStatus = 1">
                <xsl:variable name="theStatusLabel">
                    <xsl:variable name="t">
                        <xsl:call-template name="getXFormsLabel">
                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                        </xsl:call-template>
                    </xsl:variable>
                    <xsl:choose>
                        <xsl:when test="empty($t) or $t = @statusCode">
                            <xsl:call-template name="getXFormsLabel">
                                <xsl:with-param name="simpleTypeKey" select="'ReleaseStatusCodeLifeCycle'"/>
                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:copy-of select="$t"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                <td style="text-align: left; vertical-align: top;">
                    <xsl:if test="@statusCode">
                        <xsl:call-template name="showStatusDot">
                            <xsl:with-param name="status" select="@statusCode"/>
                            <xsl:with-param name="title" select="$theStatusLabel"/>
                        </xsl:call-template>
                        <xsl:text> </xsl:text>
                        <xsl:choose>
                            <xsl:when test="empty($theStatusLabel)">
                                <xsl:value-of select="@statusCode"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:copy-of select="$theStatusLabel"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:if>
                </td>
            </xsl:if>
            <!-- Code -->
            <td style="vertical-align: top;" class="columnName">
                <div class="concepttype{$theType} {$nodeType}" style="{$css-margin}">
                    <xsl:value-of select="$theCode"/>
                </div>
            </td>
            <xsl:if test="$doOrdinal = 1">
                <td style="text-align: left; vertical-align: top;">
                    <div class="concepttype{$theType} {$nodeType}" style="{$css-margin}">
                        <xsl:value-of select="@ordinal"/>
                    </div>
                </td>
            </xsl:if>
            <xsl:if test="$doEffective = 1">
                <td style="text-align: left; vertical-align: top;">
                    <div>
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="@effectiveDate"/>
                        </xsl:call-template>
                    </div>
                </td>
            </xsl:if>
            <xsl:if test="$doExpiration = 1">
                <td style="text-align: left; vertical-align: top;">
                    <div>
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="@expirationDate"/>
                        </xsl:call-template>
                    </div>
                </td>
            </xsl:if>
            <!-- Designations -->
            <xsl:if test="$doDesignation = 1">
                <td style="vertical-align: top;" class="columnName">
                    <xsl:for-each select="designation"><!--[@language = $language or not(@language)]-->
                        <div>
                            <xsl:choose>
                                <!-- check for flags for ART-DECOR well known languages -->
                                <xsl:when test="@language = ('de-DE', 'nl-NL', 'en-US')">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which" select="@language"/>
                                        <xsl:with-param name="tooltip" select="@language"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                </xsl:when>
                                <xsl:when test="@language">
                                    <i>
                                        <xsl:text>(</xsl:text>
                                        <xsl:value-of select="@language"/>
                                        <xsl:text>) </xsl:text>
                                    </i>
                                </xsl:when>
                            </xsl:choose>
                            <xsl:if test="@type">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="concat('designation_', @type)"/>
                                </xsl:call-template>
                                <xsl:text>: </xsl:text>
                            </xsl:if>
                            <xsl:value-of select="@displayName"/>
                        </div>
                    </xsl:for-each>
                </td>
            </xsl:if>
            <!-- Desc -->
            <xsl:if test="$doDesc = 1">
                <td style="vertical-align: top;">
                    <xsl:for-each select="desc"><!-- [@language = $language or not(@language)][1] -->
                        <div>
                            <xsl:choose>
                                <!-- check for flags for ART-DECOR well known languages -->
                                <xsl:when test="@language = ('de-DE', 'nl-NL', 'en-US')">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which" select="@language"/>
                                        <xsl:with-param name="tooltip" select="@language"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                </xsl:when>
                                <xsl:when test="@language">
                                    <i>
                                        <xsl:text>(</xsl:text>
                                        <xsl:value-of select="@language"/>
                                        <xsl:text>) </xsl:text>
                                    </i>
                                </xsl:when>
                            </xsl:choose>
                            <xsl:call-template name="doDescription">
                                <xsl:with-param name="ns" select="."/>
                            </xsl:call-template>
                        </div>
                    </xsl:for-each>
                </td>
            </xsl:if>
        </tr>
    </xsl:template>
    <xsl:template match="element" mode="conceptmap">
        <xsl:param name="language"/>
        <xsl:variable name="theCode" select="@code"/>
        <xsl:variable name="rowspan" select="count(target) + count(target[comment])"/>
        <xsl:variable name="nodeType" select="local-name()"/>
        <xsl:variable name="node-id" select="generate-id(.)"/>
        <tr data-tt-id="{$node-id}" style="{if (count(preceding-sibling::element) mod 2 = 0) then () else 'background-color: #eee;'}" xmlns="http://www.w3.org/1999/xhtml">
            <!-- code -->
            <td style="vertical-align: top;" rowspan="{$rowspan}">
                <xsl:value-of select="$theCode"/>
            </td>
            <!-- display -->
            <td style="vertical-align: top;" rowspan="{$rowspan}">
                <xsl:value-of select="@displayName"/>
            </td>
            <!-- targets -->
            <xsl:for-each select="target[1]">
                <td style="vertical-align: top;" rowspan="{if (comment) then 2 else 1}">
                    <xsl:call-template name="getXFormsLabel">
                        <xsl:with-param name="simpleTypeKey" select="'ConceptMapRelationshipType'"/>
                        <xsl:with-param name="simpleTypeValue" select="@relationship"/>
                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                    </xsl:call-template>
                </td>
                <td style="vertical-align: top;">
                    <xsl:value-of select="@code"/>
                </td>
                <td style="vertical-align: top;">
                    <xsl:value-of select="@displayName"/>
                </td>
            </xsl:for-each>
        </tr>
        <xsl:for-each select="target[1][comment]">
            <tr>
                <td colspan="2">
                    <xsl:call-template name="doDescription">
                        <xsl:with-param name="ns" select="comment"/>
                    </xsl:call-template>
                </td>
            </tr>
        </xsl:for-each>
        <xsl:for-each select="target[position() gt 1]">
            <tr>
                <td style="vertical-align: top;" rowspan="{if (comment) then 2 else 1}">
                    <xsl:value-of select="@relationship"/>
                </td>
                <td style="vertical-align: top;">
                    <xsl:value-of select="@code"/>
                </td>
                <td style="vertical-align: top;">
                    <xsl:value-of select="@displayName"/>
                </td>
            </tr>
            <xsl:for-each select=".[comment]">
                <tr>
                    <td colspan="2">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="comment"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:for-each>
        </xsl:for-each>
    </xsl:template>
    <xsl:template match="concept" mode="deinherit">
        <xsl:param name="dsref" select="inherit/@ref"/>
        <xsl:param name="dsed" select="inherit/@effectiveDate"/>
        <xsl:variable name="dsrefconcept" select="local:getConcept($dsref, $dsed)"/>
        <!-- 
            get the node of this referenced concept
            inherit/@ref and @effectiveDate determines concept node
            create a new concept node
            - with all attributes of the original node
            - with @ref and @effectiveDate of the inherit element as attributed inheritedId and inheritedEffectiveDate
            - copy all elements of the referenced (inherited) node 
            - copy comments and sub concepts from the original node definition (these are the only allowed node in a referencing concept)
        -->
        <!-- original node @id, @effectiveDate, @minimumMultiplicity, @maximumMultiplicity, @isMandatory, @conformance, comments and sub concepts -->
        <xsl:variable name="origid">
            <xsl:value-of select="@id"/>
        </xsl:variable>
        <xsl:variable name="origed">
            <xsl:value-of select="@effectiveDate"/>
        </xsl:variable>
        <xsl:variable name="origsc">
            <xsl:value-of select="@statusCode"/>
        </xsl:variable>
        <xsl:variable name="origmi">
            <xsl:value-of select="@minimumMultiplicity"/>
        </xsl:variable>
        <xsl:variable name="origmx">
            <xsl:value-of select="@maximumMultiplicity"/>
        </xsl:variable>
        <xsl:variable name="origma">
            <xsl:value-of select="@isMandatory"/>
        </xsl:variable>
        <xsl:variable name="origcf">
            <xsl:value-of select="@conformance"/>
        </xsl:variable>
        <xsl:variable name="origcomments">
            <xsl:copy-of select="comment"/>
        </xsl:variable>
        <xsl:variable name="origconcepts">
            <xsl:copy-of select="concept"/>
        </xsl:variable>
        <concept xmlns="">
            <!-- copy ref and effectiveDate of the inherit data element as attributes but use the name inheritedId and inheritedEffectiveDate -->
            <xsl:attribute name="id" select="$origid"/>
            <xsl:attribute name="effectiveDate" select="$origed"/>
            <xsl:if test="string-length($origsc) &gt; 0">
                <!-- original statuscode, override inherited one -->
                <xsl:attribute name="statusCode" select="$origsc"/>
            </xsl:if>
            <xsl:attribute name="minimumMultiplicity" select="$origmi"/>
            <xsl:attribute name="maximumMultiplicity" select="$origmx"/>
            <xsl:attribute name="isMandatory" select="$origma"/>
            <xsl:attribute name="conformance" select="$origcf"/>
            <xsl:attribute name="inheritedId" select="$dsref"/>
            <xsl:attribute name="inheritedEffectiveDate" select="$dsed"/>
            <xsl:choose>
                <xsl:when test="exists($dsrefconcept)">
                    <!-- it is an error if more than one concept has the same id and effective time -->
                    <xsl:if test="count($dsrefconcept) &gt; 1">
                        <xsl:call-template name="logMessage">
                            <xsl:with-param name="level" select="$logFATAL"/>
                            <xsl:with-param name="terminate" select="true()"/>
                            <xsl:with-param name="msg">
                                <xsl:text>!!! more than 1 concept with same id and effectiveDate found: </xsl:text>
                                <xsl:value-of select="$dsref"/>
                                <xsl:text>&#160;</xsl:text>
                                <xsl:value-of select="$dsed"/>
                            </xsl:with-param>
                        </xsl:call-template>
                    </xsl:if>
                    <xsl:for-each select="$dsrefconcept[1]">
                        <xsl:copy-of select="@* except (@id | @effectiveDate | @statusCode)"/>
                        <xsl:if test="string-length($origsc) = 0">
                            <xsl:copy-of select="@statusCode"/>
                        </xsl:if>
                        <xsl:copy-of select="name | desc | source | rationale | inherit"/>
                        <xsl:copy-of select="comment"/>
                        <xsl:copy-of select="$origcomments"/>
                        <xsl:copy-of select="operationalization | valueDomain"/>
                        <xsl:copy-of select="$origconcepts"/>
                    </xsl:for-each>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:copy-of select="./node() except inherit"/>
                </xsl:otherwise>
            </xsl:choose>
        </concept>
    </xsl:template>
    <xsl:template match="concept" mode="dataset">
        <xsl:param name="level"/>
        <xsl:param name="nestingWithTables" select="true()"/>
        <!-- when called from an object in an issue we need unique ids for the html. without this seed, each subsequent occurence of this concept as object in an issue would get the same id -->
        <xsl:param name="seed" as="xs:string?"/>
        <xsl:param name="dsid" as="xs:string?"/>
        <xsl:param name="dsed" as="xs:string?"/>
        <xsl:param name="trid" as="xs:string?"/>
        <xsl:param name="tred" as="xs:string?"/>
        <xsl:variable name="conceptId" select="@id"/>
        <xsl:variable name="conceptEffectiveDate" select="@effectiveDate"/>
        <xsl:variable name="conceptVersionLabel" select="@versionLabel"/>
        <xsl:variable name="inheritedId">
            <xsl:choose>
                <xsl:when test="@inheritedId">
                    <xsl:value-of select="@inheritedId"/>
                </xsl:when>
                <xsl:when test="inherit">
                    <xsl:value-of select="inherit/@ref"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="contains/@ref"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="inheritedEff">
            <xsl:choose>
                <xsl:when test="@inheritedEffectiveDate">
                    <xsl:value-of select="@inheritedEffectiveDate"/>
                </xsl:when>
                <xsl:when test="inherit">
                    <xsl:value-of select="inherit/@effectiveDate"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="contains/@flexibility"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="inheritedDisplay">
            <xsl:choose>
                <xsl:when test="inherit/@refdisplay">
                    <xsl:value-of select="inherit/@refdisplay"/>
                </xsl:when>
                <xsl:when test="contains/@refdisplay">
                    <xsl:value-of select="contains/@refdisplay"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="doShorthandId">
                        <xsl:with-param name="id" select="$inheritedId"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="originalConcept" as="element()*">
            <xsl:choose>
                <xsl:when test=".[inherit[string-length(@ref) gt 0]][not(name)]">
                    <xsl:apply-templates select="." mode="deinherit"/>
                </xsl:when>
                <xsl:when test=".[contains[string-length(@ref) gt 0]][not(name)]">
                    <xsl:apply-templates select="." mode="deinherit">
                        <xsl:with-param name="dsref" select="contains/@ref"/>
                        <xsl:with-param name="dsed" select="contains/@flexibility"/>
                    </xsl:apply-templates>
                </xsl:when>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="conceptName" as="element()*">
            <xsl:choose>
                <xsl:when test="name">
                    <xsl:copy-of select="name"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:copy-of select="$originalConcept/name"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="conceptAnchor" select="local:doHtmlAnchor($conceptId, $conceptEffectiveDate)"/>
        <!-- Concept name row -->
        <xsl:if test="not(@hidden)">
            <tr data-tt-id="{generate-id(.)}{$seed}" xmlns="http://www.w3.org/1999/xhtml">
                <xsl:if test="parent::concept">
                    <xsl:attribute name="data-tt-parent-id" select="generate-id(parent::concept)"/>
                </xsl:if>
                <td class="togglertreetable columnName columnPrint" colspan="2">
                    <a name="{$conceptAnchor}"/>
                    <xsl:if test="not(@hidden)">
                        <!-- 
                            EXCEPTION: IF name STARTS WITH "("   OR  statusCode=deprecated
                              THEN SHOW NAME IN GREY ONLY (it is an internal item not to be shown in a dataset at all) 
                        -->
                        <xsl:variable name="columnName">
                            <xsl:choose>
                                <xsl:when test="@type = 'group'">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which">folder</xsl:with-param>
                                    </xsl:call-template>
                                    <xsl:text>&#160;</xsl:text>
                                    <xsl:call-template name="showStatusDot">
                                        <xsl:with-param name="status" select="@statusCode"/>
                                        <xsl:with-param name="title">
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="@type = 'item'">
                                    <xsl:call-template name="showStatusDot">
                                        <xsl:with-param name="status" select="@statusCode"/>
                                        <xsl:with-param name="title">
                                            <xsl:call-template name="getXFormsLabel">
                                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                                            </xsl:call-template>
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="@type"/>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:choose>
                                <xsl:when test="substring($conceptName[1], 1, 1) = '('">
                                    <span style="color: grey;">
                                        <xsl:call-template name="doName">
                                            <xsl:with-param name="ns" select="$conceptName"/>
                                        </xsl:call-template>
                                    </span>
                                </xsl:when>
                                <xsl:when test="@conformance = 'NP'">
                                    <strike>
                                        <xsl:call-template name="doName">
                                            <xsl:with-param name="ns" select="$conceptName"/>
                                        </xsl:call-template>
                                    </strike>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="doName">
                                        <xsl:with-param name="ns" select="$conceptName"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text> </xsl:text>
                            <xsl:value-of select="local:getCardConf(@minimumMultiplicity, @maximumMultiplicity, @conformance, @isMandatory)"/>
                        </xsl:variable>
                        <xsl:choose>
                            <xsl:when test="not($switchCreateTreeTableHtml = 'true')">
                                <table style="float: left;">
                                    <tr>
                                        <xsl:call-template name="doIndentLevel">
                                            <xsl:with-param name="level" select="$level"/>
                                            <xsl:with-param name="icon" select="false()"/>
                                        </xsl:call-template>
                                        <td>
                                            <xsl:copy-of select="$columnName"/>
                                        </td>
                                    </tr>
                                </table>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:copy-of select="$columnName"/>
                            </xsl:otherwise>
                        </xsl:choose>
                        <div style="float: right;">
                            <xsl:choose>
                                <xsl:when test="@iddisplay">
                                    <xsl:value-of select="@iddisplay"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="doShorthandId">
                                        <xsl:with-param name="id" select="$conceptId"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </div>
                    </xsl:if>
                </td>
                <td class="togglertreetable columnNoPrint">
                    <div style="float: right;">
                        <xsl:if test="concept and string-length($projectRestUriDSDiagram) &gt; 0">
                            <a href="{$projectRestUriDSDiagram}&amp;id={$conceptId}&amp;effectiveDate{encode-for-uri($conceptEffectiveDate)}&amp;{if (string-length($dsid)=0) then concat('transactionId=',$trid,'&amp;transactionEffectiveDate=',encode-for-uri($tred)) else concat('datasetId=',$dsid,'&amp;datasetEffectiveDate=',encode-for-uri($dsed))}&amp;format=svg" onclick="target='_blank';">
                                <xsl:attribute name="title">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'showDiagram'"/>
                                    </xsl:call-template>
                                </xsl:attribute>
                                <xsl:text>link</xsl:text>
                            </a>
                        </xsl:if>
                    </div>
                </td>
            </tr>
            <!-- Concept contents row -->
            <tr data-tt-id="{generate-id(.)}{$seed}-contents" data-tt-parent-id="{generate-id(.)}{$seed}" xmlns="http://www.w3.org/1999/xhtml">
                <td class="columnDetails"/>
                <td class="columnDetails">
                    <!--
                        show concept properties
                        
                        for concepts with an id directly
                        for concept with an inherited concept do copying of properties of the referenced conept first and then show it
                    -->
                    <xsl:choose>
                        <!-- Compilation already resolves inherit info. Check if this is the case by checking whether or we already have a name.
                                The concept will not have a name in a normal inherit situation.
                            -->
                        <xsl:when test="not(name | $originalConcept)">
                            <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                <xsl:if test="@statusCode = ('cancelled', 'deprecated', 'rejected')">
                                    <!-- if concept is cancelled, deprecated, rejected... make strips in the background -->
                                    <xsl:attribute name="class" select="'bgstrips'"/>
                                </xsl:if>
                                <tr>
                                    <!-- show error in concept node -->
                                    <td class="nodetype" style="text-align: center;">
                                        <xsl:call-template name="showStatusDot">
                                            <xsl:with-param name="status" select="'error'"/>
                                        </xsl:call-template>
                                        <xsl:text>&#160;</xsl:text>
                                    </td>
                                    <!-- show the error message -->
                                    <td valign="middle" colspan="2" class="nodename tabtab">
                                        <table style="border: 0;">
                                            <xsl:call-template name="doMessage">
                                                <xsl:with-param name="msg">
                                                    <xsl:choose>
                                                        <xsl:when test="string-length($inheritedEff) &gt; 0">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'theReferencedConceptAsOfCannotBeFound'"/>
                                                                <xsl:with-param name="p1" select="$inheritedId"/>
                                                                <xsl:with-param name="p2" select="$inheritedEff"/>
                                                            </xsl:call-template>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'theReferencedConceptCannotBeFound'"/>
                                                                <xsl:with-param name="p1" select="$inheritedId"/>
                                                            </xsl:call-template>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </xsl:when>
                        <!-- this is a concept with an id, show it -->
                        <xsl:when test="string-length($conceptId) &gt; 0">
                            <table width="100%" border="0" cellspacing="1" cellpadding="6">
                                <xsl:if test="@statusCode = ('cancelled', 'deprecated', 'rejected')">
                                    <!-- if concept is cancelled, deprecated, rejected... make strips in the background -->
                                    <xsl:attribute name="class" select="'bgstrips'"/>
                                </xsl:if>
                                <!-- ID -->
                                <tr>
                                    <td class="nodeproperty" style="vertical-align: top;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Id'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td colspan="2">
                                        <a href="#{local:doHtmlAnchor($conceptId, $conceptEffectiveDate)}">
                                            <xsl:attribute name="title">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'LinkToSelf'"/>
                                                </xsl:call-template>
                                            </xsl:attribute>
                                            <xsl:choose>
                                                <xsl:when test="@iddisplay">
                                                    <xsl:value-of select="@iddisplay"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="doShorthandId">
                                                        <xsl:with-param name="id" select="$conceptId"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </a>
                                        <xsl:if test="$conceptEffectiveDate">
                                            <xsl:text> (</xsl:text>
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$conceptEffectiveDate"/>
                                            </xsl:call-template>
                                            <xsl:text>)</xsl:text>
                                        </xsl:if>
                                        <xsl:if test="@versionLabel[string-length() gt 0]">
                                            <xsl:text> </xsl:text>
                                            <xsl:value-of select="@versionLabel"/>
                                        </xsl:if>
                                    </td>
                                </tr>
                                <!-- show cardinality conformance if present (only for scenario transaction dataset compilations) -->
                                <xsl:if test="string-length(concat(@minimumMultiplicity, @maximumMultiplicity, @isMandatory, @conformance)) &gt; 0 or count(conditionalConcept) &gt; 0">
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Cardinality'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <strong>
                                                <xsl:value-of select="local:getCardConf(@minimumMultiplicity, @maximumMultiplicity, @conformance, @isMandatory)"/>
                                            </strong>
                                            <xsl:if test="conditionalConcept">
                                                <xsl:variable name="conditionals" as="element()">
                                                    <conditionals xmlns="">
                                                        <!-- copy the extra pre-processed conditions -->
                                                        <xsl:copy-of select="conditionalConcept"/>
                                                    </conditionals>
                                                </xsl:variable>
                                                <p>
                                                    <xsl:apply-templates select="$conditionals"/>
                                                </p>
                                            </xsl:if>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <xsl:if test="context[.//text()[string-length(normalize-space()) gt 0]]">
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Context'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <xsl:call-template name="doDescription">
                                                <xsl:with-param name="ns" select="context"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <!-- Obligations -->
                                <xsl:if test="obligation">
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Obligation'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <xsl:call-template name="doObligation">
                                                <xsl:with-param name="ns" select="obligation"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <!-- Compilation already resolves inherit/contains info, but leaves the element in-->
                                <xsl:if test="(inherit | @inheritedId | contains)">
                                    <xsl:variable name="inheritedConcept" select="local:getConcept($inheritedId, $inheritedEff)" as="element(concept)?"/>
                                    <xsl:variable name="dataset" select="local:getDatasetForConcept($inheritedId, $inheritedEff)" as="element(dataset)?"/>
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key">
                                                    <xsl:choose>
                                                        <xsl:when test="inherit">conceptInheritsFrom</xsl:when>
                                                        <xsl:otherwise>conceptContains</xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <i>
                                                <!-- In a compiled situation it is very well possible that we cannot resolve the concept, but add link in case we do -->
                                                <xsl:choose>
                                                    <xsl:when test="$inheritedConcept">
                                                        <xsl:call-template name="showStatusDot">
                                                            <xsl:with-param name="status" select="$inheritedConcept/@statusCode"/>
                                                            <xsl:with-param name="title">
                                                                <xsl:call-template name="getXFormsLabel">
                                                                    <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                                    <xsl:with-param name="simpleTypeValue" select="$inheritedConcept/@statusCode"/>
                                                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                                </xsl:call-template>
                                                            </xsl:with-param>
                                                        </xsl:call-template>
                                                        <xsl:text>&#160;</xsl:text>
                                                        <a href="{local:doHtmlName('DS', $projectPrefix, $dataset/@id, $dataset/@effectiveDate, $inheritedId, $inheritedConcept/@effectiveDate, (), (), '.html', false())}">
                                                            <!-- No need to open new tab/window when target is self. -->
                                                            <xsl:choose>
                                                                <xsl:when test="$dataset[@id = $dsid][@effectiveDate = $dsed]"/>
                                                                <xsl:otherwise>
                                                                    <xsl:attribute name="onclick">target='_blank';</xsl:attribute>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                            <xsl:copy-of select="$inheritedDisplay"/>
                                                        </a>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <span title="{$inheritedId}">
                                                            <xsl:copy-of select="$inheritedDisplay"/>
                                                        </span>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </i>
                                            <xsl:text> (</xsl:text>
                                            <xsl:choose>
                                                <xsl:when test="$inheritedEff castable as xs:dateTime">
                                                    <xsl:call-template name="showDate">
                                                        <xsl:with-param name="date" select="$inheritedEff"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            <xsl:text>)</xsl:text>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <xsl:call-template name="check4Issue">
                                    <xsl:with-param name="id" select="$conceptId"/>
                                    <xsl:with-param name="effectiveDate" select="$conceptEffectiveDate"/>
                                    <xsl:with-param name="colspans" select="2"/>
                                </xsl:call-template>
                                <xsl:if test="synonym[@language = $defaultLanguage]">
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key">
                                                    <xsl:choose>
                                                        <xsl:when test="count(synonym[@language = $defaultLanguage]) > 1">Synonyms</xsl:when>
                                                        <xsl:otherwise>Synonym</xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:with-param>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <xsl:for-each select="synonym[@language = $defaultLanguage]">
                                                <div>
                                                    <xsl:value-of select="."/>
                                                </div>
                                            </xsl:for-each>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Description'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <xsl:call-template name="doDescription">
                                                <xsl:with-param name="ns" select="desc"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <xsl:if test="property">
                                    <tr>
                                        <td colspan="3">
                                            <div id="Accordionid" class="Accordion">
                                                <div class="AccordionPanel">
                                                    <div class="AccordionPanelTab">
                                                        <div class="acco" onclick="toggleZoomImg(this,'zoomout','{$theAssetsDir}');">
                                                            <h3>
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'Properties'"/>
                                                                </xsl:call-template>
                                                            </h3>
                                                        </div>
                                                    </div>
                                                    <div class="AccordionPanelContent">
                                                        <table class="zebra-table" width="100%">
                                                            <xsl:for-each select="property">
                                                                <xsl:variable name="ref" select="@ref"/>
                                                                <xsl:variable name="flex" select="@flexibility"/>
                                                                <tr>
                                                                    <td style="text-align: left; background-color: #F6F3EE;">
                                                                        <xsl:value-of select="@name"/>
                                                                    </td>
                                                                    <td>
                                                                        <xsl:copy-of select="node()"/>
                                                                    </td>
                                                                </tr>
                                                            </xsl:for-each>
                                                        </table>
                                                    </div>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <xsl:if test="relationship">
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Relationship'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <xsl:for-each select="relationship">
                                                <xsl:variable name="ref" select="@ref"/>
                                                <xsl:variable name="flex" select="@flexibility"/>
                                                <xsl:variable name="concept" select="local:getConceptFlat($ref, $flex)" as="element(concept)?"/>
                                                <xsl:variable name="dataset" select="local:getDatasetFlatForConcept($ref, $flex)" as="element(dataset)?"/>
                                                <xsl:variable name="ced">
                                                    <xsl:choose>
                                                        <xsl:when test="$flex castable as xs:dateTime">
                                                            <xsl:value-of select="$flex"/>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <xsl:value-of select="$concept[1]/@effectiveDate"/>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:variable>
                                                <xsl:variable name="cstext" as="xs:string*">
                                                    <xsl:choose>
                                                        <xsl:when test="@refdisplay[string-length() > 0]">
                                                            <xsl:value-of select="@refdisplay"/>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <xsl:call-template name="doShorthandId">
                                                                <xsl:with-param name="id" select="$ref"/>
                                                            </xsl:call-template>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                    <xsl:text> - </xsl:text>
                                                    <xsl:choose>
                                                        <xsl:when test="matches(@flexibility, '^\d{4}')">
                                                            <xsl:call-template name="showDate">
                                                                <xsl:with-param name="date" select="$flex"/>
                                                            </xsl:call-template>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                            </xsl:call-template>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:variable>
                                                <div>
                                                    <xsl:call-template name="getXFormsLabel">
                                                        <xsl:with-param name="simpleTypeKey" select="'RelationshipTypes'"/>
                                                        <xsl:with-param name="simpleTypeValue" select="@type"/>
                                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                    </xsl:call-template>
                                                    <xsl:text> </xsl:text>
                                                    <xsl:choose>
                                                        <xsl:when test="$concept[@effectiveDate = $ced]">
                                                            <a href="{local:doHtmlName('DS', $projectPrefix, $dataset/@id, $dataset/@effectiveDate, $concept[@effectiveDate = $ced]/@id, $ced, (), (), '.html', false())}">
                                                                <!-- No need to open new tab/window when target is self. -->
                                                                <xsl:choose>
                                                                    <xsl:when test="$dataset[@id = $dsid][@effectiveDate = $dsed]"/>
                                                                    <xsl:otherwise>
                                                                        <xsl:attribute name="onclick">target='_blank';</xsl:attribute>
                                                                    </xsl:otherwise>
                                                                </xsl:choose>
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="$concept/name"/>
                                                                </xsl:call-template>
                                                                <i>
                                                                    <xsl:text> (</xsl:text>
                                                                    <xsl:value-of select="string-join($cstext, '')"/>
                                                                    <xsl:text>)</xsl:text>
                                                                </i>
                                                            </a>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <span title="{$ref}">
                                                                <xsl:value-of select="string-join($cstext, '')"/>
                                                            </span>
                                                            <xsl:call-template name="logMessage">
                                                                <xsl:with-param name="level" select="$logDEBUG"/>
                                                                <xsl:with-param name="msg">
                                                                    <xsl:text>+++ Could not find referenced concept id='</xsl:text>
                                                                    <xsl:value-of select="$ref"/>
                                                                    <xsl:text>' referenced from relationship in concept id='</xsl:text>
                                                                    <xsl:value-of select="../@id"/>
                                                                    <xsl:text> - </xsl:text>
                                                                    <xsl:value-of select="../@effectiveDate"/>
                                                                    <xsl:text>. This might be due to it being in a different project/BBR or because the ref/effectiveDate is broken.</xsl:text>
                                                                </xsl:with-param>
                                                            </xsl:call-template>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </div>
                                            </xsl:for-each>
                                            
                                        </td>
                                    </tr>
                                </xsl:if>
                                <xsl:for-each select="rationale">
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Rationale'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <xsl:copy-of select="node()"/>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                                <xsl:for-each select="source">
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:choose>
                                                <xsl:when test="position() = 1">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'Source'"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:text>&#160;</xsl:text>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </td>
                                        <td colspan="2">
                                            <xsl:copy-of select="node()"/>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                                <xsl:for-each select="comment">
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Comment'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <xsl:copy-of select="node()"/>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                                <xsl:for-each select="operationalization">
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'Operationalization'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <xsl:copy-of select="node()"/>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                                <!-- Find terminologyAssociations
                                    - When compiled: they will be inline in the dataset. Assume those are ok.
                                    - When uncompiled: find what matches in $allTerminologyAssociations
                                    
                                    In both cases: matches will have a @code, and shall match one of:
                                    1. The current concept/@id
                                    2. The current concept/inherit/@ref
                                    3. The original concept/@id (normally this is equal to the concept/inherit/@ref, but inc ase of indirect inheritance, it might be yet a third id)
                                -->
                                <xsl:variable name="currentTerminologyAssociations" as="element()*">
                                    <xsl:choose>
                                        <xsl:when test="terminologyAssociation">
                                            <!-- Match any association with a @code, that does not match any of the valueDomain concepts. When the decor file is compiled, $originalConcept 
                                                will not have anything useful so this is an indirect method to get to the right stuff -->
                                            <xsl:copy-of select="terminologyAssociation[not(@conceptId = ../valueDomain//@id)][@code]"/>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:copy-of select="$allTerminologyAssociations/*/terminologyAssociation[@conceptId = ($conceptId | $inheritedId | $originalConcept/@id)][@code]"/>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>
                                <xsl:for-each-group select="$currentTerminologyAssociations" group-by="concat(@code, @codeSystem)">
                                    <xsl:variable name="theCode" select="current-group()[1]/@code"/>
                                    <xsl:variable name="theCodeSystem" select="current-group()[1]/@codeSystem"/>
                                    <xsl:variable name="theDisplayName" select="current-group()[1]/@displayName"/>
                                    <xsl:variable name="theCodeSystemName">
                                        <xsl:variable name="theCSN" as="xs:string*">
                                            <xsl:call-template name="getIDDisplayName">
                                                <xsl:with-param name="root" select="current-group()[1]/@codeSystem"/>
                                            </xsl:call-template>
                                        </xsl:variable>
                                        <xsl:choose>
                                            <xsl:when test="empty($theCSN)">
                                                <xsl:value-of select="(current-group()/@codeSystemName)[1]"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="$theCSN"/>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <xsl:variable name="theEffectiveDate" select="current-group()[1]/@effectiveDate"/>
                                    <xsl:variable name="theExpirationDate" select="current-group()[1]/@expirationDate"/>
                                    <xsl:variable name="expiredLook">
                                        <xsl:if test="$theExpirationDate castable as xs:dateTime and xs:dateTime($theExpirationDate) &lt;= current-dateTime()">text-decoration: line-through;</xsl:if>
                                    </xsl:variable>
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'terminologyAssociation'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td style="background-color: #FFEAFF; {$expiredLook}" colspan="2">
                                            <xsl:choose>
                                                <xsl:when test="string-length(@displayName) > 0">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'conceptRepresentationLineWithDisplay'"/>
                                                        <xsl:with-param name="p1" select="$theCode"/>
                                                        <xsl:with-param name="p2" select="$theCodeSystem"/>
                                                        <xsl:with-param name="p3" select="$theDisplayName"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'conceptRepresentationLine'"/>
                                                        <xsl:with-param name="p1" select="$theCode"/>
                                                        <xsl:with-param name="p2" select="$theCodeSystem"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            <xsl:text> </xsl:text>
                                            <i>
                                                <xsl:copy-of select="$theCodeSystemName"/>
                                            </i>
                                            <!--<xsl:if test="@effectiveDate | @expirationDate"> (</xsl:if>
                                            <xsl:if test="@effectiveDate">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'fromX'"/>
                                                </xsl:call-template>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="@effectiveDate"/>
                                                </xsl:call-template>
                                            </xsl:if>-->
                                            <xsl:if test="$theExpirationDate">
                                                <xsl:text> (</xsl:text>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'toY'"/>
                                                </xsl:call-template>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="$theExpirationDate"/>
                                                </xsl:call-template>
                                                <xsl:text>)</xsl:text>
                                            </xsl:if>
                                            <xsl:if test="$theEffectiveDate | $theExpirationDate">)</xsl:if>
                                        </td>
                                    </tr>
                                </xsl:for-each-group>
                                <xsl:for-each select="valueDomain">
                                    <xsl:variable name="datatype" select="@type"/>
                                    <xsl:variable name="doMinInclude" select="property[@minInclude[not(. = '')]]"/>
                                    <xsl:variable name="doMaxInclude" select="property[@maxInclude[not(. = '')]]"/>
                                    <xsl:variable name="doMinLength" select="property[@minLength[not(. = '')]]"/>
                                    <xsl:variable name="doMaxLength" select="property[@maxLength[not(. = '')]]"/>
                                    <xsl:variable name="doFractionDigits" select="property[@fractionDigits[not(. = '')]]"/>
                                    <xsl:variable name="doUnit" select="property[@unit[not(. = '')]]"/>
                                    <xsl:variable name="doDefault" select="property[@default[not(. = '')]]"/>
                                    <xsl:variable name="doFixed" select="property[@fixed[not(. = '')]]"/>
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'ValueDomain'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <a href="https://docs.art-decor.org/introduction/dataset/#datatypes" onclick="target='_blank';" alt="">
                                                <xsl:attribute name="title">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'go-to-documentation'"/>
                                                    </xsl:call-template>
                                                </xsl:attribute>
                                                <xsl:call-template name="getXFormsLabel">
                                                    <xsl:with-param name="simpleTypeKey" select="'DataSetValueType'"/>
                                                    <xsl:with-param name="simpleTypeValue" select="$datatype"/>
                                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                </xsl:call-template>
                                            </a>
                                        </td>
                                    </tr>
                                    <xsl:if test="property[@*[string-length() gt 0]]">
                                        <tr>
                                            <td class="nodeproperty" style="vertical-align: top;">
                                                <xsl:if test="position() = 1">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'Property'"/>
                                                    </xsl:call-template>
                                                </xsl:if>
                                            </td>
                                            <!-- select per type -->
                                            <xsl:choose>
                                                <xsl:when test="$datatype = 'count'">
                                                    <td colspan="2" class="tabtab">
                                                        <table border="0" cellspacing="3" cellpadding="5">
                                                            <tr>
                                                                <xsl:if test="$doMinInclude">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'minInclude'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doMaxInclude">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'maxInclude'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doDefault">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'default'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doFixed">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'fixed'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:for-each select="distinct-values(property/(@*[not(. = '')] except (@minInclude | @minInclude | @default | @fixed))/name())">
                                                                    <th>
                                                                        <xsl:attribute name="title">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'unexpectedPropertyForDatatype'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:attribute>
                                                                        <i>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="if (. = 'timeStampPrecision') then 'TimestampPrecision' else (.)"/>
                                                                            </xsl:call-template>
                                                                        </i>
                                                                    </th>
                                                                </xsl:for-each>
                                                            </tr>
                                                            <xsl:for-each select="property[@*[string-length() gt 0]]">
                                                                <tr>
                                                                    <xsl:if test="$doMinInclude">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@minInclude"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doMaxInclude">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@maxInclude"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doDefault">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@default"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doFixed">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@fixed"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:for-each select="@*[not(. = '')] except (@minInclude | @minInclude | @default | @fixed)">
                                                                        <td>
                                                                            <xsl:value-of select="."/>
                                                                        </td>
                                                                    </xsl:for-each>
                                                                </tr>
                                                            </xsl:for-each>
                                                        </table>
                                                    </td>
                                                </xsl:when>
                                                <xsl:when test="$datatype = 'text' or $datatype = 'string'">
                                                    <td colspan="2" class="tabtab">
                                                        <table border="0" cellspacing="3" cellpadding="5">
                                                            <tr>
                                                                <xsl:if test="$doMinLength">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'minLength'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doMaxLength">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'maxLength'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doDefault">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'default'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doFixed">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'fixed'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:for-each select="distinct-values(property/(@*[not(. = '')] except (@minLength | @maxLength | @default | @fixed))/name())">
                                                                    <th>
                                                                        <xsl:attribute name="title">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'unexpectedPropertyForDatatype'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:attribute>
                                                                        <i>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="if (. = 'timeStampPrecision') then 'TimestampPrecision' else (.)"/>
                                                                            </xsl:call-template>
                                                                        </i>
                                                                    </th>
                                                                </xsl:for-each>
                                                            </tr>
                                                            <xsl:for-each select="property[@*[string-length() gt 0]]">
                                                                <tr>
                                                                    <xsl:if test="$doMinLength">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@minLength"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doMaxLength">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@maxLength"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doDefault">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@default"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doFixed">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@fixed"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:for-each select="@*[not(. = '')] except (@minLength | @maxLength | @default | @fixed)">
                                                                        <td>
                                                                            <xsl:value-of select="."/>
                                                                        </td>
                                                                    </xsl:for-each>
                                                                </tr>
                                                            </xsl:for-each>
                                                        </table>
                                                    </td>
                                                </xsl:when>
                                                <xsl:when test="$datatype = 'date' or $datatype = 'datetime'">
                                                    <!-- timeStampPrecision -->
                                                    <td colspan="2" class="tabtab">
                                                        <table border="0" cellspacing="3" cellpadding="5">
                                                            <tr>
                                                                <th>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'TimestampPrecision'"/>
                                                                    </xsl:call-template>
                                                                </th>
                                                                <xsl:for-each select="distinct-values(property/(@*[not(. = '')] except (@timeStampPrecision))/name())">
                                                                    <th>
                                                                        <xsl:attribute name="title">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'unexpectedPropertyForDatatype'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:attribute>
                                                                        <i>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="if (. = 'timeStampPrecision') then 'TimestampPrecision' else (.)"/>
                                                                            </xsl:call-template>
                                                                        </i>
                                                                    </th>
                                                                </xsl:for-each>
                                                            </tr>
                                                            <xsl:for-each select="property[@*[string-length() gt 0]]">
                                                                <tr>
                                                                    <td style="text-align: left;">
                                                                        <xsl:if test="@timeStampPrecision[not(. = '')]">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="concat('timeStampPrecision-', @timeStampPrecision)"/>
                                                                            </xsl:call-template>
                                                                        </xsl:if>
                                                                    </td>
                                                                    <xsl:for-each select="@*[not(. = '')] except (@timeStampPrecision)">
                                                                        <td>
                                                                            <xsl:value-of select="."/>
                                                                        </td>
                                                                    </xsl:for-each>
                                                                </tr>
                                                            </xsl:for-each>
                                                        </table>
                                                    </td>
                                                </xsl:when>
                                                <xsl:when test="$datatype = 'quantity' or $datatype = 'duration'">
                                                    <!-- rangeFrom, rangeTo, unit(s), fractionDigits -->
                                                    <td colspan="2" class="tabtab">
                                                        <table border="0" cellspacing="3" cellpadding="5">
                                                            <tr>
                                                                <xsl:if test="$doMinInclude">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'minInclude'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doMaxLength">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'maxInclude'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doUnit">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'unit'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doFractionDigits">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'fractionDigits'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doDefault">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'default'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doFixed">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'fixed'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:for-each select="distinct-values(property/(@*[not(. = '')] except (@minInclude | @maxInclude | @unit | @fractionDigits | @default | @fixed))/name())">
                                                                    <th>
                                                                        <xsl:attribute name="title">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'unexpectedPropertyForDatatype'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:attribute>
                                                                        <i>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="if (. = 'timeStampPrecision') then 'TimestampPrecision' else (.)"/>
                                                                            </xsl:call-template>
                                                                        </i>
                                                                    </th>
                                                                </xsl:for-each>
                                                            </tr>
                                                            <xsl:for-each select="property[@*[string-length() gt 0]]">
                                                                <tr>
                                                                    <xsl:if test="$doMinInclude">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@minInclude"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doMaxInclude">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@maxInclude"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doUnit">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@unit"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doFractionDigits">
                                                                        <td style="text-align: right;">
                                                                            <xsl:choose>
                                                                                <xsl:when test="string-length(@fractionDigits) = 0">&#160;</xsl:when>
                                                                                <xsl:when test="matches(string(@fractionDigits), '!$')">
                                                                                    <!-- exact fraction digits -->
                                                                                    <xsl:value-of select="substring-before(@fractionDigits, '!')"/>
                                                                                </xsl:when>
                                                                                <xsl:when test="matches(string(@fractionDigits), '\.$')">
                                                                                    <!-- max fraction digits -->
                                                                                    <xsl:text>&lt;= </xsl:text>
                                                                                    <xsl:value-of select="substring-before(@fractionDigits, '.')"/>
                                                                                </xsl:when>
                                                                                <xsl:otherwise>
                                                                                    <!-- min fraction digits -->
                                                                                    <xsl:text>&gt;= </xsl:text>
                                                                                    <xsl:value-of select="@fractionDigits"/>
                                                                                </xsl:otherwise>
                                                                            </xsl:choose>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doDefault">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@default"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doFixed">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@fixed"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:for-each select="@*[not(. = '')] except (@minInclude | @maxInclude | @unit | @fractionDigits | @default | @fixed)">
                                                                        <td>
                                                                            <xsl:value-of select="."/>
                                                                        </td>
                                                                    </xsl:for-each>
                                                                </tr>
                                                            </xsl:for-each>
                                                        </table>
                                                    </td>
                                                </xsl:when>
                                                <xsl:when test="$datatype = 'identifier'">
                                                    <td colspan="2" class="tabtab">
                                                        <table border="0" cellspacing="3" cellpadding="5">
                                                            <tr>
                                                                <xsl:if test="$doMinLength">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'minLength'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doMaxLength">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'maxLength'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:for-each select="distinct-values(property/(@*[not(. = '')] except (@minLength | @maxLength))/name())">
                                                                    <th>
                                                                        <xsl:attribute name="title">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'unexpectedPropertyForDatatype'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:attribute>
                                                                        <i>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="if (. = 'timeStampPrecision') then 'TimestampPrecision' else (.)"/>
                                                                            </xsl:call-template>
                                                                        </i>
                                                                    </th>
                                                                </xsl:for-each>
                                                            </tr>
                                                            <xsl:for-each select="property[@*[string-length() gt 0]]">
                                                                <tr>
                                                                    <xsl:if test="$doMinLength">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@minLength"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:if test="$doMaxLength">
                                                                        <td style="text-align: right;">
                                                                            <xsl:value-of select="@maxLength"/>
                                                                        </td>
                                                                    </xsl:if>
                                                                    <xsl:for-each select="@*[not(. = '')] except (@minLength | @maxLength)">
                                                                        <td>
                                                                            <xsl:value-of select="."/>
                                                                        </td>
                                                                    </xsl:for-each>
                                                                </tr>
                                                            </xsl:for-each>
                                                        </table>
                                                    </td>
                                                </xsl:when>
                                                <xsl:when test="$datatype = 'blob'">
                                                    <td colspan="2" class="tabtab">
                                                        <table border="0" cellspacing="3" cellpadding="5">
                                                            <tr>
                                                                <xsl:if test="$doMinLength">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'minLength'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:if test="$doMaxLength">
                                                                    <th>
                                                                        <xsl:call-template name="getMessage">
                                                                            <xsl:with-param name="key" select="'maxLength'"/>
                                                                        </xsl:call-template>
                                                                    </th>
                                                                </xsl:if>
                                                                <xsl:for-each select="@*[not(. = '')] except (@minLength | @maxLength)">
                                                                    <th>
                                                                        <xsl:attribute name="title">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'unexpectedPropertyForDatatype'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:attribute>
                                                                        <i>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="if (. = 'timeStampPrecision') then 'TimestampPrecision' else (.)"/>
                                                                            </xsl:call-template>
                                                                        </i>
                                                                    </th>
                                                                </xsl:for-each>
                                                            </tr>
                                                            <tr>
                                                                <xsl:if test="$doMinLength">
                                                                    <td style="text-align: right;">
                                                                        <xsl:value-of select="@minLength"/>
                                                                    </td>
                                                                </xsl:if>
                                                                <xsl:if test="$doMaxLength">
                                                                    <td style="text-align: right;">
                                                                        <xsl:value-of select="@maxLength"/>
                                                                    </td>
                                                                </xsl:if>
                                                                <xsl:for-each select="@*[not(. = '')] except (@minLength | @maxLength)">
                                                                    <td>
                                                                        <xsl:value-of select="."/>
                                                                    </td>
                                                                </xsl:for-each>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <td colspan="2">
                                                        <table border="0" cellspacing="3" cellpadding="5">
                                                            <tr>
                                                                <xsl:for-each select="distinct-values(property/(@*[not(. = '')])/name())">
                                                                    <th>
                                                                        <xsl:attribute name="title">
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="'unexpectedPropertyForDatatype'"/>
                                                                            </xsl:call-template>
                                                                        </xsl:attribute>
                                                                        <i>
                                                                            <xsl:call-template name="getMessage">
                                                                                <xsl:with-param name="key" select="if (. = 'timeStampPrecision') then 'TimestampPrecision' else (.)"/>
                                                                            </xsl:call-template>
                                                                        </i>
                                                                    </th>
                                                                </xsl:for-each>
                                                            </tr>
                                                            <xsl:for-each select="property[@*[string-length() gt 0]]">
                                                                <tr>
                                                                    <xsl:for-each select="@*[not(. = '')]">
                                                                        <td>
                                                                            <xsl:value-of select="."/>
                                                                        </td>
                                                                    </xsl:for-each>
                                                                </tr>
                                                            </xsl:for-each>
                                                        </table>
                                                    </td>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </tr>
                                    </xsl:if>
                                    <xsl:call-template name="doIdentifierAssociations">
                                        <xsl:with-param name="in" select="../identifierAssociation"/>
                                    </xsl:call-template>
                                    <xsl:apply-templates select="conceptList"/>
                                    <xsl:for-each select="example">
                                        <!-- 
                                                show example pretty printed
                                                if parent is template then different td's are used compared to in-element examples
                                            -->
                                        <xsl:variable name="expclass">
                                            <xsl:choose>
                                                <xsl:when test="@type = 'valid'">
                                                    <!-- a valid example, render it green -->
                                                    <xsl:text>explabelgreen</xsl:text>
                                                </xsl:when>
                                                <xsl:when test="@type = 'error'">
                                                    <!-- an invalid example, render it red -->
                                                    <xsl:text>explabelred</xsl:text>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <!-- normal rendering otherwise -->
                                                    <xsl:text>explabelblue</xsl:text>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:variable>
                                        <tr>
                                            <td class="nodeproperty" style="vertical-align: top;">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Example'"/>
                                                </xsl:call-template>
                                            </td>
                                            <td class="{$expclass}" colspan="2">
                                                <xsl:if test=".[@caption]">
                                                    <div class="expcaption">
                                                        <xsl:value-of select="@caption"/>
                                                    </div>
                                                </xsl:if>
                                                <xsl:copy-of select="node()"/>
                                            </td>
                                        </tr>
                                    </xsl:for-each>
                                </xsl:for-each>
                                <!-- used in what scenarios? -->
                                <xsl:variable name="assocScenarios" select="$allScenarios//representingTemplate[@sourceDataset = ($dsid, ancestor::dataset/@id)][@sourceDatasetFlexibility = ($dsed, ancestor::dataset/@effectiveDate)]/concept[@ref = $conceptId] | 
                                                                            $allScenarios//representingTemplate/concept[@ref = $conceptId][@flexibility = $conceptEffectiveDate]"/>
                                <!-- used in what datasets? -->
                                <xsl:variable name="assocDatasets" select="$allDatasets/dataset//inherit[@ref = $conceptId][@effectiveDate = $conceptEffectiveDate]"/>
                                
                                <!-- used in what templates? -->
                                <xsl:variable name="assocTemplates" select="$allTemplateAssociation/*/templateAssociation[concept[@ref = $conceptId][@effectiveDate = $conceptEffectiveDate]]"/>
                                <xsl:variable name="sccount" select="count($assocScenarios)"/>
                                <xsl:variable name="ihcount" select="count($assocDatasets)"/>
                                <xsl:variable name="tmcount" select="count($assocTemplates)"/>
                                <!-- Counter header -->
                                <xsl:if test="$sccount + $ihcount + $tmcount gt 0">
                                    <xsl:variable name="elid" select="generate-id(.)"/>
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top;">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">target</xsl:with-param>
                                            </xsl:call-template>
                                            <xsl:text> </xsl:text>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'UsedBy'"/>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <xsl:choose>
                                                <xsl:when test="not($switchCreateTreeTableHtml = 'true')">
                                                    <xsl:attribute name="class" select="'toggler'"/>
                                                    <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:attribute name="class" select="'togglertreetable subcollapsed'"/>
                                                    <xsl:attribute name="onclick" select="concat('$(''#', $elid, ''').toggle(); $(this).toggleClass(''subcollapsed'').toggleClass(''subexpanded'')')"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            <xsl:choose>
                                                <xsl:when test="$sccount = 1 and $tmcount = 1 and $ihcount = 1">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'scenarioTemplateInheritCount'"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:when test="$sccount = 1 and $tmcount != 1 and $ihcount = 1">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'scenarioTemplatesInheritCount'"/>
                                                        <xsl:with-param name="p1" select="$tmcount"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:when test="$sccount != 1 and $tmcount = 1 and $ihcount = 1">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'scenariosTemplateInheritCount'"/>
                                                        <xsl:with-param name="p1" select="$sccount"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:when test="$sccount != 1 and $tmcount != 1 and $ihcount = 1">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'scenariosTemplatesInheritCount'"/>
                                                        <xsl:with-param name="p1" select="$sccount"/>
                                                        <xsl:with-param name="p2" select="$tmcount"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:when test="$sccount = 1 and $tmcount = 1 and $ihcount != 1">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'scenarioTemplateInheritsCounts'"/>
                                                        <xsl:with-param name="p1" select="$ihcount"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:when test="$sccount = 1 and $tmcount != 1 and $ihcount != 1">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'scenarioTemplatesInheritsCounts'"/>
                                                        <xsl:with-param name="p1" select="$tmcount"/>
                                                        <xsl:with-param name="p2" select="$ihcount"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:when test="$sccount != 1 and $tmcount = 1 and $ihcount != 1">
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'scenariosTemplateInheritsCounts'"/>
                                                        <xsl:with-param name="p1" select="$sccount"/>
                                                        <xsl:with-param name="p2" select="$ihcount"/>
                                                    </xsl:call-template>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:call-template name="getMessage">
                                                        <xsl:with-param name="key" select="'scenariosTemplatesInheritsCounts'"/>
                                                        <xsl:with-param name="p1" select="$sccount"/>
                                                        <xsl:with-param name="p2" select="$tmcount"/>
                                                        <xsl:with-param name="p3" select="$ihcount"/>
                                                    </xsl:call-template>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="nodeproperty" style="vertical-align: top; text-align: left;">&#160;</td>
                                        <td colspan="2" style="vertical-align: top;">
                                            <div id="{$elid}" style="background-color: #FFEAEA;">
                                                <!--<xsl:if test="not($switchCreateTreeTableHtml = 'true')">-->
                                                <xsl:attribute name="style" select="'display: none;'"/>
                                                <!--</xsl:if>-->
                                                <!-- Display transactions -->
                                                <xsl:for-each select="$assocScenarios">
                                                    <div style="background-color: #FFEAEA;">
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'conceptTransactionAssocLine_1'"/>
                                                        </xsl:call-template>
                                                        <xsl:text> </xsl:text>
                                                        <i>
                                                            <a href="{local:doHtmlName('TR', $projectPrefix, ancestor-or-self::transaction[1]/@id, ancestor-or-self::transaction[1]/@effectiveDate, (), (), $conceptId, $conceptEffectiveDate, '.html', false())}" onclick="target='_blank';">
                                                                <!-- Transaction Name -->
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="ancestor-or-self::transaction[1]/name"/>
                                                                </xsl:call-template>
                                                                <xsl:if test="ancestor-or-self::transaction[1]/@versionLabel">
                                                                    <xsl:text> (</xsl:text>
                                                                    <xsl:value-of select="ancestor-or-self::transaction[1]/@versionLabel"/>
                                                                    <xsl:text>)</xsl:text>
                                                                </xsl:if>
                                                            </a>
                                                        </i>
                                                        <xsl:text> (</xsl:text>
                                                        <!-- Min/Max/Conf/Mand -->
                                                        <xsl:value-of select="local:getCardConf(., $defaultLanguage)"/>
                                                        <xsl:text>) </xsl:text>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'conceptTransactionAssocLine_2'"/>
                                                            <xsl:with-param name="p1">
                                                                <!-- Scenario Name -->
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="ancestor-or-self::scenario/name"/>
                                                                </xsl:call-template>
                                                                <xsl:if test="ancestor-or-self::scenario/@versionLabel">
                                                                    <xsl:text> (</xsl:text>
                                                                    <xsl:value-of select="ancestor-or-self::scenario/@versionLabel"/>
                                                                    <xsl:text>)</xsl:text>
                                                                </xsl:if>
                                                            </xsl:with-param>
                                                        </xsl:call-template>
                                                        <xsl:text> </xsl:text>
                                                    </div>
                                                </xsl:for-each>
                                                <!-- Display templates -->
                                                <xsl:for-each select="$assocTemplates">
                                                    <xsl:variable name="xref" select="@templateId"/>
                                                    <xsl:variable name="xflex" select="@effectiveDate"/>
                                                    <xsl:variable name="rccontent" as="element()*">
                                                        <xsl:call-template name="getRulesetContent">
                                                            <xsl:with-param name="ruleset" select="$xref"/>
                                                            <xsl:with-param name="flexibility" select="$xflex"/>
                                                            <xsl:with-param name="sofar" select="()"/>
                                                        </xsl:call-template>
                                                    </xsl:variable>
                                                    <xsl:for-each-group select="concept[@ref = $conceptId][not(@effectiveDate) or @effectiveDate = $conceptEffectiveDate]" group-by="concat(@ref, @elementId)">
                                                        <xsl:for-each select="current-group()[1]">
                                                            <xsl:variable name="elementId" select="@elementId"/>
                                                            <xsl:variable name="elementAnchor" select="local:doHtmlAnchor($elementId, ())"/>
                                                            <div style="background-color: #FFEAEA;">
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'conceptTemplateAssocLine_1'"/>
                                                                </xsl:call-template>
                                                                <xsl:text> </xsl:text>
                                                                <i>
                                                                    <a href="{local:doHtmlName('TM', $xref, $xflex, '.html')}#{$elementAnchor}" onclick="target='_blank';">
                                                                        <xsl:choose>
                                                                            <xsl:when test="$rccontent[1][@displayName]">
                                                                                <xsl:value-of select="$rccontent[1]/@displayName"/>
                                                                            </xsl:when>
                                                                            <xsl:otherwise>
                                                                                <xsl:value-of select="$rccontent[1]/@name"/>
                                                                            </xsl:otherwise>
                                                                        </xsl:choose>
                                                                        <xsl:if test="$rccontent[1]/@versionLabel">
                                                                            <xsl:text> (</xsl:text>
                                                                            <xsl:value-of select="$rccontent[1]/@versionLabel"/>
                                                                            <xsl:text>)</xsl:text>
                                                                        </xsl:if>
                                                                    </a>
                                                                </i>
                                                                <xsl:text> </xsl:text>
                                                                <xsl:call-template name="getMessage">
                                                                    <xsl:with-param name="key" select="'conceptTemplateAssocLine_2'"/>
                                                                    <xsl:with-param name="p1">
                                                                        <xsl:call-template name="showDate">
                                                                            <xsl:with-param name="date" select="$xflex"/>
                                                                        </xsl:call-template>
                                                                    </xsl:with-param>
                                                                    <xsl:with-param name="p2">
                                                                        <xsl:variable name="elementAttribute" select="$rccontent//*[@id = $elementId]"/>
                                                                        <xsl:choose>
                                                                            <xsl:when test="$elementAttribute[self::element]">
                                                                                <xsl:value-of select="$elementAttribute/@name"/>
                                                                                <xsl:text> </xsl:text>
                                                                                <xsl:value-of select="local:getCardConf($elementAttribute, $defaultLanguage)"/>
                                                                            </xsl:when>
                                                                            <xsl:when test="$elementAttribute[self::attribute]">
                                                                                <xsl:variable name="attribute" as="element()*">
                                                                                    <xsl:apply-templates select="$elementAttribute" mode="NORMALIZE"/>
                                                                                </xsl:variable>
                                                                                <xsl:value-of select="$attribute[1]/@name"/>
                                                                                <xsl:text> </xsl:text>
                                                                                <xsl:value-of select="local:getCardConf($elementAttribute[1], $defaultLanguage)"/>
                                                                            </xsl:when>
                                                                        </xsl:choose>
                                                                    </xsl:with-param>
                                                                </xsl:call-template>
                                                            </div>
                                                        </xsl:for-each>
                                                    </xsl:for-each-group>
                                                </xsl:for-each>
                                                <!-- Display datasets -->
                                                <xsl:for-each select="$assocDatasets">
                                                    <div style="background-color: #FFEAEA;">
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'conceptDatasetAssocLine_1'"/>
                                                        </xsl:call-template>
                                                        <xsl:text> </xsl:text>
                                                        <i>
                                                            <xsl:variable name="adsid" select="ancestor::dataset/@id"/>
                                                            <xsl:variable name="adsed" select="ancestor::dataset/@effectiveDate"/>
                                                            <xsl:variable name="adeid" select="parent::concept/(@id | @ref)"/>
                                                            <xsl:variable name="adeed" select="parent::concept/(@effectiveDate | @flexibility)"/>
                                                            <xsl:variable name="conceptAnchor" select="local:doHtmlAnchor($adeid, $adeed)"/>
                                                            <a href="{local:doHtmlName('DS', $projectPrefix, $adsid, $adsed, $adeid, $adeed, (), (), '.html', false())}">
                                                                <!-- No need to open new tab/window when target is self. -->
                                                                <xsl:choose>
                                                                    <xsl:when test=".[$adsid = $dsid][$adsed = $dsed]"/>
                                                                    <xsl:otherwise>
                                                                        <xsl:attribute name="onclick">target='_blank';</xsl:attribute>
                                                                    </xsl:otherwise>
                                                                </xsl:choose>
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="$conceptName"/>
                                                                </xsl:call-template>
                                                                <xsl:if test="parent::concept/@versionLabel">
                                                                    <xsl:text> (</xsl:text>
                                                                    <xsl:value-of select="parent::concept/@versionLabel"/>
                                                                    <xsl:text>)</xsl:text>
                                                                </xsl:if>
                                                            </a>
                                                        </i>
                                                        <xsl:text> </xsl:text>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'conceptDatasetAssocLine_2'"/>
                                                            <xsl:with-param name="p1">
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="ancestor::dataset/name"/>
                                                                </xsl:call-template>
                                                                <xsl:if test="ancestor::dataset/@versionLabel">
                                                                    <xsl:text> (</xsl:text>
                                                                    <xsl:value-of select="ancestor::dataset/@versionLabel"/>
                                                                    <xsl:text>)</xsl:text>
                                                                </xsl:if>
                                                            </xsl:with-param>
                                                        </xsl:call-template>
                                                    </div>
                                                </xsl:for-each>
                                            </div>
                                        </td>
                                    </tr>
                                </xsl:if>
                                <xsl:variable name="hccount" select="count(history)"/>
                                <xsl:if test="$hccount &gt; 0">
                                    <tr>
                                        <td style="vertical-align: top; text-align: left;">
                                            <xsl:call-template name="showIcon">
                                                <xsl:with-param name="which">blueclock</xsl:with-param>
                                            </xsl:call-template>
                                        </td>
                                        <td colspan="2">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'historicDefinition'"/>
                                                <xsl:with-param name="p1" select="$hccount"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:if>
                            </table>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="logMessage">
                                <xsl:with-param name="level" select="$logWARN"/>
                                <xsl:with-param name="msg">
                                    <xsl:text>+++ not processing dataset concept that does not have an @id or inherit/@id "</xsl:text>
                                    <xsl:copy copy-namespaces="no">
                                        <xsl:copy-of select="@*" copy-namespaces="no"/>
                                    </xsl:copy>
                                    <xsl:text>"</xsl:text>
                                </xsl:with-param>
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                </td>
                <td/>
            </tr>
            <xsl:apply-templates select="concept" mode="dataset">
                <xsl:with-param name="level" select="$level + 1"/>
                <xsl:with-param name="nestingWithTables" select="$nestingWithTables"/>
                <xsl:with-param name="seed" select="$seed"/>
                <xsl:with-param name="dsid" select="$dsid"/>
                <xsl:with-param name="dsed" select="$dsed"/>
                <xsl:with-param name="trid" select="$trid"/>
                <xsl:with-param name="tred" select="$tred"/>
            </xsl:apply-templates>
        </xsl:if>
    </xsl:template>
    <xsl:template name="doObligation" match="*">
        <xsl:param name="ns" select="obligation" as="element()+"/>
        
        <xsl:if test="$ns">
            <xsl:variable name="doName" select="$ns/name"/>
            <xsl:variable name="doUsage" select="$ns/usage"/>
            <xsl:variable name="cols" select="if ($doName and $doUsage) then 4 else if ($doName or $doUsage) then 3 else 2"/>
            
            <table border="0" cellspacing="3" cellpadding="2">
                <tr style="border-spacing: 0; border: 0">
                    <xsl:if test="$doName">
                        <th>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'columnName'"/>
                            </xsl:call-template>
                        </th>
                    </xsl:if>
                    <th>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Obligation'"/>
                        </xsl:call-template></th>
                    <th>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Actor'"/>
                        </xsl:call-template>
                    </th>
                    <xsl:if test="$doUsage">
                        <th>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'Context'"/>
                            </xsl:call-template>
                        </th>
                    </xsl:if>
                </tr>
                <xsl:for-each select="$ns">
                    <tr style="border-spacing: 0; border: 0">
                        <xsl:variable name="cs" select="code"/>
                        <xsl:variable name="usage" select="usage"/>
                        <xsl:if test="$doName">
                            <td style="border: 0; border-top: 1px solid black;">
                                <xsl:call-template name="doName">
                                    <xsl:with-param name="ns" select="name"/>
                                </xsl:call-template>
                            </td>
                        </xsl:if>
                        <td style="border: 0; border-top: 1px solid black;">
                            <xsl:variable name="litems" as="element(li)*">
                                <xsl:for-each select="$cs">
                                    <li>
                                        <xsl:value-of select="@code"/>
                                    </li>
                                </xsl:for-each>
                            </xsl:variable>
                            <xsl:choose>
                                <xsl:when test="count($litems) = 0"/>
                                <xsl:when test="count($litems) = 1">
                                    <xsl:copy-of select="$litems/node()"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <ul>
                                        <xsl:copy-of select="$litems"/>
                                    </ul>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                        <td style="border: 0; border-top: 1px solid black;">
                            <xsl:variable name="litems" as="element(li)+">
                                <xsl:choose>
                                    <xsl:when test="actor">
                                        <xsl:variable name="acid" select="distinct-values(actor/@ref)"/>
                                        <xsl:for-each select="$allActors//actor[@id = $acid]">
                                            <li>
                                                <xsl:call-template name="doName">
                                                    <xsl:with-param name="ns" select="name"/>
                                                </xsl:call-template>
                                            </li>
                                        </xsl:for-each>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <li>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'All'"/>
                                            </xsl:call-template>
                                        </li>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:variable>
                            <xsl:choose>
                                <xsl:when test="count($litems) = 0"/>
                                <xsl:when test="count($litems) = 1">
                                    <xsl:copy-of select="$litems/node()"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <ul>
                                        <xsl:copy-of select="$litems"/>
                                    </ul>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                        <xsl:if test="$doUsage">
                            <td style="border: 0; border-top: 1px solid black;">
                                <xsl:variable name="litems" as="element(li)*">
                                    <xsl:for-each select="usage">
                                        <li>
                                            <xsl:value-of select="code/(@displayName, @code)[1]"/>
                                            <xsl:text>: </xsl:text>
                                            <xsl:choose>
                                                <xsl:when test="valueCoding">
                                                    <xsl:value-of select="valueCoding/(@displayName, @code)[1]"/>
                                                </xsl:when>
                                                <xsl:when test="valueQuantity">
                                                    <xsl:value-of select="valueQuantity/string-join((@comparator, @value, (@unit, @code)[1]), ' ')"/>
                                                </xsl:when>
                                                <xsl:when test="valueRange">
                                                    <xsl:variable name="vl" select="valueRange/low"/>
                                                    <xsl:variable name="vh" select="valueRange/high"/>
                                                    <xsl:choose>
                                                        <xsl:when test="$vl/@code = $vh/@code or $vl/@unit = $vh/@unit">
                                                            <xsl:value-of select="string-join(($vl/string-join((@comparator, @value), ' ')[not(. = '')], $vh/string-join((@comparator, @value, (@unit, @code)[1]), ' ')[not(. = '')]), ' - ')"/>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <xsl:value-of select="string-join(($vl/string-join((@comparator, @value, (@unit, @code)[1]), ' ')[not(. = '')], $vh/string-join((@comparator, @value, (@unit, @code)[1]), ' ')[not(. = '')]), ' - ')"/>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:when>
                                            </xsl:choose>
                                        </li>
                                    </xsl:for-each>
                                </xsl:variable>
                                <xsl:choose>
                                    <xsl:when test="count($litems) = 0"/>
                                    <xsl:when test="count($litems) = 1">
                                        <xsl:copy-of select="$litems/node()"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <ul>
                                            <xsl:copy-of select="$litems"/>
                                        </ul>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                        </xsl:if>
                    </tr>
                    <xsl:if test="desc">
                        <tr style="border: 0">
                            <td style="border: 0; border-bottom: 1px solid black;"> </td>
                            <td style="border: 0; border-bottom: 1px solid black;" colspan="{$cols - 1}">
                                <xsl:call-template name="doDescription">
                                    <xsl:with-param name="ns" select="desc"/>
                                </xsl:call-template>
                            </td>
                        </tr>
                    </xsl:if>
                </xsl:for-each>
            </table>
        </xsl:if>
    </xsl:template>
    <xsl:template match="concept" mode="filter">
        <xsl:param name="representingTemplate"/>
        <!-- 
            copy filtered concept (concept data is taken from allDatasetConceptsFlat as they are already de-refed)
        -->
        <!-- cache current concept id and effectiveDate -->
        <xsl:variable name="cid" select="@id"/>
        <xsl:variable name="ceff" select="@effectiveDate"/>
        <!-- de-ref'd concept -->
        <xsl:variable name="theConcept" select="local:getConceptFlat($cid, $ceff)" as="element(concept)?"/>
        <xsl:variable name="theTransactionConcept" select="$representingTemplate/concept[@ref = $cid]" as="element(concept)*"/>
        <!-- make a copy of the concept data -->
        <concept xmlns="">
            <!-- copy attributes -->
            <xsl:copy-of select="$theConcept/@*"/>
            <xsl:if test="empty($theTransactionConcept)">
                <!-- set hidden flag for this concept if not present -->
                <xsl:attribute name="hidden" select="'true'"/>
            </xsl:if>
            <xsl:if test="$theTransactionConcept">
                <!-- concept present, copy cardinality conformance if present -->
                <xsl:copy-of select="$theTransactionConcept/(@minimumMultiplicity | @maximumMultiplicity | @isMandatory | @conformance | @enableBehavior)"/>
                <!-- copy conditions of conditional concept as conditionalConcept -->
                <xsl:for-each select="$theTransactionConcept/condition">
                    <conditionalConcept>
                        <xsl:copy-of select="@*"/>
                        <xsl:copy-of select="node()"/>
                    </conditionalConcept>
                </xsl:for-each>
                <!-- context | terminologyAssociation | identifierAssociation | enableWhen -->
                <xsl:copy-of select="$theTransactionConcept/* except condition"/>
            </xsl:if>
            <!-- copy all elements of the concept, no sub-concepts are copied (done later recursively), no history and no valueSet (done later) -->
            <xsl:for-each select="$theConcept/(* except (history | valueSet))">
                <xsl:choose>
                    <xsl:when test="$theTransactionConcept[terminologyAssociation | identifierAssociation] and .[self::terminologyAssociation | self::identifierAssociation]">
                        <!-- Don't copy concept terminologyAssociation | identifierAssociation if trasnsaction has them -->
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:copy-of select="."/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
            <!-- if there is a valueSet, it will contain the terminologyAssociation it was based on. copy valueSet only if that 
                terminologyAssociation refers to as @conceptId that the transaction concept does not have a terminologyAssociation for
            -->
            <xsl:for-each select="$theConcept/valueSet">
                <xsl:variable name="conceptId" select="terminologyAssociation/@conceptId"/>
                <xsl:variable name="matchingTransactionAssociation" select="$theTransactionConcept/*[@conceptId = $conceptId]"/>
                
                <xsl:if test="empty($matchingTransactionAssociation)">
                    <xsl:copy-of select="."/>
                </xsl:if>
            </xsl:for-each>
            <!-- process subconcepts -->
            <xsl:apply-templates select="concept" mode="filter">
                <xsl:with-param name="representingTemplate" select="$representingTemplate"/>
            </xsl:apply-templates>
        </concept>
    </xsl:template>
    <xsl:template match="concept" mode="eliminatedHiddenConcepts">
        <!--
             return the concept item 
             - if it is NOT a historic concept not(ancestor::history)
             - if it is NOT a concept of a conceptList not(ancestor::conceptList)
             - if it is not hidden not(@hidden)
        -->
        <xsl:if test="descendant-or-self::concept[not(ancestor::history | ancestor::conceptList)][not(@hidden)]">
            <xsl:copy>
                <xsl:copy-of select="@*"/>
                <xsl:copy-of select="* except (concept | history)"/>
                <xsl:apply-templates select="concept" mode="eliminatedHiddenConcepts"/>
            </xsl:copy>
        </xsl:if>
    </xsl:template>
    <xsl:template name="doIdentifierAssociations">
        <xsl:param name="in" as="element(identifierAssociation)*"/>
        
        <xsl:if test="$in">
            <tr xmlns="http://www.w3.org/1999/xhtml">
                <td style="vertical-align: top;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'identifierSystemList'"/>
                    </xsl:call-template>
                </td>
                <td class="tabtab" style="vertical-align: top;" colspan="2">
                    <table width="100%" border="0" cellspacing="3" cellpadding="2">
                        <xsl:for-each-group select="$in" group-by="concat(@ref, @expirationDate)">
                            <xsl:sort select="current-grouping-key()"/>
                            <xsl:variable name="theEffectiveDate" select="current-group()[1]/@effectiveDate"/>
                            <xsl:variable name="theExpirationDate" select="current-group()[1]/@expirationDate"/>
                            <xsl:variable name="expiredLook">
                                <xsl:if test="$theExpirationDate castable as xs:dateTime and xs:dateTime($theExpirationDate) &lt;= current-dateTime()">text-decoration: line-through;</xsl:if>
                            </xsl:variable>
                            <tr>
                                <td style="vertical-align: top; background-color: #FFEAFF; {$expiredLook}">
                                    <xsl:value-of select="current-group()/@ref"/>
                                </td>
                                <td style="vertical-align: top;">
                                    <xsl:value-of select="(@refdisplay, @ref)[1]"/>
                                    <xsl:if test="$theExpirationDate">
                                        <xsl:text> (</xsl:text>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'toY'"/>
                                        </xsl:call-template>
                                        <xsl:call-template name="showDate">
                                            <xsl:with-param name="date" select="$theExpirationDate"/>
                                        </xsl:call-template>
                                        <xsl:text>)</xsl:text>
                                    </xsl:if>
                                </td>
                            </tr>
                        </xsl:for-each-group>
                    </table>
                </td>
            </tr>
        </xsl:if>
    </xsl:template>
    <xsl:template match="conceptList">
        <!--
            if conceptList has no @ref (ie and @id or neither an @id nor a @ref)
            show concept list with all concepts and exceptions
            if conceptList has a @ref then first resolve the @ref within the current dataset
            and then show concept list with all concepts and exceptions
        -->
        <!-- get the right list -->
        <xsl:variable name="clid" select="(@id | @ref)[last()]"/>
        <xsl:variable name="theConceptList" as="element(conceptList)*">
            <xsl:choose>
                <!-- a @ref, resolve first, then process -->
                <xsl:when test="@ref">
                    <xsl:copy-of select="local:getConceptOrConceptList(@ref, ())"/>
                </xsl:when>
                <!-- otherwise simply make a copy and process it -->
                <xsl:otherwise>
                    <xsl:copy-of select="."/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="currentTerminologyAssociations" as="element()*">
            <xsl:choose>
                <xsl:when test="ancestor::concept[1]/terminologyAssociation[@conceptId = ($clid | $theConceptList/concept/@id)]">
                    <!-- Match any association with a @code, that does not match any of the valueDomain concepts. When the decor file is compiled, $originalConcept 
                                                will not have anything useful so this is an indirect method to get to the right stuff -->
                    <xsl:copy-of select="ancestor::concept[1]/terminologyAssociation[@conceptId = ($clid | $theConceptList/concept/@id)]"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:copy-of select="$allTerminologyAssociations/*/terminologyAssociation[@conceptId = ($clid | $theConceptList/concept/@id)]"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:if test="$theConceptList/concept[name] or $currentTerminologyAssociations[@valueSet]">
            <xsl:variable name="doLevelType" select="exists($theConceptList/concept[@level | @type])" as="xs:boolean"/>
            <xsl:variable name="doSynonyms" select="exists($theConceptList/concept[name]/synonym[@language = $defaultLanguage])" as="xs:boolean"/>
            <xsl:variable name="doAssociations" select="exists($currentTerminologyAssociations[@conceptId = $theConceptList/concept[name]/@id])" as="xs:boolean"/>
            <xsl:variable name="theColspan" select="2 + count(($doLevelType, $doAssociations, $doSynonyms)[. = true()])" as="xs:integer"/>
            <tr xmlns="http://www.w3.org/1999/xhtml">
                <td style="vertical-align: top;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'choiceList'"/>
                    </xsl:call-template>
                </td>
                <td class="tabtab" style="vertical-align: top;" colspan="2">
                    <table width="100%" border="0" cellspacing="3" cellpadding="2">
                        <tr class="headinglabel">
                            <th colspan="{$theColspan}">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'ConceptList'"/>
                                </xsl:call-template>
                            </th>
                        </tr>
                        <xsl:if test="$theConceptList/concept[name]">
                            <tr style="background-color: #F6F3EE;">
                                <xsl:if test="$doLevelType">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'LevelSlashType'"/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:if>
                                <td>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'choiceListConcept'"/>
                                    </xsl:call-template>
                                </td>
                                <xsl:if test="$doSynonyms">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Synonyms'"/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:if>
                                <td>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'choiceListDescription'"/>
                                    </xsl:call-template>
                                </td>
                                <xsl:if test="$doAssociations">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'choiceListResolvedRefs'"/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:if>
                            </tr>
                            <xsl:for-each select="$theConceptList/concept[name]">
                                <xsl:variable name="cid" select="@id"/>
                                <xsl:variable name="css-margin" select="if (@level castable as xs:integer) then concat('padding-left: ',number(@level) * 15,'px;') else ()"/>
                                <xsl:variable name="css-font" select="if (@type) then concat('concepttype', @type) else ()"/>
                                <tr>
                                    <xsl:if test="$doLevelType">
                                        <td style="vertical-align: top;">
                                            <xsl:if test=".[@level | @type]">
                                                <xsl:value-of select="concat(@level, '-', @type)"/>
                                            </xsl:if>
                                        </td>
                                    </xsl:if>
                                    <td class="{$css-font}" style="vertical-align: top;{$css-margin}">
                                        <xsl:call-template name="doName">
                                            <xsl:with-param name="ns" select="name"/>
                                        </xsl:call-template>
                                    </td>
                                    <xsl:if test="$doSynonyms">
                                        <td style="vertical-align: top;">
                                            <xsl:for-each select="synonym[@language = $defaultLanguage]">
                                                <div>
                                                    <xsl:value-of select="."/>
                                                </div>
                                            </xsl:for-each>
                                        </td>
                                    </xsl:if>
                                    <td style="vertical-align: top;">
                                        <xsl:if test="@exception = 'true'">
                                            <div>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'exceptionalConcept'"/>
                                                </xsl:call-template>
                                            </div>
                                        </xsl:if>
                                        <xsl:if test="@ordinal[not(.= '')]">
                                            <div>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'Ordinal'"/>
                                                </xsl:call-template>
                                                <xsl:text>: </xsl:text>
                                                <xsl:value-of select="@ordinal"/>
                                            </div>
                                        </xsl:if>
                                        <xsl:call-template name="doDescription">
                                            <xsl:with-param name="ns" select="desc"/>
                                        </xsl:call-template>
                                    </td>
                                    <xsl:if test="$doAssociations">
                                        <td style="vertical-align: top;">
                                            <!--xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'toBeDetermined'"/>
                                            </xsl:call-template-->
                                            <!-- 2DO check if assumption on code/codeSystem is correct -->
                                            <xsl:for-each-group select="$currentTerminologyAssociations[@conceptId = $cid]" group-by="concat(@code, @codeSystem)">
                                                <xsl:variable name="css-margin" select="concat('padding-left: ',number(current-group()[1]/@level) * 15,'px;')"/>
                                                <xsl:variable name="css-font" select="if (@type) then concat('concepttype', current-group()[1]/@type) else if (local-name() = 'exclude') then ('concepttypeD') else ()"/>
                                                <xsl:variable name="theCode" select="current-group()[1]/@code"/>
                                                <xsl:variable name="theCodeSystem" select="current-group()[1]/@codeSystem"/>
                                                <xsl:variable name="theDisplayName" select="current-group()[1]/@displayName"/>
                                                <xsl:variable name="theOrdinal" select="current-group()[1]/@ordinal"/>
                                                <xsl:variable name="theCodeSystemName">
                                                    <xsl:variable name="theCSN" as="xs:string*">
                                                        <xsl:call-template name="getIDDisplayName">
                                                            <xsl:with-param name="root" select="current-group()[1]/@codeSystem"/>
                                                        </xsl:call-template>
                                                    </xsl:variable>
                                                    <xsl:choose>
                                                        <xsl:when test="empty($theCSN)">
                                                            <xsl:value-of select="(current-group()/@codeSystemName)[1]"/>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <xsl:value-of select="$theCSN"/>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </xsl:variable>
                                                <xsl:variable name="theExpirationDate" select="current-group()[1]/@expirationDate"/>
                                                <xsl:variable name="expiredLook">
                                                    <xsl:if test="$theExpirationDate castable as xs:dateTime and xs:dateTime($theExpirationDate) &lt;= current-dateTime()">text-decoration: line-through;</xsl:if>
                                                </xsl:variable>
                                                <div class="{$css-font}" style="{$expiredLook}{$css-margin}">
                                                    <xsl:choose>
                                                        <xsl:when test="string-length($theDisplayName) gt 0">
                                                            <xsl:choose>
                                                                <xsl:when test="string-length($theOrdinal) gt 0">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'conceptInConceptListRepresentationLineWithDisplayAndOrdinal'"/>
                                                                        <xsl:with-param name="p1" select="$theCode"/>
                                                                        <xsl:with-param name="p2" select="($theCodeSystemName, $theCodeSystem)[string-length() gt 0][1]"/>
                                                                        <xsl:with-param name="p3" select="$theDisplayName"/>
                                                                        <xsl:with-param name="p4" select="$theOrdinal"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'conceptInConceptListRepresentationLineWithDisplay'"/>
                                                                        <xsl:with-param name="p1" select="$theCode"/>
                                                                        <xsl:with-param name="p2" select="($theCodeSystemName, $theCodeSystem)[string-length() gt 0][1]"/>
                                                                        <xsl:with-param name="p3" select="$theDisplayName"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <xsl:choose>
                                                                <xsl:when test="string-length($theOrdinal) gt 0">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'conceptInConceptListRepresentationLineWithOrdinal'"/>
                                                                        <xsl:with-param name="p1" select="$theCode"/>
                                                                        <xsl:with-param name="p2" select="($theCodeSystemName, $theCodeSystem)[string-length() gt 0][1]"/>
                                                                        <xsl:with-param name="p3" select="$theOrdinal"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'conceptInConceptListRepresentationLine'"/>
                                                                        <xsl:with-param name="p1" select="$theCode"/>
                                                                        <xsl:with-param name="p2" select="($theCodeSystemName, $theCodeSystem)[string-length() gt 0][1]"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                    <!--<xsl:if test="@effectiveDate | @expirationDate"> (</xsl:if>
                                                    <xsl:if test="@effectiveDate">
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'fromX'"/>
                                                        </xsl:call-template>
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="@effectiveDate"/>
                                                        </xsl:call-template>
                                                    </xsl:if>-->
                                                    <xsl:if test="$theExpirationDate">
                                                        <xsl:text> (</xsl:text>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'toY'"/>
                                                        </xsl:call-template>
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="$theExpirationDate"/>
                                                        </xsl:call-template>
                                                        <xsl:text>)</xsl:text>
                                                    </xsl:if>
                                                    <!--<xsl:if test="@effectiveDate | @expirationDate">)</xsl:if>-->
                                                </div>
                                            </xsl:for-each-group>
                                        </td>
                                    </xsl:if>
                                </tr>
                            </xsl:for-each>
                        </xsl:if>
                        <!-- show coded concept associations = value sets - if already defined -->
                        <xsl:for-each-group select="$currentTerminologyAssociations[@conceptId = $clid][@valueSet]" group-by="concat(@valueSet, @flexibility[. castable as xs:dateTime])">
                            <xsl:variable name="theStrength" select="if (current-group()[1][@strength = 'CNE']) then 'required' else if (current-group()[1][@strength = 'CWE']) then 'extensible' else (current-group()[1]/@strength)"/>
                            <xsl:variable name="theEffectiveDate" select="current-group()[1]/@effectiveDate"/>
                            <xsl:variable name="theExpirationDate" select="current-group()[1]/@expirationDate"/>
                            <xsl:variable name="expiredLook">
                                <xsl:if test="$theExpirationDate castable as xs:dateTime and xs:dateTime($theExpirationDate) &lt;= current-dateTime()">text-decoration: line-through;</xsl:if>
                            </xsl:variable>
                            <xsl:variable name="xvsref" select="current-group()[1]/@valueSet"/>
                            <xsl:variable name="xvsflex" select="
                                    if (current-group()[1]/@flexibility) then
                                        (current-group()[1]/@flexibility)
                                    else
                                        ('dynamic')"/>
                            <xsl:variable name="xvs">
                                <xsl:call-template name="getValueset">
                                    <xsl:with-param name="reference" select="$xvsref"/>
                                    <xsl:with-param name="flexibility" select="$xvsflex"/>
                                </xsl:call-template>
                            </xsl:variable>
                            <xsl:variable name="xvsid" select="($xvs/valueSet)[1]/@id"/>
                            <xsl:variable name="xvsdn" select="
                                    if (($xvs/valueSet)[1]/@displayName) then
                                        (($xvs/valueSet)[1]/@displayName)
                                    else
                                        (($xvs/valueSet)[1]/@name)"/>
                            <tr>
                                <td colspan="{$theColspan}">
                                    <hr/>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="{$theColspan}" style="vertical-align: top; background-color: #FFEAFF; {$expiredLook}">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'valueSet'"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <xsl:if test="not(empty($theStrength))">
                                        <span>
                                            <xsl:attribute name="title">
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="concat('bindingStrength-', $theStrength, '-help')"/>
                                                </xsl:call-template>
                                            </xsl:attribute>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="concat('bindingStrength-', $theStrength)"/>
                                            </xsl:call-template>
                                        </span>
                                    </xsl:if>
                                    <xsl:text> </xsl:text>
                                    <i>
                                        <a href="{local:doHtmlName('VS',$xvsid,$xvsflex,'.html')}" onclick="target='_blank';">
                                            <xsl:value-of select="if ($xvsdn) then ($xvsdn) else ($xvsref)"/>
                                        </a>
                                    </i>
                                    <xsl:text> (</xsl:text>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'version'"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <xsl:choose>
                                        <xsl:when test="matches($xvsflex, '^\d{4}')">
                                            <xsl:call-template name="showDate">
                                                <xsl:with-param name="date" select="$xvsflex"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                    <xsl:text>)</xsl:text>
                                    <!--<xsl:if test="$theEffectiveDate | $theExpirationDate"> (</xsl:if>-->
                                    <!--<xsl:if test="$theEffectiveDate">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'fromX'"/>
                                        </xsl:call-template>
                                        <xsl:call-template name="showDate">
                                            <xsl:with-param name="date" select="$theEffectiveDate"/>
                                        </xsl:call-template>
                                    </xsl:if>-->
                                    <xsl:if test="$theExpirationDate">
                                        <xsl:text> (</xsl:text>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'toY'"/>
                                        </xsl:call-template>
                                        <xsl:call-template name="showDate">
                                            <xsl:with-param name="date" select="$theExpirationDate"/>
                                        </xsl:call-template>
                                        <xsl:text>)</xsl:text>
                                    </xsl:if>
                                    <!--<xsl:if test="$theEffectiveDate | $theExpirationDate">)</xsl:if>-->
                                    <!--<xsl:if test="not($theEffectiveDate or $theExpirationDate)">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'terminologyAssociationDYNAMIC'"/>
                                        </xsl:call-template>
                                    </xsl:if>-->
                                </td>
                            </tr>
                        </xsl:for-each-group>
                    </table>
                </td>
            </tr>
        </xsl:if>
    </xsl:template>
    <xsl:template match="valueSet">
        <xsl:param name="doMultiple" select="false()" as="xs:boolean"/>
        <!-- language, not yet used -->
        <xsl:param name="language"/>
        <!-- whether to show other versions of this value set at the end as a list, default is true -->
        <xsl:param name="showOtherVersionsList" select="true()"/>
        <xsl:variable name="vsname" select="@name"/>
        <xsl:variable name="vsid" select="(@id | @ref)"/>
        <xsl:variable name="vsed" select="@effectiveDate"/>
        <!-- When the list of concepts is big, the performance in finding the parent node degrades so significant that it is better not to -->
        <xsl:variable name="doNesting" select="count(conceptList/*) &lt;= 1000"/>
        <xsl:variable name="doOrdinal" select="if (conceptList/*[@ordinal]) then 1 else 0"/>
        <xsl:variable name="doCodeSystemVersion" select="if (conceptList/*[@codeSystemVersion]) then 1 else 0"/>
        <xsl:variable name="doDesignation" select="if (conceptList/*[designation]) then 1 else 0"/>
        <xsl:variable name="doDesc" select="if (conceptList/*[desc]) then 1 else 0"/>
        <xsl:variable name="fWidth" select="'20em'"/>
        <xsl:variable name="numcol" select="4"/>
        <xsl:variable name="numcolcodes" select="4 + $doOrdinal + $doCodeSystemVersion + $doDesignation + $doDesc"/>
        <table xmlns="http://www.w3.org/1999/xhtml" width="100%" border="0" cellspacing="3" cellpadding="2">
            <!-- added KH and AH 20220815: warning texts on publications that this terminology is a snapshot -->
            <xsl:if test="conceptList[*] and string-length($adram) > 0">
                <tr class="desclabel">
                    <td colspan="{$numcol}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'PublicationWarningBeUp2Date'"/>
                            <xsl:with-param name="p1">
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="$latestVersionOrRelease/@date"/>
                                </xsl:call-template>
                            </xsl:with-param>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- end added KH and AH 20220815 -->
            <!-- id / effectiveDate -->
            <tr style="vertical-align: top;">
                <!-- id -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Id'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:variable name="ident" select="(@ident, ../@ident)[1]"/>
                    <xsl:variable name="url" select="(@url, ../@url)[1]"/>
                    <xsl:choose>
                        <!-- In live ART-DECOR you can just go there, but in an offline publication, we cannot jump to a different publication location -->
                        <xsl:when test="$url and not(empty($projectPrefix)) and $ident[not(. = $projectPrefix)] and $seeThisUrlLocation = ('live', 'live-vue')">
                            <a href="{local:doHtmlName('VS',$url,$ident,$vsid,$vsed,(),(),(),(),'.html',false())}" onclick="target='_blank';">
                                <xsl:value-of select="$vsid"/>
                            </a>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$vsid"/>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                </td>
                <!-- version information -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'effectiveDate'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:if test="@effectiveDate[string-length() &gt; 0]">
                        <!--<xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'templateValidFrom'"/>
                        </xsl:call-template>-->
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="@effectiveDate"/>
                        </xsl:call-template>
                    </xsl:if>
                    <xsl:if test="@expirationDate[string-length() &gt; 0]">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'templateValidTo'"/>
                        </xsl:call-template>
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="@expirationDate"/>
                        </xsl:call-template>
                    </xsl:if>
                    <!-- Summarize other versions of this valueSet -->
                    <xsl:if test="$showOtherVersionsList = true()">
                        <xsl:variable name="otherVersions" select="$allValueSets/*/valueSet[@name = $vsname or @id = $vsid][@effectiveDate[not(. = $vsed)]]" as="element()*"/>
                        <xsl:if test="$otherVersions">
                            <div>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'OtherVersionsWithThisId'"/>
                                </xsl:call-template>
                                <ul>
                                    <xsl:for-each-group select="$otherVersions" group-by="concat(@id, @effectiveDate)">
                                        <xsl:sort select="@effectiveDate" order="descending"/>
                                        <xsl:for-each select="current-group()[1]">
                                            <li>
                                                <xsl:call-template name="showStatusDot">
                                                    <xsl:with-param name="status" select="@statusCode"/>
                                                    <xsl:with-param name="title">
                                                        <xsl:call-template name="getXFormsLabel">
                                                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                        </xsl:call-template>
                                                    </xsl:with-param>
                                                </xsl:call-template>
                                                <xsl:text> </xsl:text>
                                                <a href="{local:doHtmlName('VS', @id, @effectiveDate, '.html')}" onclick="target='_blank';">
                                                    <xsl:value-of select="(@displayName, @name)[1]"/>
                                                </a>
                                                <xsl:if test="@versionLabel">
                                                    <xsl:value-of select="@versionLabel"/>
                                                    <xsl:text> - </xsl:text>
                                                </xsl:if>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'xAsOfy'"/>
                                                </xsl:call-template>
                                                <xsl:text> </xsl:text>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="@effectiveDate"/>
                                                </xsl:call-template>
                                                <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                            </li>
                                        </xsl:for-each>
                                    </xsl:for-each-group>
                                </ul>
                            </div>
                        </xsl:if>
                    </xsl:if>
                </td>
            </tr>
            <!-- HL7 FHIR URI -->
            <xsl:if test="@canonicalUri">
                <tr style="vertical-align: top;">
                    <!-- fhir uri -->
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'canonicalUri'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:value-of select="@canonicalUri"/>
                    </td>
                </tr>
            </xsl:if>
            <!-- status / versionLabel -->
            <tr style="vertical-align: top;">
                <!-- status -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Status'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:call-template name="showStatusDot">
                        <xsl:with-param name="status" select="@statusCode"/>
                        <xsl:with-param name="title">
                            <xsl:call-template name="getXFormsLabel">
                                <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                <xsl:with-param name="lang" select="$defaultLanguage"/>
                            </xsl:call-template>
                        </xsl:with-param>
                    </xsl:call-template>
                    <xsl:text> </xsl:text>
                    <xsl:call-template name="getXFormsLabel">
                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                    </xsl:call-template>
                </td>
                <!-- versionLabel -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'columnVersionLabel'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@versionLabel"/>
                </td>
            </tr>
            <!-- experimental -->
            <xsl:if test="@experimental = 'true'">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'experimental'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'yes'"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- name / displayName -->
            <tr style="vertical-align: top;">
                <!-- name -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Name'"/>
                    </xsl:call-template>
                    <!--<xsl:if test="count(context) = 0">
                        <!-\- no context means: internal template -\->
                        <xsl:text> (</xsl:text>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'internal'"/>
                        </xsl:call-template>
                        <xsl:text>)</xsl:text>
                    </xsl:if>-->
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@name"/>
                </td>
                <!-- displayName -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'DisplayName'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@displayName"/>
                </td>
            </tr>
            <!-- description if given -->
            <xsl:if test="desc[.//text()[string-length(normalize-space()) gt 0]]">
                <tr style="vertical-align: top;">
                    <xsl:choose>
                        <xsl:when test="desc[string-length(string-join(descendant-or-self::text(), ' ')) > 200]">
                            <td style="text-align: left;" colspan="{$numcol}">
                                <xsl:variable name="elid" select="local:randomString2(., ())"/>
                                <!--<xsl:variable name="elidtoggler" select="concat('toggler-', $elid)"/>-->
                                <table id="valueSetDescTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                                    <tr class="desclabel" data-tt-id="valueSetDescHeader">
                                        <td class="togglertreetable" style="height: 1.5em;">
                                            <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                <xsl:attribute name="class" select="'toggler'"/>
                                                <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                            </xsl:if>
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'templateDescription'"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                    <tr data-tt-id="valueSetDescBody" data-tt-parent-id="valueSetDescHeader">
                                        <td>
                                            <div id="{$elid}">
                                                <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                    <xsl:attribute name="class" select="'toggle'"/>
                                                </xsl:if>
                                                <xsl:call-template name="doDescription">
                                                    <xsl:with-param name="ns" select="desc"/>
                                                </xsl:call-template>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </xsl:when>
                        <xsl:otherwise>
                            <th style="width: {$fWidth}; text-align: left;">
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'templateDescription'"/>
                                </xsl:call-template>
                            </th>
                            <td style="text-align: left;" colspan="{$numcol - 1}">
                                <xsl:call-template name="doDescription">
                                    <xsl:with-param name="ns" select="desc"/>
                                </xsl:call-template>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>
                </tr>
            </xsl:if>
            <!-- handle copyright -->
            <xsl:for-each-group select="copyright" group-by="@language">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Copyright'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="."/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:for-each-group>
            <!-- handle usage -->
            <!-- Don't do this for live or 'live-services' as those would either be under an xforms representation of this usage so html would duplicate stuff or the calculation would be inaccurate i.e. missing stuff -->
            <xsl:if test="not($seeThisUrlLocation = ('live', 'live-services', 'live-vue', 'live-services-vue'))">
                <xsl:variable name="valueSetIsNewest" select="string(max($allDECOR//valueSet[@id = $vsid]/xs:dateTime(@effectiveDate))) = $vsed" as="xs:boolean"/>
                <!-- This only works in compiled projects. Calculation on uncompiled projects is next to impossible because the terminologyAssociation is on a conceptList that might be in a different project -->
                <xsl:variable name="datasetConceptUsage" select="$allDECOR//dataset//concept[valueSet[@id = $vsid][@effectiveDate = $vsed]]" as="element()*"/>
                <xsl:variable name="transactionConceptUsage" select="
                        $allDECOR//transaction//concept[valueSet[@id = $vsid][@effectiveDate = $vsed]] |
                        $allDECOR//transaction//concept[terminologyAssociation[$valueSetIsNewest][@valueSet = $vsid][not(@flexibility castable as xs:dateTime)]]" as="element()*"/>
                <xsl:variable name="templateUsage" select="
                        $allDECOR//vocabulary[@valueSet = $vsid][@flexibility = $vsed] |
                        $allDECOR//vocabulary[$valueSetIsNewest][@valueSet = $vsid][not(@flexibility castable as xs:dateTime)]" as="element()*"/>
                <!-- Note: technically there could be valueSets including other valueSets, but these would be resolved in a compiled project hence no point in checking -->
                <xsl:if test="$datasetConceptUsage | $transactionConceptUsage | $templateUsage">
                    <xsl:variable name="elid" select="local:randomString2(., ())"/>
                    <tr style="vertical-align: top;">
                        <td colspan="{$numcol}">
                            <table id="valueSetUsageTable" class="treetable" width="100%" border="0" cellspacing="3" cellpadding="2">
                                <tr class="desclabel" data-tt-id="valueSetUsageTableHeader">
                                    <td class="togglertreetable" style="height: 1.5em;">
                                        <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                            <xsl:attribute name="class" select="'toggler'"/>
                                            <xsl:attribute name="onclick" select="concat('return toggleZoom(''', $elid, ''',this, ''', $theAssetsDir, ''')')"/>
                                        </xsl:if>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Usage'"/>
                                        </xsl:call-template>
                                        <xsl:text>: </xsl:text>
                                        <xsl:value-of select="count($datasetConceptUsage | $transactionConceptUsage | $templateUsage)"/>
                                    </td>
                                </tr>
                                <tr data-tt-id="valueSetUsageTableBody" data-tt-parent-id="valueSetUsageTableHeader">
                                    <td>
                                        <div id="{$elid}">
                                            <xsl:if test="not($switchCreateTreeTableHtml = 'true')">
                                                <xsl:attribute name="class" select="'toggle'"/>
                                            </xsl:if>
                                            <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                                <tr>
                                                    <th>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'Id'"/>
                                                        </xsl:call-template>
                                                    </th>
                                                    <th>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'Name'"/>
                                                        </xsl:call-template>
                                                    </th>
                                                    <th>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'Type'"/>
                                                        </xsl:call-template>
                                                    </th>
                                                </tr>
                                                <xsl:if test="$datasetConceptUsage">
                                                    <tr>
                                                        <th style="text-align: left;" colspan="3">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'Dataset'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                    </tr>
                                                </xsl:if>
                                                <xsl:for-each select="$datasetConceptUsage">
                                                    <tr>
                                                        <td>
                                                            <xsl:choose>
                                                                <xsl:when test="@iddisplay">
                                                                    <xsl:value-of select="@iddisplay"/>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="doShorthandId">
                                                                        <xsl:with-param name="id" select="@id"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </td>
                                                        <td>
                                                            <a href="{local:doHtmlName('DS', $projectPrefix, ancestor::dataset/@id, ancestor::dataset/@effectiveDate, @id, @effectiveDate, (), (), '.html', false())}" onclick="target='_blank';">
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="name"/>
                                                                </xsl:call-template>
                                                                <xsl:if test="@versionLabel">
                                                                    <xsl:text> (</xsl:text>
                                                                    <xsl:value-of select="@versionLabel"/>
                                                                    <xsl:text>)</xsl:text>
                                                                </xsl:if>
                                                            </a>
                                                        </td>
                                                        <td>
                                                            <xsl:choose>
                                                                <xsl:when test="terminologyAssociation[@valueSet = $vsid][@flexibility castable as xs:dateTime]">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'terminologyAssociationSTATIC'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'terminologyAssociationDYNAMIC'"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </td>
                                                    </tr>
                                                </xsl:for-each>
                                                <xsl:if test="$transactionConceptUsage">
                                                    <tr>
                                                        <th style="text-align: left;" colspan="3">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'Transaction'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                    </tr>
                                                </xsl:if>
                                                <xsl:for-each select="$transactionConceptUsage">
                                                    <xsl:variable name="dsid" select="../@sourceDataset"/>
                                                    <xsl:variable name="deid" select="@ref"/>
                                                    <xsl:variable name="theConcept" select="local:getConcept($deid, @flexibility, $dsid, ../@sourceDatasetFlexibility)"/>
                                                    <tr>
                                                        <td>
                                                            <xsl:choose>
                                                                <xsl:when test="$theConcept/@iddisplay">
                                                                    <xsl:value-of select="$theConcept/@iddisplay"/>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="doShorthandId">
                                                                        <xsl:with-param name="id" select="@ref"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </td>
                                                        <td>
                                                            <a href="{local:doHtmlName('TR', $projectPrefix, ancestor::transaction[1]/@id, ancestor::transaction[1]/@effectiveDate, $deid, $theConcept/@effectiveDate, (), (), '.html', false())}" onclick="target='_blank';">
                                                                <xsl:call-template name="doName">
                                                                    <xsl:with-param name="ns" select="$theConcept/name"/>
                                                                </xsl:call-template>
                                                                <xsl:if test="$theConcept/@versionLabel">
                                                                    <xsl:text> (</xsl:text>
                                                                    <xsl:value-of select="$theConcept/@versionLabel"/>
                                                                    <xsl:text>)</xsl:text>
                                                                </xsl:if>
                                                            </a>
                                                        </td>
                                                        <td>
                                                            <xsl:choose>
                                                                <xsl:when test="terminologyAssociation[@valueSet = $vsid][@flexibility castable as xs:dateTime]">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'terminologyAssociationSTATIC'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'terminologyAssociationDYNAMIC'"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </td>
                                                    </tr>
                                                </xsl:for-each>
                                                <xsl:if test="$templateUsage">
                                                    <tr>
                                                        <th style="text-align: left;" colspan="3">
                                                            <xsl:call-template name="getMessage">
                                                                <xsl:with-param name="key" select="'Template'"/>
                                                            </xsl:call-template>
                                                        </th>
                                                    </tr>
                                                </xsl:if>
                                                <xsl:for-each select="$templateUsage">
                                                    <tr>
                                                        <td>
                                                            <xsl:choose>
                                                                <xsl:when test="ancestor::template/@iddisplay">
                                                                    <xsl:value-of select="ancestor::template/@iddisplay"/>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="doShorthandId">
                                                                        <xsl:with-param name="id" select="ancestor::template/@id"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </td>
                                                        <td>
                                                            <a href="{local:doHtmlName('TM', ancestor::template/@id, ancestor::template/@effectiveDate, '.html', false())}" onclick="target='_blank';">
                                                                <xsl:value-of select="ancestor::template/(@displayName, @name)[1]"/>
                                                                <xsl:if test="ancestor::template/@versionLabel">
                                                                    <xsl:text> (</xsl:text>
                                                                    <xsl:value-of select="ancestor::template/@versionLabel"/>
                                                                    <xsl:text>)</xsl:text>
                                                                </xsl:if>
                                                            </a>
                                                        </td>
                                                        <td>
                                                            <xsl:choose>
                                                                <xsl:when test=".[@flexibility castable as xs:dateTime]">
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'terminologyAssociationSTATIC'"/>
                                                                    </xsl:call-template>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                    <xsl:call-template name="getMessage">
                                                                        <xsl:with-param name="key" select="'terminologyAssociationDYNAMIC'"/>
                                                                    </xsl:call-template>
                                                                </xsl:otherwise>
                                                            </xsl:choose>
                                                        </td>
                                                    </tr>
                                                </xsl:for-each>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </xsl:if>
            </xsl:if>
            <!-- handle SNOMED International copyright
            <xsl:if test="completeCodeSystem[@codeSystem='2.16.840.1.113883.6.96'] or conceptList/concept[@codeSystem='2.16.840.1.113883.6.96']">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Copyright'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        "This material includes SNOMED Clinical Terms® (SNOMED CT®) which is used by permission of SNOMED International (former known as International Health Terminology Standards Development Organisation IHTSDO). All rights reserved. SNOMED CT®, was originally created by The College of American Pathologists. “SNOMED” and “SNOMED CT” are registered trademarks of SNOMED International."
                    </td>
                </tr>
            </xsl:if>
            -->
            <xsl:call-template name="check4Issue">
                <xsl:with-param name="id" select="$vsid"/>
                <xsl:with-param name="effectiveDate" select="$vsed"/>
                <xsl:with-param name="colspans" select="$numcol - 1"/>
            </xsl:call-template>
            <xsl:variable name="completeCodeSystems" select="completeCodeSystem[not(filter)] | conceptList/include[@codeSystem][not(@code | filter)]"/>
            <xsl:variable name="otherDefinitions" select="completeCodeSystem[filter] | conceptList/include[@ref | @code | filter] | conceptList/exclude | conceptList/concept | conceptList/exception"/>
            <xsl:if test="$completeCodeSystems">
                <xsl:variable name="doTheType" select="exists($completeCodeSystems[@type])" as="xs:boolean"/>
                <xsl:variable name="doTheVersion" select="exists($completeCodeSystems[@codeSystemVersion])" as="xs:boolean"/>
                <xsl:variable name="doTheFlexibility" select="exists($completeCodeSystems[@flexibility])" as="xs:boolean"/>
                <xsl:variable name="doFilter" select="exists($completeCodeSystems[filter])" as="xs:boolean"/>
                <tr>
                    <td style="padding-top: 1.5em;" colspan="{$numcol}">
                        <xsl:choose>
                            <xsl:when test="count($completeCodeSystems) = 1">
                                <b>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'xCompleteCodeSystem'"/>
                                    </xsl:call-template>
                                </b>
                            </xsl:when>
                            <xsl:when test="count($completeCodeSystems) gt 1">
                                <b>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'xCompleteCodeSystems'"/>
                                        <xsl:with-param name="p1" select="count($completeCodeSystems)"/>
                                    </xsl:call-template>
                                </b>
                            </xsl:when>
                        </xsl:choose>
                        <table width="100%" border="0" cellspacing="3" cellpadding="2">
                            <tr style="background-color: #F6F3EE;">
                                <xsl:if test="$doTheType">
                                    <td style="text-align: left;" width="20">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Type'"/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:if>
                                <!-- name -->
                                <td style="width: 200px; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'CodeSystemName'"/>
                                    </xsl:call-template>
                                </td>
                                <!-- id -->
                                <td style="width: 200px; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'CodeSystemId'"/>
                                    </xsl:call-template>
                                </td>
                                <xsl:if test="$doTheVersion">
                                    <td style="text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'CodeSystemVersion'"/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:if>
                                <xsl:if test="$doTheFlexibility">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Flexibility'"/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:if>
                                <xsl:if test="$doFilter">
                                    <td>
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'filter-on-code-property'"/>
                                        </xsl:call-template>
                                    </td>
                                </xsl:if>
                            </tr>
                            <xsl:for-each select="$completeCodeSystems">
                                <tr>
                                    <xsl:if test="$doTheType">
                                        <td style="text-align: left;">
                                            <xsl:value-of select="@type"/>
                                        </td>
                                    </xsl:if>
                                    <!-- name -->
                                    <td style="text-align: left;">
                                        <xsl:variable name="theId" select="@codeSystem"/>
                                        <xsl:variable name="theName">
                                            <xsl:call-template name="getIDDisplayName">
                                                <xsl:with-param name="root" select="$theId"/>
                                            </xsl:call-template>
                                        </xsl:variable>
                                        <div class="concepttype{@type}">
                                            <xsl:choose>
                                                <xsl:when test="string-length(@codeSystemName) &gt; 0">
                                                    <xsl:text>&#160;</xsl:text>
                                                    <i>
                                                        <xsl:value-of select="@codeSystemName"/>
                                                    </i>
                                                </xsl:when>
                                                <xsl:when test="string-length($theName) &gt; 0">
                                                    <xsl:text>&#160;</xsl:text>
                                                    <i>
                                                        <xsl:value-of select="$theName"/>
                                                    </i>
                                                </xsl:when>
                                            </xsl:choose>
                                        </div>
                                    </td>
                                    <!-- id -->
                                    <td style="text-align: left;">
                                        <div class="concepttype{@type}">
                                            <xsl:value-of select="@codeSystem"/>
                                        </div>
                                    </td>
                                    <xsl:if test="$doTheVersion">
                                        <td style="text-align: left;">
                                            <div class="concepttype{@type}">
                                                <xsl:value-of select="@codeSystemVersion"/>
                                            </div>
                                        </td>
                                    </xsl:if>
                                    <xsl:if test="$doTheFlexibility">
                                        <td style="text-align: left;">
                                            <div class="concepttype{@type}">
                                                <xsl:choose>
                                                    <xsl:when test="matches(@flexibility, '^\d{4}')">
                                                        <xsl:call-template name="showDate">
                                                            <xsl:with-param name="date" select="@flexibility"/>
                                                        </xsl:call-template>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:call-template name="getMessage">
                                                            <xsl:with-param name="key" select="'terminologyAssociationDYNAMIC'"/>
                                                        </xsl:call-template>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </div>
                                        </td>
                                    </xsl:if>
                                    <xsl:if test="$doFilter">
                                        <td style="text-align: left;">
                                            <ul>
                                                <xsl:for-each select="filter">
                                                    <li>
                                                        <b>
                                                            <xsl:value-of select="@property"/>
                                                        </b>
                                                        <xsl:text> </xsl:text>
                                                        <xsl:value-of select="@op"/>
                                                        <xsl:text> </xsl:text>
                                                        <xsl:value-of select="@value"/>
                                                    </li>
                                                </xsl:for-each>
                                            </ul>
                                        </td>
                                    </xsl:if>
                                </tr>
                            </xsl:for-each>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="$completeCodeSystems and $otherDefinitions">
                <tr>
                    <td style="padding-top: 1.5em;" colspan="{$numcol}">
                        <b>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'orOneOfTheFollowing'"/>
                            </xsl:call-template>
                        </b>
                    </td>
                </tr>
            </xsl:if>
            <xsl:if test="$otherDefinitions">
                <!-- print and/or calculate sourceCodeSystems -->
                <!-- check if sourceCodeSystem is used in this original value set, if not - create them -->
                <xsl:variable name="sourceCodeSystem" as="element()*">
                    <xsl:choose>
                        <xsl:when test="sourceCodeSystem">
                            <xsl:copy-of select="sourceCodeSystem"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:for-each-group select="conceptList/concept | conceptList/exception" group-by="@codeSystem">
                                <sourceCodeSystem xmlns="" id="{current-grouping-key()}">
                                    <xsl:attribute name="identifierName">
                                        <xsl:choose>
                                            <xsl:when test="@codeSystemName">
                                                <xsl:value-of select="(@codeSystemName)[1]"/>
                                            </xsl:when>
                                            <xsl:when test="ancestor::terminology/codeSystem[(@id | @ref) = current-grouping-key()]">
                                                <xsl:value-of select="(ancestor::terminology/codeSystem[(@id | @ref) = current-grouping-key()]/@name)[1]"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:call-template name="getIDDisplayName">
                                                    <xsl:with-param name="root" select="current-grouping-key()"/>
                                                </xsl:call-template>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:attribute>
                                </sourceCodeSystem>
                            </xsl:for-each-group>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>
                <xsl:if test="$sourceCodeSystem[not(@id = $completeCodeSystems/@codeSystem)]">
                    <tr class="headinglabel">
                        <th style="vertical-align: top; text-align: left;">
                            <xsl:choose>
                                <xsl:when test="count($sourceCodeSystem[not(@id = $completeCodeSystems/@codeSystem)]) = 1">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'xSourceCodeSystem'"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'xSourceCodeSystems'"/>
                                        <xsl:with-param name="p1" select="string(count($sourceCodeSystem[not(@id = $completeCodeSystems/@codeSystem)]))"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </th>
                        <td colspan="{$numcol - 1}" class="tabtab">
                            <xsl:for-each select="$sourceCodeSystem[not(@id = $completeCodeSystems/@codeSystem)]">
                                <div style="width: 100%; margin: 4px 0px; background-color: {if (position() mod 2 = 0) then '#eee' else '#fff'};">
                                    <xsl:value-of select="@id"/>
                                    <xsl:if test="string-length(@identifierName) &gt; 0">
                                        <xsl:text> - </xsl:text>
                                        <i>
                                            <xsl:value-of select="@identifierName"/>
                                        </i>
                                    </xsl:if>
                                    <xsl:if test="string-length(@canonicalUri) &gt; 0">
                                        <xsl:text> - FHIR: </xsl:text>
                                        <i>
                                            <xsl:value-of select="@canonicalUri"/>
                                        </i>
                                    </xsl:if>
                                    <xsl:if test="string-length(@hl7v2table0396) &gt; 0">
                                        <xsl:text> - HL7 V2: </xsl:text>
                                        <i>
                                            <xsl:value-of select="@hl7v2table0396"/>
                                        </i>
                                    </xsl:if>
                                </div>
                            </xsl:for-each>
                        </td>
                    </tr>
                </xsl:if>
                <tr>
                    <td colspan="{$numcol}" class="tabtab">
                        <xsl:if test="$switchCreateTreeTableHtml = 'true' and not($doMultiple)">
                            <div>
                                <xsl:if test="conceptList/*[@level &gt; 0]">
                                    <button id="expandAll" type="button">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                        </xsl:call-template>
                                    </button>
                                    <button id="collapseAll" type="button">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                        </xsl:call-template>
                                    </button>
                                </xsl:if>
                                <input id="nameSearch">
                                    <xsl:attribute name="placeholder">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'textSearch'"/>
                                        </xsl:call-template>
                                    </xsl:attribute>
                                </input>
                            </div>
                        </xsl:if>
                        <table class="treetable" width="100%" border="0" cellspacing="0" cellpadding="5">
                            <xsl:if test="not($doMultiple)">
                                <xsl:attribute name="id" select="'transactionTable'"/>
                            </xsl:if>
                            <tr style="background-color: #F6F3EE;">
                                <!-- Level / Type -->
                                <th style="text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'LevelSlashType'"/>
                                    </xsl:call-template>
                                </th>
                                <!-- Code -->
                                <th style="width: 100px; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Code'"/>
                                    </xsl:call-template>
                                </th>
                                <!-- DisplayName -->
                                <th style="text-align: left;">
                                    <xsl:if test="conceptList/concept">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'DisplayName'"/>
                                        </xsl:call-template>
                                    </xsl:if>
                                    <xsl:if test="conceptList/concept and (conceptList/include | conceptList/exclude)">
                                        <xsl:value-of select="' / '"/>
                                    </xsl:if>
                                    <xsl:if test="conceptList/include | conceptList/exclude">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'IntensionalDefinition'"/>
                                        </xsl:call-template>
                                    </xsl:if>
                                </th>
                                <!-- Ordinal -->
                                <xsl:if test="$doOrdinal = 1">
                                    <th style="text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Ordinal'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                                <!-- CodeSystem -->
                                <th style="width: 200px; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'CodeSystem'"/>
                                    </xsl:call-template>
                                </th>
                                <!-- CodeSystemVersion -->
                                <xsl:if test="$doCodeSystemVersion = 1">
                                    <th style="text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'CodeSystemVersion'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                                <!-- Designation -->
                                <xsl:if test="$doDesignation = 1">
                                    <th style="vertical-align: top; text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Designations'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                                <!-- Description -->
                                <xsl:if test="$doDesc = 1">
                                    <th style="vertical-align: top; text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Description'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                            </tr>
                            <!-- first list all valid concepts -->
                            <!-- 
                                KH: set publication limit:
                                if called by ADRAM then limit the number of conceptList/concept to $truncateConceptListOutput 
                                and show the message: 
                                This value set has >$truncateConceptListOutput codes in it. In order to keep the publication size manageable, only a selection ($truncateConceptListOutput codes) of the whole set of codes is shown
                            -->
                            <xsl:choose>
                                <xsl:when test="count(conceptList/concept) > $truncateConceptListOutput and string-length($adram) > 0">
                                    <xsl:for-each select="$otherDefinitions[position() &lt; $truncateConceptListOutput][self::concept | self::include | self::exclude]">
                                        <xsl:apply-templates select="." mode="valueset">
                                            <xsl:with-param name="language" select="$defaultLanguage"/>
                                            <xsl:with-param name="doNesting" select="$doNesting" as="xs:boolean"/>
                                            <xsl:with-param name="doOrdinal" select="$doOrdinal"/>
                                            <xsl:with-param name="doCodeSystemVersion" select="$doCodeSystemVersion"/>
                                            <xsl:with-param name="doDesignation" select="$doDesignation"/>
                                            <xsl:with-param name="doDesc" select="$doDesc"/>
                                        </xsl:apply-templates>
                                    </xsl:for-each>
                                    <tr>
                                        <td colspan="{$numcolcodes}" style="background-color: #ffe6e6; border: 1px solid #ffcccc;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'value-set-too-big'"/>
                                                <xsl:with-param name="p1" select="count(conceptList/concept)"/>
                                                <xsl:with-param name="p2" select="$truncateConceptListOutput"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:for-each select="$otherDefinitions[not(self::exception)]">
                                        <xsl:apply-templates select="." mode="valueset">
                                            <xsl:with-param name="language" select="$defaultLanguage"/>
                                            <xsl:with-param name="doNesting" select="$doNesting" as="xs:boolean"/>
                                            <xsl:with-param name="doOrdinal" select="$doOrdinal"/>
                                            <xsl:with-param name="doCodeSystemVersion" select="$doCodeSystemVersion"/>
                                            <xsl:with-param name="doDesignation" select="$doDesignation"/>
                                            <xsl:with-param name="doDesc" select="$doDesc"/>
                                        </xsl:apply-templates>
                                    </xsl:for-each>
                                </xsl:otherwise>
                            </xsl:choose>
                            <!-- list allowed null flavors -->
                            <xsl:if test="conceptList[concept | include | exclude]">
                                <tr>
                                    <td colspan="{$numcolcodes}">
                                        <hr/>
                                    </td>
                                </tr>
                            </xsl:if>
                            <xsl:for-each select="conceptList/exception">
                                <xsl:apply-templates select="." mode="valueset">
                                    <xsl:with-param name="language" select="$defaultLanguage"/>
                                    <xsl:with-param name="doNesting" select="$doNesting" as="xs:boolean"/>
                                    <xsl:with-param name="doOrdinal" select="$doOrdinal"/>
                                    <xsl:with-param name="doCodeSystemVersion" select="$doCodeSystemVersion"/>
                                    <xsl:with-param name="doDesignation" select="$doDesignation"/>
                                    <xsl:with-param name="doDesc" select="$doDesc"/>
                                </xsl:apply-templates>
                            </xsl:for-each>
                            <!--tr>
                                <td colspan="{$numcolcodes}">&#160;</td>
                            </tr-->
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <!-- Print legend line -->
            <xsl:if test="conceptList[*]">
                <tr class="desclabel">
                    <td colspan="{$numcol}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'CodeSystemLegendaLine'"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- Print intensional hint when intensional -->
            <xsl:if test="conceptList[include|exclude]">
                <tr class="vslabel">
                    <td colspan="{$numcol}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'IntensionalDefinitionLegendaLine'"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- if rest URIs are defined show them for download here -->
            <xsl:variable name="theURI" select="($projectRestUriVS, $bindingBehaviorValueSetsURL)[string-length() gt 0][1]"/>
            <xsl:if test="$theURI">
                <xsl:if test="not($adram = ('mediawiki', 'confluence', 'wordpress'))">
                    <tr class="noprint">
                        <td colspan="{$numcol}">
                            <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                <tr>
                                    <td style="width: 50px;">
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">download</xsl:with-param>
                                            <xsl:with-param name="tooltip" select="'Download'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td class="tabtab" style="text-align: left;">
                                        <xsl:for-each select="('XML', 'JSON', 'CSV', 'SQL', 'SVS')">
                                            <xsl:variable name="theHref" select="local:doHtmlName('VS', $artdecordeeplinkprefix, $projectPrefix, $vsid, $vsed, (), (), (), (), lower-case(.), false(), lower-case(.))"/>
                                            <a href="{$theHref}" onclick="target='_blank';">
                                                <xsl:value-of select="."/>
                                            </a>
                                            <xsl:text>&#160;</xsl:text>
                                        </xsl:for-each>
                                        <!-- Expect in decor project file under /decor/project:
                                        <restURI for="FHIR" format="<fhirVersion>">https://art-decor.org/fhir/</restURI>
                                        
                                        Build URI that looks like:
                                        https://art-decor.org/fhir/<fhirVersion>/<prefix>[project version]/ValueSet/<valueset id>-\-<valueset effectivedate>
                                    -->
                                        <xsl:for-each select="$projectRestUriFHIR">
                                            <xsl:variable name="theHref">
                                                <xsl:value-of select="."/>
                                                <xsl:text>ValueSet/</xsl:text>
                                                <xsl:value-of select="concat($vsid, '--', replace($vsed, '[^\d]', ''))"/>
                                            </xsl:variable>
                                                <xsl:value-of select="concat(@for, ' (', @format, ') [')"/>
                                            <a href="{$theHref}?_format=xml" onclick="target='_blank';">xml</a>
                                            <xsl:text>&#160;/&#160;</xsl:text>
                                            <a href="{$theHref}?_format=json" onclick="target='_blank';">json</a>
                                            <xsl:text>]&#160;</xsl:text>
                                        </xsl:for-each>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </xsl:if>
            </xsl:if>
        </table>
    </xsl:template>
    <xsl:template match="codeSystem">
        <xsl:param name="doMultiple" select="false()" as="xs:boolean"/>
        <!-- language, not yet used -->
        <xsl:param name="language"/>
        <!-- whether to show other versions of this value set at the end as a list, default is true -->
        <xsl:param name="showOtherVersionsList" select="true()"/>
        <xsl:variable name="csname" select="@name"/>
        <xsl:variable name="csid" select="(@id | @ref)"/>
        <xsl:variable name="csed" select="@effectiveDate"/>
        
        <!-- When the list of concepts is big, the performance in finding the parent node degrades so significant that it is better not to -->
        <xsl:variable name="doNesting" select="count(conceptList/*) &lt;= 1000"/>
        <xsl:variable name="doStatus" select="if (conceptList/*[@statusCode]) then 1 else 0"/>
        <xsl:variable name="doOrdinal" select="if (conceptList/*[@ordinal]) then 1 else 0"/>
        <xsl:variable name="doEffective" select="if (conceptList/*[@effectiveDate]) then 1 else 0"/>
        <xsl:variable name="doExpiration" select="if (conceptList/*[@expirationDate]) then 1 else 0"/>
        <xsl:variable name="doDesignation" select="if (conceptList/*[designation]) then 1 else 0"/>
        <xsl:variable name="doDesc" select="if (conceptList/*[desc]) then 1 else 0"/>
        <xsl:variable name="fWidth" select="'20em'"/>
        <xsl:variable name="numcol" select="4"/>
        <xsl:variable name="numcolcodes" select="2 + $doStatus + $doOrdinal + $doDesignation + $doDesc"/>
        <table xmlns="http://www.w3.org/1999/xhtml" width="100%" border="0" cellspacing="3" cellpadding="2">
            <!-- added KH and AH 20220815: warning texts on publications that this terminology is a snapshot -->
            <xsl:if test="conceptList[*] and string-length($adram) > 0">
                <tr class="desclabel">
                    <td colspan="{$numcol}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'PublicationWarningBeUp2Date'"/>
                            <xsl:with-param name="p1">
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="$latestVersionOrRelease/@date"/>
                                </xsl:call-template>
                            </xsl:with-param>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- end added KH and AH 20220815 -->
            <!-- id / effectiveDate -->
            <tr style="vertical-align: top;">
                <!-- id -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Id'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:variable name="ident" select="(@ident, ../@ident)[1]"/>
                    <xsl:variable name="url" select="(@url, ../@url)[1]"/>
                    <xsl:choose>
                        <!-- In live ART-DECOR you can just go there, but in an offline publication, we cannot jump to a different publication location -->
                        <xsl:when test="$url and not(empty($projectPrefix)) and $ident[not(. = $projectPrefix)] and $seeThisUrlLocation = ('live', 'live-vue')">
                            <a href="{local:doHtmlName('CS',$url,$ident,$csid,$csed,(),(),(),(),'.html', false())}" onclick="target='_blank';">
                                <xsl:value-of select="$csid"/>
                            </a>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$csid"/>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                </td>
                <!-- version information -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'effectiveDate'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:if test="@effectiveDate[string-length() &gt; 0]">
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="@effectiveDate"/>
                        </xsl:call-template>
                    </xsl:if>
                    <xsl:if test="@expirationDate[string-length() &gt; 0]">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'templateValidTo'"/>
                        </xsl:call-template>
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="@expirationDate"/>
                        </xsl:call-template>
                    </xsl:if>
                    <!-- Summarize other versions of this valueSet -->
                    <xsl:if test="$showOtherVersionsList = true()">
                        <xsl:variable name="otherVersions" select="$allCodeSystems/*/codeSystem[@name = $csname or @id = $csid][@effectiveDate[not(. = $csed)]]" as="element()*"/>
                        <xsl:if test="$otherVersions">
                            <div>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'OtherVersionsWithThisId'"/>
                                </xsl:call-template>
                                <ul>
                                    <xsl:for-each-group select="$otherVersions" group-by="concat(@id, @effectiveDate)">
                                        <xsl:sort select="@effectiveDate" order="descending"/>
                                        <xsl:for-each select="current-group()[1]">
                                            <li>
                                                <xsl:call-template name="showStatusDot">
                                                    <xsl:with-param name="status" select="@statusCode"/>
                                                    <xsl:with-param name="title">
                                                        <xsl:call-template name="getXFormsLabel">
                                                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                        </xsl:call-template>
                                                    </xsl:with-param>
                                                </xsl:call-template>
                                                <xsl:text> </xsl:text>
                                                <a href="{local:doHtmlName('CS', @id, @effectiveDate, '.html')}" onclick="target='_blank';">
                                                    <xsl:value-of select="(@displayName, @name)[1]"/>
                                                </a>
                                                <xsl:if test="@versionLabel">
                                                    <xsl:value-of select="@versionLabel"/>
                                                    <xsl:text> - </xsl:text>
                                                </xsl:if>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'xAsOfy'"/>
                                                </xsl:call-template>
                                                <xsl:text> </xsl:text>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="@effectiveDate"/>
                                                </xsl:call-template>
                                                <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                            </li>
                                        </xsl:for-each>
                                    </xsl:for-each-group>
                                </ul>
                            </div>
                        </xsl:if>
                    </xsl:if>
                </td>
            </tr>
            <!-- HL7 FHIR URI -->
            <xsl:if test="@canonicalUri">
                <tr style="vertical-align: top;">
                    <!-- fhir uri -->
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'canonicalUri'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:value-of select="@canonicalUri"/>
                    </td>
                </tr>
            </xsl:if>
            <!-- status / versionLabel -->
            <xsl:if test="@statusCode | @versionLabel">
                <tr style="vertical-align: top;">
                    <!-- status -->
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Status'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;">
                        <xsl:if test="@statusCode">
                            <xsl:variable name="theStatusLabel">
                                <xsl:variable name="t">
                                    <xsl:call-template name="getXFormsLabel">
                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                    </xsl:call-template>
                                </xsl:variable>
                                <xsl:choose>
                                    <xsl:when test="empty($t) or $t = @statusCode">
                                        <xsl:call-template name="getXFormsLabel">
                                            <xsl:with-param name="simpleTypeKey" select="'ReleaseStatusCodeLifeCycle'"/>
                                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:copy-of select="$t"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:variable>
                            <xsl:call-template name="showStatusDot">
                                <xsl:with-param name="status" select="@statusCode"/>
                                <xsl:with-param name="title" select="$theStatusLabel"/>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <xsl:choose>
                                <xsl:when test="empty($theStatusLabel)">
                                    <xsl:value-of select="@statusCode"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:copy-of select="$theStatusLabel"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:if>
                    </td>
                    <!-- versionLabel -->
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'columnVersionLabel'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;">
                        <xsl:value-of select="@versionLabel"/>
                    </td>
                </tr>
            </xsl:if>
            <!-- name / displayName -->
            <tr style="vertical-align: top;">
                <!-- name -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Name'"/>
                    </xsl:call-template>
                    <!--<xsl:if test="count(context) = 0">
                        <!-\- no context means: internal template -\->
                        <xsl:text> (</xsl:text>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'internal'"/>
                        </xsl:call-template>
                        <xsl:text>)</xsl:text>
                    </xsl:if>-->
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@name"/>
                </td>
                <!-- displayName -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'DisplayName'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@displayName"/>
                </td>
            </tr>
            <!-- experimental / caseSensitive -->
            <xsl:if test="@experimental | @caseSensitive">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'experimental'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="if (@experimental = 'true') then 'yes' else 'no'"/>
                        </xsl:call-template>
                    </td>
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'caseSensitive'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="if (@caseSensitive = 'false') then 'no' else 'yes'"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- description if given -->
            <xsl:if test="@ref | desc">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Description'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="desc"/>
                        </xsl:call-template>
                        <xsl:if test="@ref">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'CodeSystemReferenceData'"/>
                                <xsl:with-param name="p1" select="$csid"/>
                                <xsl:with-param name="p2" select="(@displayName, @name)[1]"/>
                            </xsl:call-template>
                        </xsl:if>
                    </td>
                </tr>
            </xsl:if>
            <!-- handle copyright -->
            <xsl:for-each-group select="copyright" group-by="@language">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Copyright'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="."/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:for-each-group>
            <!-- handle SNOMED International copyright
            <xsl:if test="completeCodeSystem[@codeSystem='2.16.840.1.113883.6.96'] or conceptList/concept[@codeSystem='2.16.840.1.113883.6.96']">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Copyright'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        "This material includes SNOMED Clinical Terms® (SNOMED CT®) which is used by permission of SNOMED International (former known as International Health Terminology Standards Development Organisation IHTSDO). All rights reserved. SNOMED CT®, was originally created by The College of American Pathologists. “SNOMED” and “SNOMED CT” are registered trademarks of SNOMED International."
                    </td>
                </tr>
            </xsl:if>
            -->
            <xsl:call-template name="check4Issue">
                <xsl:with-param name="id" select="$csid"/>
                <xsl:with-param name="effectiveDate" select="$csed"/>
                <xsl:with-param name="colspans" select="$numcol - 1"/>
            </xsl:call-template>
            <xsl:if test="conceptList[*]">
                <tr>
                    <td colspan="{$numcol}" class="tabtab">
                        <xsl:if test="$switchCreateTreeTableHtml = 'true' and not($doMultiple)">
                            <div>
                                <xsl:if test="conceptList/*[@level &gt; 0]">
                                    <button id="expandAll" type="button">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                        </xsl:call-template>
                                    </button>
                                    <button id="collapseAll" type="button">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                        </xsl:call-template>
                                    </button>
                                </xsl:if>
                                <input id="nameSearch">
                                    <xsl:attribute name="placeholder">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'textSearch'"/>
                                        </xsl:call-template>
                                    </xsl:attribute>
                                </input>
                            </div>
                        </xsl:if>
                        <table class="treetable" width="100%" border="0" cellspacing="0" cellpadding="5">
                            <xsl:if test="not($doMultiple)">
                                <xsl:attribute name="id" select="'transactionTable'"/>
                            </xsl:if>
                            <tr style="background-color: #F6F3EE; width: {$fWidth}; text-align: left;">
                                <!-- Level / Type -->
                                <th style="text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'LevelSlashType'"/>
                                    </xsl:call-template>
                                </th>
                                <!-- Status -->
                                <xsl:if test="$doStatus = 1">
                                    <th style="width: 100px; text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Status'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                                <!-- Code -->
                                <th style="width: 100px; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Code'"/>
                                    </xsl:call-template>
                                </th>
                                <!-- Ordinal -->
                                <xsl:if test="$doOrdinal = 1">
                                    <th style="text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Ordinal'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                                <xsl:if test="$doEffective = 1">
                                    <th style="text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'EffectiveDate'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                                <xsl:if test="$doExpiration = 1">
                                    <th style="text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'ExpirationDate'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                                <!-- Designation -->
                                <xsl:if test="$doDesignation = 1">
                                    <th style="vertical-align: top; text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Designations'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                                <!-- Description -->
                                <xsl:if test="$doDesc = 1">
                                    <th style="vertical-align: top; text-align: left;">
                                        <xsl:call-template name="getMessage">
                                            <xsl:with-param name="key" select="'Description'"/>
                                        </xsl:call-template>
                                    </th>
                                </xsl:if>
                            </tr>
                            <!-- first list all valid concepts -->
                            <!-- 
                                KH: set publication limit:
                                if called by ADRAM then limit the number of conceptList/concept to $truncateConceptListOutput 
                                and show the message: 
                                This value set has >1000 codes in it. In order to keep the publication size manageable, only a selection (1000 codes) of the whole set of codes is shown
                            -->
                            <xsl:choose>
                                <xsl:when test="count(conceptList/codedConcept) > $truncateConceptListOutput and string-length($adram) > 0">
                                    <xsl:for-each select="conceptList/codedConcept[position() &lt; $truncateConceptListOutput]">
                                        <xsl:apply-templates select="." mode="codesystem">
                                            <xsl:with-param name="language" select="$defaultLanguage"/>
                                            <xsl:with-param name="doStatus" select="$doStatus"/>
                                            <xsl:with-param name="doNesting" select="$doNesting"/>
                                            <xsl:with-param name="doOrdinal" select="$doOrdinal"/>
                                            <xsl:with-param name="doEffective" select="$doEffective"/>
                                            <xsl:with-param name="doExpiration" select="$doExpiration"/>
                                            <xsl:with-param name="doDesignation" select="$doDesignation"/>
                                            <xsl:with-param name="doDesc" select="$doDesc"/>
                                        </xsl:apply-templates>
                                    </xsl:for-each>
                                    <tr>
                                        <td colspan="{$numcolcodes}" style="background-color: #ffe6e6; border: 1px solid #ffcccc;">
                                            <xsl:call-template name="getMessage">
                                                <xsl:with-param name="key" select="'codesystem-too-big'"/>
                                                <xsl:with-param name="p1" select="count(conceptList/codedConcept)"/>
                                                <xsl:with-param name="p2" select="$truncateConceptListOutput"/>
                                            </xsl:call-template>
                                        </td>
                                    </tr>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:for-each select="conceptList/codedConcept">
                                        <xsl:apply-templates select="." mode="codesystem">
                                            <xsl:with-param name="language" select="$defaultLanguage"/>
                                            <xsl:with-param name="doStatus" select="$doStatus"/>
                                            <xsl:with-param name="doNesting" select="$doNesting"/>
                                            <xsl:with-param name="doOrdinal" select="$doOrdinal"/>
                                            <xsl:with-param name="doEffective" select="$doEffective"/>
                                            <xsl:with-param name="doExpiration" select="$doExpiration"/>
                                            <xsl:with-param name="doDesignation" select="$doDesignation"/>
                                            <xsl:with-param name="doDesc" select="$doDesc"/>
                                        </xsl:apply-templates>
                                    </xsl:for-each>
                                </xsl:otherwise>
                            </xsl:choose>
                        </table>
                    </td>
                </tr>
            </xsl:if>
            <!-- Print legend line -->
            <xsl:if test="conceptList[*]">
                <tr class="desclabel">
                    <td colspan="{$numcol}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'CodeSystemLegendaLine'"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- Print intensional hint when intensional -->
            <xsl:if test="conceptList[include|exclude]">
                <tr class="vslabel">
                    <td colspan="{$numcol}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'IntensionalDefinitionLegendaLine'"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- if rest URIs are defined show them for download here -->
            <xsl:if test="$projectRestUriCS[string-length() &gt; 0] or $bindingBehaviorValueSetsURL[contains(., 'RetrieveCodeSystem')]">
                <xsl:variable name="theURI" select="
                        if ($projectRestUriCS[string-length() &gt; 0]) then
                            $projectRestUriCS
                        else
                            $bindingBehaviorValueSetsURL"/>
                <xsl:if test="not($adram = ('mediawiki', 'confluence', 'wordpress'))">
                    <tr class="noprint">
                        <td colspan="{$numcol}">
                            <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                <tr>
                                    <td style="width: 50px;">
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">download</xsl:with-param>
                                            <xsl:with-param name="tooltip" select="'Download'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td class="tabtab" style="text-align: left;">
                                        <xsl:for-each select="('XML', 'JSON', 'CSV', 'SQL')">
                                            <xsl:variable name="theHref" select="local:doHtmlName('CS', $artdecordeeplinkprefix, $projectPrefix, $csid, $csed, (), (), (), (), lower-case(.), false(), lower-case(.))"/>
                                            <a href="{$theHref}" onclick="target='_blank';">
                                                <xsl:value-of select="."/>
                                            </a>
                                            <xsl:text>&#160;</xsl:text>
                                        </xsl:for-each>
                                        <xsl:for-each select="$projectRestUriFHIR[not(@format = ('1.0', '3.0'))]">
                                            <xsl:variable name="theHref">
                                                <xsl:value-of select="."/>
                                                <xsl:text>CodeSystem/</xsl:text>
                                                <xsl:value-of select="concat($csid, '--', replace($csed, '[^\d]', ''))"/>
                                            </xsl:variable>
                                            <a href="{$theHref}" onclick="target='_blank';">
                                                <xsl:value-of select="concat(@for, ' (', @format, ')')"/>
                                            </a>
                                            <xsl:text>&#160;</xsl:text>
                                        </xsl:for-each>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </xsl:if>
            </xsl:if>
        </table>
    </xsl:template>
    <xsl:template match="conceptMap">
        <xsl:param name="doMultiple" select="false()" as="xs:boolean"/>
        <!-- language, not yet used -->
        <xsl:param name="language"/>
        <!-- whether to show other versions of this value set at the end as a list, default is true -->
        <xsl:param name="showOtherVersionsList" select="true()"/>
        <xsl:variable name="csname" select="@name"/>
        <xsl:variable name="csid" select="(@id | @ref)"/>
        <xsl:variable name="csed" select="@effectiveDate"/>
        
        <!-- When the list of concepts is big, the performance in finding the parent node degrades so significant that it is better not to -->
        <xsl:variable name="doNesting" select="count(group/*) &lt;= 1000"/>
        <xsl:variable name="fWidth" select="'20em'"/>
        <xsl:variable name="numcol" select="4"/>
        <xsl:variable name="numcolcodes" select="4"/>
        <table xmlns="http://www.w3.org/1999/xhtml" width="100%" border="0" cellspacing="3" cellpadding="2">
            <!-- added KH and AH 20220815: warning texts on publications that this terminology is a snapshot -->
            <xsl:if test="conceptList[*] and string-length($adram) > 0">
                <tr class="desclabel">
                    <td colspan="{$numcol}">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'PublicationWarningBeUp2Date'"/>
                            <xsl:with-param name="p1">
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="$latestVersionOrRelease/@date"/>
                                </xsl:call-template>
                            </xsl:with-param>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>
            <!-- end added KH and AH 20220815 -->
            <!-- id / effectiveDate -->
            <tr style="vertical-align: top;">
                <!-- id -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Id'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:variable name="ident" select="(@ident, ../@ident)[1]"/>
                    <xsl:variable name="url" select="(@url, ../@url)[1]"/>
                    <xsl:choose>
                        <!-- In live ART-DECOR you can just go there, but in an offline publication, we cannot jump to a different publication location -->
                        <xsl:when test="$url and not(empty($projectPrefix)) and $ident[not(. = $projectPrefix)] and $seeThisUrlLocation = ('live', 'live-vue')">
                            <a href="{local:doHtmlName('MP',$url,$ident,$csid,$csed,(),(),(),(),'.html',false())}" onclick="target='_blank';">
                                <xsl:value-of select="$csid"/>
                            </a>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$csid"/>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:apply-templates select="." mode="buildReferenceBox"/>
                </td>
                <!-- version information -->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'effectiveDate'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:if test="@effectiveDate[string-length() &gt; 0]">
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="@effectiveDate"/>
                        </xsl:call-template>
                    </xsl:if>
                    <xsl:if test="@expirationDate[string-length() &gt; 0]">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'templateValidTo'"/>
                        </xsl:call-template>
                        <xsl:call-template name="showDate">
                            <xsl:with-param name="date" select="@expirationDate"/>
                        </xsl:call-template>
                    </xsl:if>
                    <!-- Summarize other versions of this valueSet -->
                    <xsl:if test="$showOtherVersionsList = true()">
                        <xsl:variable name="otherVersions" select="$allCodeSystems/*/conceptMap[@name = $csname or @id = $csid][@effectiveDate[not(. = $csed)]]" as="element()*"/>
                        <xsl:if test="$otherVersions">
                            <div>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'OtherVersionsWithThisId'"/>
                                </xsl:call-template>
                                <ul>
                                    <xsl:for-each-group select="$otherVersions" group-by="concat(@id, @effectiveDate)">
                                        <xsl:sort select="@effectiveDate" order="descending"/>
                                        <xsl:for-each select="current-group()[1]">
                                            <li>
                                                <xsl:call-template name="showStatusDot">
                                                    <xsl:with-param name="status" select="@statusCode"/>
                                                    <xsl:with-param name="title">
                                                        <xsl:call-template name="getXFormsLabel">
                                                            <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                                        </xsl:call-template>
                                                    </xsl:with-param>
                                                </xsl:call-template>
                                                <xsl:text> </xsl:text>
                                                <a href="{local:doHtmlName('MP', @id, @effectiveDate, '.html')}" onclick="target='_blank';">
                                                    <xsl:value-of select="(@displayName, @name)[1]"/>
                                                </a>
                                                <xsl:if test="@versionLabel">
                                                    <xsl:value-of select="@versionLabel"/>
                                                    <xsl:text> - </xsl:text>
                                                </xsl:if>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'xAsOfy'"/>
                                                </xsl:call-template>
                                                <xsl:text> </xsl:text>
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="@effectiveDate"/>
                                                </xsl:call-template>
                                                <xsl:apply-templates select="." mode="buildReferenceBox"/>
                                            </li>
                                        </xsl:for-each>
                                    </xsl:for-each-group>
                                </ul>
                            </div>
                        </xsl:if>
                    </xsl:if>
                </td>
            </tr>
            <!-- HL7 FHIR URI -->
            <xsl:if test="@canonicalUri">
                <tr style="vertical-align: top;">
                    <!-- fhir uri -->
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'canonicalUri'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:value-of select="@canonicalUri"/>
                    </td>
                </tr>
            </xsl:if>
            <!-- status / versionLabel -->
            <xsl:if test="@statusCode | @versionLabel">
                <tr style="vertical-align: top;">
                    <!-- status -->
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Status'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;">
                        <xsl:if test="@statusCode">
                            <xsl:variable name="theStatusLabel">
                                <xsl:variable name="t">
                                    <xsl:call-template name="getXFormsLabel">
                                        <xsl:with-param name="simpleTypeKey" select="'ItemStatusCodeLifeCycle'"/>
                                        <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                        <xsl:with-param name="lang" select="$defaultLanguage"/>
                                    </xsl:call-template>
                                </xsl:variable>
                                <xsl:choose>
                                    <xsl:when test="empty($t) or $t = @statusCode">
                                        <xsl:call-template name="getXFormsLabel">
                                            <xsl:with-param name="simpleTypeKey" select="'ReleaseStatusCodeLifeCycle'"/>
                                            <xsl:with-param name="simpleTypeValue" select="@statusCode"/>
                                            <xsl:with-param name="lang" select="$defaultLanguage"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:copy-of select="$t"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:variable>
                            <xsl:call-template name="showStatusDot">
                                <xsl:with-param name="status" select="@statusCode"/>
                                <xsl:with-param name="title" select="$theStatusLabel"/>
                            </xsl:call-template>
                            <xsl:text> </xsl:text>
                            <xsl:choose>
                                <xsl:when test="empty($theStatusLabel)">
                                    <xsl:value-of select="@statusCode"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:copy-of select="$theStatusLabel"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:if>
                    </td>
                    <!-- versionLabel -->
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'columnVersionLabel'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;">
                        <xsl:value-of select="@versionLabel"/>
                    </td>
                </tr>
            </xsl:if>
            <!-- name / displayName -->
            <!--<tr style="vertical-align: top;">
                <!-\- name -\->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Name'"/>
                    </xsl:call-template>
                    <!-\-<xsl:if test="count(context) = 0">
                        <!-\\- no context means: internal template -\\->
                        <xsl:text> (</xsl:text>
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'internal'"/>
                        </xsl:call-template>
                        <xsl:text>)</xsl:text>
                    </xsl:if>-\->
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@name"/>
                </td>
                <!-\- displayName -\->
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'DisplayName'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:value-of select="@displayName"/>
                </td>
            </tr>-->
            <!-- experimental / caseSensitive -->
            <!--<xsl:if test="@experimental | @caseSensitive">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'experimental'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="if (@experimental = 'true') then 'yes' else 'no'"/>
                        </xsl:call-template>
                    </td>
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'caseSensitive'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="if (@caseSensitive = 'false') then 'no' else 'yes'"/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:if>-->
            <!-- description if given -->
            <xsl:if test="@ref | desc">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Description'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="desc"/>
                        </xsl:call-template>
                        <xsl:if test="@ref">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'CodeSystemReferenceData'"/>
                                <xsl:with-param name="p1" select="$csid"/>
                                <xsl:with-param name="p2" select="(@displayName, @name)[1]"/>
                            </xsl:call-template>
                        </xsl:if>
                    </td>
                </tr>
            </xsl:if>
            <!-- handle copyright -->
            <xsl:for-each-group select="copyright" group-by="@language">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Copyright'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="."/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:for-each-group>
            <!-- handle purpose -->
            <xsl:for-each-group select="purpose" group-by="@language">
                <tr style="vertical-align: top;">
                    <th style="width: {$fWidth}; text-align: left;">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="'Purpose'"/>
                        </xsl:call-template>
                    </th>
                    <td style="text-align: left;" colspan="3">
                        <xsl:call-template name="doDescription">
                            <xsl:with-param name="ns" select="."/>
                        </xsl:call-template>
                    </td>
                </tr>
            </xsl:for-each-group>
            <xsl:call-template name="check4Issue">
                <xsl:with-param name="id" select="$csid"/>
                <xsl:with-param name="effectiveDate" select="$csed"/>
                <xsl:with-param name="colspans" select="$numcol - 1"/>
            </xsl:call-template>
            <!-- Source / Target -->
            <tr style="vertical-align: top;">
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'SourceScope'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:variable name="vsid" select="sourceScope/@ref"/>
                    <xsl:variable name="vsed" select="(sourceScope/@flexibility, 'dynamic')[1]"/>
                    <xsl:variable name="vs" as="element()*">
                        <xsl:call-template name="getValueset">
                            <xsl:with-param name="reference" select="$vsid"/>
                            <xsl:with-param name="flexibility" select="$vsed"/>
                        </xsl:call-template>
                    </xsl:variable>
                    <xsl:variable name="linktext">
                        <xsl:value-of select="($vs/@displayName, sourceScope/@displayName, sourceScope/@ref)[1]"/>
                        <xsl:if test="$vs[1]/@versionLabel">
                            <xsl:text> </xsl:text>
                            <xsl:value-of select="$vs[1]/@versionLabel"/>
                        </xsl:if>
                        <xsl:text> (</xsl:text>
                        <xsl:choose>
                            <xsl:when test="sourceScope/@flexibility castable as xs:dateTime">
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="sourceScope/@flexibility"/>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:text>)</xsl:text>
                    </xsl:variable>
                    <i>
                        <xsl:choose>
                            <xsl:when test="$seeThisUrlLocation = ('live', 'live-services', 'live-vue', 'live-services-vue')">
                                <xsl:copy-of select="$linktext"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:if test="empty($vs)">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which">alert</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:if>
                                <a href="{local:doHtmlName('VS', $projectPrefix, sourceScope/@ref, sourceScope/@flexibility, (), (), (), (), '.html', false())}" onclick="target='_blank';">
                                    <xsl:copy-of select="$linktext"/>
                                </a>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:if test="$vs/@canonicalUri | sourceScope/@canonicalUri">
                            <xsl:text> </xsl:text>
                            <xsl:value-of select="($vs/@canonicalUri | sourceScope/@canonicalUri)[1]"/>
                        </xsl:if>
                    </i>
                </td>
                <th style="width: {$fWidth}; text-align: left;">
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'TargetScope'"/>
                    </xsl:call-template>
                </th>
                <td style="text-align: left;">
                    <xsl:variable name="vsid" select="targetScope/@ref"/>
                    <xsl:variable name="vsed" select="(targetScope/@flexibility, 'dynamic')[1]"/>
                    <xsl:variable name="vs" as="element()*">
                        <xsl:call-template name="getValueset">
                            <xsl:with-param name="reference" select="$vsid"/>
                            <xsl:with-param name="flexibility" select="$vsed"/>
                        </xsl:call-template>
                    </xsl:variable>
                    <xsl:variable name="linktext">
                        <xsl:value-of select="($vs/@displayName, targetScope/@displayName, targetScope/@ref)[1]"/>
                        <xsl:if test="$vs[1]/@versionLabel">
                            <xsl:text> </xsl:text>
                            <xsl:value-of select="$vs[1]/@versionLabel"/>
                        </xsl:if>
                        <xsl:text> (</xsl:text>
                        <xsl:choose>
                            <xsl:when test="targetScope/@flexibility castable as xs:dateTime">
                                <xsl:call-template name="showDate">
                                    <xsl:with-param name="date" select="targetScope/@flexibility"/>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:call-template name="getMessage">
                                    <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:text>)</xsl:text>
                    </xsl:variable>
                    <i>
                        <xsl:choose>
                            <xsl:when test="$seeThisUrlLocation = ('live', 'live-services', 'live-vue', 'live-services-vue')">
                                <xsl:copy-of select="$linktext"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:if test="empty($vs)">
                                    <xsl:call-template name="showIcon">
                                        <xsl:with-param name="which">alert</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:if>
                                <a href="{local:doHtmlName('VS', $projectPrefix, targetScope/@ref, targetScope/@flexibility, (), (), (), (), '.html', false())}" onclick="target='_blank';">
                                    <xsl:copy-of select="$linktext"/>
                                </a>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:if test="$vs/@canonicalUri | targetScope/@canonicalUri">
                            <xsl:text> </xsl:text>
                            <xsl:value-of select="($vs/@canonicalUri | targetScope/@canonicalUri)[1]"/>
                        </xsl:if>
                    </i>
                </td>
            </tr>
            <!--<tr>
                <td colspan="{$numcol}" class="tabtab">
                    <xsl:if test="$switchCreateTreeTableHtml = 'true' and not($doMultiple)">
                        <div>
                            <xsl:if test="conceptList/*[@level &gt; 0]">
                                <button id="expandAll" type="button">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'buttonExpandAll'"/>
                                    </xsl:call-template>
                                </button>
                                <button id="collapseAll" type="button">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'buttonCollapseAll'"/>
                                    </xsl:call-template>
                                </button>
                            </xsl:if>
                            <input id="nameSearch">
                                <xsl:attribute name="placeholder">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'textSearch'"/>
                                    </xsl:call-template>
                                </xsl:attribute>
                            </input>
                        </div>
                    </xsl:if>
                </td>
            </tr>-->
            <tr>
                <td colspan="{$numcol}" char="tabtab">
                    <xsl:for-each select="group">
                        <table class="treetable tabtab" width="100%" border="0" cellspacing="0" cellpadding="5">
                            <xsl:if test="not($doMultiple)">
                                <xsl:attribute name="id" select="'transactionTable'"/>
                            </xsl:if>
                            <xsl:if test="preceding-sibling::group | following-sibling::group">
                                <caption>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Group'"/>
                                    </xsl:call-template>
                                    <xsl:text> </xsl:text>
                                    <xsl:value-of select="position()"/>
                                </caption>
                            </xsl:if>
                            <tr style="vertical-align: top;">
                                <th style="width: {$fWidth}; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Sourcesystem'"/>
                                    </xsl:call-template>
                                </th>
                                <td style="text-align: left;">
                                    <xsl:variable name="csid" select="source/@codeSystem"/>
                                    <xsl:variable name="csed" select="source/@codeSystemVersion"/>
                                    <xsl:variable name="cs" select="$allDECOR//codeSystem[@id = $csid][@effectiveDate = $csed or @effectiveDate = string(max($allDECOR//codeSystem[@id = $csid]/xs:dateTime(@effectiveDate)))]" as="element()*"/>
                                    <i>
                                        <xsl:value-of select="($cs/@displayName, source/@displayName, $csid)[1]"/>
                                        <xsl:if test="$cs[1]/@versionLabel">
                                            <xsl:text> </xsl:text>
                                            <xsl:value-of select="$cs[1]/@versionLabel"/>
                                        </xsl:if>
                                        <xsl:text> (</xsl:text>
                                        <xsl:choose>
                                            <xsl:when test="$csed castable as xs:dateTime">
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="$csed"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:when test="$csed">
                                                <xsl:value-of select="$csed"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                </xsl:call-template>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                        <xsl:text>)</xsl:text>
                                        <xsl:if test="$cs/@canonicalUri | source/@canonicalUri">
                                            <xsl:text> </xsl:text>
                                            <xsl:value-of select="($cs/@canonicalUri | source/@canonicalUri)[1]"/>
                                        </xsl:if>
                                    </i>
                                </td>
                                <th style="width: {$fWidth}; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Targetsystem'"/>
                                    </xsl:call-template>
                                </th>
                                <td style="text-align: left;" colspan="2">
                                    <xsl:variable name="csid" select="target/@codeSystem"/>
                                    <xsl:variable name="csed" select="target/@codeSystemVersion"/>
                                    <xsl:variable name="cs" select="$allDECOR//codeSystem[@id = $csid][@effectiveDate = $csed or @effectiveDate = string(max($allDECOR//codeSystem[@id = $csid]/xs:dateTime(@effectiveDate)))]" as="element()*"/>
                                    <i>
                                        <xsl:value-of select="($cs/@displayName, target/@displayName, $csid)[1]"/>
                                        <xsl:if test="$cs[1]/@versionLabel">
                                            <xsl:text> </xsl:text>
                                            <xsl:value-of select="$cs[1]/@versionLabel"/>
                                        </xsl:if>
                                        <xsl:text> (</xsl:text>
                                        <xsl:choose>
                                            <xsl:when test="$csed castable as xs:dateTime">
                                                <xsl:call-template name="showDate">
                                                    <xsl:with-param name="date" select="$csed"/>
                                                </xsl:call-template>
                                            </xsl:when>
                                            <xsl:when test="$csed">
                                                <xsl:value-of select="$csed"/>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:call-template name="getMessage">
                                                    <xsl:with-param name="key" select="'associationDYNAMIC'"/>
                                                </xsl:call-template>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                        <xsl:text>)</xsl:text>
                                        <xsl:if test="$cs/@canonicalUri | target/@canonicalUri">
                                            <xsl:text> </xsl:text>
                                            <xsl:value-of select="($cs/@canonicalUri | target/@canonicalUri)[1]"/>
                                        </xsl:if>
                                    </i>
                                </td>
                            </tr>
                            <tr style="background-color: #F6F3EE;">
                                <!-- Code -->
                                <th style="width:15%; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Code'"/>
                                    </xsl:call-template>
                                </th>
                                <!-- Display -->
                                <th style="width:25%; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'DisplayName'"/>
                                    </xsl:call-template>
                                </th>
                                <!-- Equivalence -->
                                <th style="width:10%; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Equivalence'"/>
                                    </xsl:call-template>
                                </th>
                                <!-- Code -->
                                <th style="width:15%; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'Code'"/>
                                    </xsl:call-template>
                                </th>
                                <!-- Display -->
                                <th style="width:25%; text-align: left;">
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'DisplayName'"/>
                                    </xsl:call-template>
                                </th>
                            </tr>
                            <!-- first list all valid concepts -->
                            <xsl:for-each select="element">
                                <xsl:apply-templates select="." mode="conceptmap">
                                    <xsl:with-param name="language" select="$defaultLanguage"/>
                                </xsl:apply-templates>
                            </xsl:for-each>
                        </table>
                    </xsl:for-each>
                </td>
            </tr>
            
            <!-- if rest URIs are defined show them for download here -->
            <xsl:if test="$projectRestUriMP[string-length() &gt; 0] or $bindingBehaviorValueSetsURL[contains(., 'RetrieveConceptMap')]">
                <xsl:variable name="theURI" select="
                        if ($projectRestUriMP[string-length() &gt; 0]) then
                            $projectRestUriMP
                        else
                            $bindingBehaviorValueSetsURL"/>
                <xsl:if test="not($adram = ('mediawiki', 'confluence', 'wordpress'))">
                    <tr class="noprint">
                        <td colspan="{$numcol}">
                            <table width="100%" border="0" cellspacing="3" cellpadding="2">
                                <tr>
                                    <td style="width: 50px;">
                                        <xsl:call-template name="showIcon">
                                            <xsl:with-param name="which">download</xsl:with-param>
                                            <xsl:with-param name="tooltip" select="'Download'"/>
                                        </xsl:call-template>
                                    </td>
                                    <td class="tabtab" style="text-align: left;">
                                        <!--<xsl:for-each select="('XML', 'JSON', 'CSV', 'SQL')">-->
                                        <xsl:for-each select="('XML', 'JSON')">
                                            <xsl:variable name="theHref" select="local:doHtmlName('MP', $artdecordeeplinkprefix, $projectPrefix, $csid, $csed, (), (), (), (), lower-case(.), false(), lower-case(.))"/>
                                            <a href="{$theHref}" onclick="target='_blank';">
                                                <xsl:value-of select="."/>
                                            </a>
                                            <xsl:text>&#160;</xsl:text>
                                        </xsl:for-each>
                                        <xsl:for-each select="$projectRestUriFHIR[not(@format = ('1.0', '3.0'))]">
                                            <xsl:variable name="theHref">
                                                <xsl:value-of select="."/>
                                                <xsl:text>ConceptMap/</xsl:text>
                                                <xsl:value-of select="concat($csid, '--', replace($csed, '[^\d]', ''))"/>
                                            </xsl:variable>
                                            <a href="{$theHref}" onclick="target='_blank';">
                                                <xsl:value-of select="concat(@for, ' (', @format, ')')"/>
                                            </a>
                                            <xsl:text>&#160;</xsl:text>
                                        </xsl:for-each>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </xsl:if>
            </xsl:if>
        </table>
    </xsl:template>
    <xsl:template match="publishingAuthority | endorsingAuthority">
        <xsl:param name="headerClass" as="xs:string?"/>
        <xsl:param name="fWidth" select="'20em'"/>
        <xsl:param name="colspan" select="3"/>
        <tr style="vertical-align: top;">
            <th style="width: {$fWidth}; text-align: left;">
                <xsl:if test="string-length($headerClass) gt 0">
                    <xsl:attribute name="class" select="$headerClass"/>
                    <xsl:attribute name="style" select="''"/>
                </xsl:if>
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="name(.)"/>
                </xsl:call-template>
            </th>
            <td style="text-align: left;" colspan="{$colspan}">
                <div>
                    <xsl:value-of select="@name"/>
                    <xsl:if test="@id">
                        <xsl:text> - </xsl:text>
                        <xsl:value-of select="@id"/>
                    </xsl:if>
                </div>
                <xsl:for-each select="addrLine">
                    <xsl:choose>
                        <xsl:when test="@type = 'uri'">
                            <a href="{.}">
                                <xsl:value-of select="."/>
                            </a>
                        </xsl:when>
                        <xsl:when test="@type = ('twitter', 'linkedin', 'facebook')">
                            <a href="{.}" title="{@type}">
                                <xsl:call-template name="showIcon">
                                    <xsl:with-param name="which" select="@type"/>
                                </xsl:call-template>
                            </a>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="."/>
                        </xsl:otherwise>
                    </xsl:choose>
                    <br/>
                </xsl:for-each>
            </td>
        </tr>
    </xsl:template>
    <!-- valueSets are sent in when coming from live situation with their parent element carrying the ident/url attributes, so check both -->
    <xsl:template match="*" mode="buildReferenceBox">
        <xsl:variable name="ident" select="(@ident, ../@ident)[1]"/>
        <xsl:variable name="url" select="(@url, ../@url)[1]"/>
        <xsl:if test="@ref | $ident[not(. = $projectPrefix)] | $url[not(. = $allDECOR/@deeplinkprefixservices)]">
            <xsl:text> </xsl:text>
            <span class="repobox">
                <div class="repo ref sspacing">
                    <xsl:value-of select="'ref'"/>
                </div>
                <div class="non-selectable repo refvalue sspacing">
                    <xsl:choose>
                        <xsl:when test="string-length($ident) gt 0">
                            <xsl:value-of select="$ident"/>
                        </xsl:when>
                        <xsl:otherwise>?</xsl:otherwise>
                    </xsl:choose>
                </div>
            </span>
        </xsl:if>
    </xsl:template>
    <!--<xsl:template name="getAnchorName">
        <!-\- build an HTML anchor that is unique AND stable over multiple builds. Don't include # so we can reuse for href too -\->
        <!-\- Dataset concepts: id + effectiveTime -\->
        <!-\- Template elements: id -\->
        <xsl:param name="id" as="xs:string" required="yes"/>
        <xsl:param name="effectiveDate" as="xs:string?"/>
        <xsl:param name="status" as="xs:string?"/>
        <xsl:text>_</xsl:text>
        <xsl:call-template name="doShorthandId">
            <xsl:with-param name="id" select="$id"/>
        </xsl:call-template>
        <xsl:if test="string-length($effectiveDate)&gt;0">
            <xsl:text>_</xsl:text>
            <xsl:value-of select="replace($effectiveDate,'[T:-]','')"/>
        </xsl:if>
        <xsl:if test="string-length($status)&gt;0">
            <xsl:text>_</xsl:text>
            <xsl:value-of select="$status"/>
        </xsl:if>
    </xsl:template>-->
    <!-- For a given id, try to find the shorthand notation. Return id as-is if not possible -->
    <xsl:template name="doShorthandId">
        <xsl:param name="id" as="item()*"/>
        <xsl:if test="count($id) gt 1">
            <xsl:call-template name="logMessage">
                <xsl:with-param name="level" select="$logINFO"/>
                <xsl:with-param name="msg">
                    <xsl:text>+++ technical problem in DECOR2html.xsl. doShortHandId got multiple ids '</xsl:text>
                    <xsl:value-of select="$id"/>
                    <xsl:text>'</xsl:text>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:if>
        
        <xsl:choose>
            <xsl:when test="$id[1] instance of attribute(ref) and $id[1]/../@refdisplay">
                <span style="color: grey;" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:value-of select="$id[1]/../@refdisplay"/>
                </span>
            </xsl:when>
            <xsl:when test="$id[1] instance of attribute(id) and $id[1]/../@iddisplay">
                <span style="color: grey;" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:value-of select="$id[1]/../@iddisplay"/>
                </span>
            </xsl:when>
            <xsl:otherwise>
                <xsl:variable name="allbids">
                    <xsl:for-each select="$allBaseIDs">
                        <xsl:sort select="string-length(@id)" order="descending"/>
                        <xsl:if test="matches($id, concat('^', @id, '\.'))">
                            <bid xmlns="" id="{@id}" prefix="{@prefix}"/>
                        </xsl:if>
                    </xsl:for-each>
                </xsl:variable>
                
                <xsl:choose>
                    <xsl:when test="string-length(($allbids/bid/@prefix)[1]) &gt; 0">
                        <xsl:variable name="thebidi" select="($allbids/bid/@id)[1]"/>
                        <xsl:variable name="thebidp" select="($allbids/bid/@prefix)[1]"/>
                        <span style="color: grey;" xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:value-of select="$thebidp"/>
                        </span>
                        <xsl:value-of select="replace($id, concat('^', $thebidi, '\.'), '')"/>
                    </xsl:when>
                    <xsl:when test="string-length($projectId) gt 0 and matches($id, concat('^', $projectId, '\.77\.2'))">
                        <span style="color: grey;" xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:value-of select="concat($projectPrefix, 'concept-')"/>
                        </span>
                        <xsl:value-of select="replace($id, concat('^', $projectId, '\.77\.2\.'), '')"/>
                    </xsl:when>
                    <xsl:when test="string-length($projectId) gt 0 and matches($id, concat('^', $projectId))">
                        <span style="color: grey;" xmlns="http://www.w3.org/1999/xhtml">
                            <xsl:value-of select="$projectPrefix"/>
                        </span>
                        <xsl:value-of select="replace($id, concat('^', $projectId, '\.'), '')"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$id"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="check4Issue">
        <xsl:param name="id"/>
        <xsl:param name="effectiveDate"/>
        <xsl:param name="colspans"/>
        <xsl:variable name="relatedIssues" select="$allIssues/issue[object[@id = $id][@effectiveDate = $effectiveDate]]" as="element()*"/>
        <xsl:variable name="openIssues" select="$relatedIssues[tracking[@effectiveDate = max(parent::issue/tracking/xs:dateTime(@effectiveDate))][last()][@statusCode = ('new', 'open', 'inprogress', 'feedback', 'deferred')]]" as="element()*"/>
        <xsl:variable name="cis" select="count($openIssues)"/>
        <xsl:if test="$cis > 0">
            <!-- 
                from all issue status codes:
                new open inprogress feedback closed rejected deferred cancelled
                
                issues where no immediate action is required ("closed") are:
                closed rejected cancelled
                
                and "open" issues are:
                new open inprogress feedback deferred
            -->
            <tr style="vertical-align: top;" xmlns="http://www.w3.org/1999/xhtml">
                <td style="text-align: center;">
                    <xsl:call-template name="showIcon">
                        <xsl:with-param name="which">notice</xsl:with-param>
                    </xsl:call-template>
                </td>
                <td>
                    <xsl:if test="$colspans > 1">
                        <xsl:attribute name="colspan" select="$colspans"/>
                    </xsl:if>
                    <xsl:choose>
                        <xsl:when test="$cis = 1">
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'ThereIsAnOpenIssueWithThisItem'"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="getMessage">
                                <xsl:with-param name="key" select="'ThereAreOpenIssuesWithThisItem'"/>
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                    <ul>
                        <xsl:for-each select="$openIssues">
                            <li>
                                <a href="{local:doHtmlName('IS',@id,@effectiveDate,'.html')}" onclick="target='_blank';">
                                    <xsl:call-template name="doShorthandId">
                                        <xsl:with-param name="id" select="@id"/>
                                    </xsl:call-template>
                                </a>
                                <xsl:text>: </xsl:text>
                                <i>
                                    <xsl:value-of select="@displayName"/>
                                </i>
                                <xsl:text> (</xsl:text>
                                <xsl:call-template name="getXFormsLabel">
                                    <xsl:with-param name="simpleTypeKey" select="'IssueStatusCodeLifeCycle'"/>
                                    <xsl:with-param name="simpleTypeValue" select="(tracking[@effectiveDate = max(parent::issue/tracking/xs:dateTime(@effectiveDate))]/@statusCode)[last()]"/>
                                    <xsl:with-param name="lang" select="$defaultLanguage"/>
                                </xsl:call-template>
                                <xsl:text>)</xsl:text>
                            </li>
                        </xsl:for-each>
                    </ul>
                </td>
            </tr>
        </xsl:if>
    </xsl:template>
    <xsl:template name="doMessage">
        <xsl:param name="level" select="'error'"/>
        <xsl:param name="msg"/>
        <!-- 
            show message msg as an info, warning or error
            
            context: a table row within a <table>
        -->
        <xsl:if test="string-length($msg) &gt; 0">
            <xsl:choose>
                <xsl:when test="$level = 'info'">
                    <tr xmlns="http://www.w3.org/1999/xhtml">
                        <td style="vertical-align: top;">
                            <xsl:call-template name="showIcon">
                                <xsl:with-param name="which">info</xsl:with-param>
                            </xsl:call-template>
                        </td>
                        <td style="vertical-align: top;">
                            <span style="color: #99CCFF;">
                                <strong>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'infoWord'"/>
                                    </xsl:call-template>
                                    <xsl:text>: </xsl:text>
                                    <xsl:value-of select="$msg"/>
                                </strong>
                            </span>
                        </td>
                    </tr>
                </xsl:when>
                <xsl:when test="$level = 'warning'">
                    <tr xmlns="http://www.w3.org/1999/xhtml">
                        <td style="vertical-align: top;">
                            <xsl:call-template name="showIcon">
                                <xsl:with-param name="which">notice</xsl:with-param>
                            </xsl:call-template>
                        </td>
                        <td style="vertical-align: top;">
                            <span style="color: orange;">
                                <strong>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'warningWord'"/>
                                    </xsl:call-template>
                                    <xsl:text>: </xsl:text>
                                    <xsl:value-of select="$msg"/>
                                </strong>
                            </span>
                        </td>
                    </tr>
                </xsl:when>
                <xsl:when test="$level = 'issue'">
                    <tr xmlns="http://www.w3.org/1999/xhtml">
                        <td style="vertical-align: top;">
                            <xsl:call-template name="showIcon">
                                <xsl:with-param name="which">notice</xsl:with-param>
                            </xsl:call-template>
                        </td>
                        <td style="vertical-align: top;">
                            <span style="color: orange;">
                                <strong>
                                    <xsl:value-of select="$msg"/>
                                </strong>
                            </span>
                        </td>
                    </tr>
                </xsl:when>
                <xsl:otherwise>
                    <!-- handle this as an error -->
                    <tr xmlns="http://www.w3.org/1999/xhtml">
                        <td style="vertical-align: top;">
                            <xsl:call-template name="showIcon">
                                <xsl:with-param name="which">alert</xsl:with-param>
                            </xsl:call-template>
                        </td>
                        <td style="vertical-align: top;">
                            <span style="color: red;">
                                <strong>
                                    <xsl:call-template name="getMessage">
                                        <xsl:with-param name="key" select="'errorWord'"/>
                                    </xsl:call-template>
                                    <xsl:text>: </xsl:text>
                                    <xsl:value-of select="$msg"/>
                                </strong>
                            </span>
                        </td>
                    </tr>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:template>
    <xsl:template name="showIssueType">
        <xsl:param name="it"/>
        <xsl:choose>
            <xsl:when test="$it = 'INC'">
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'issueTypeINC'"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$it = 'RFC'">
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'issueTypeRFC'"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$it = 'CLF'">
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'issueTypeCLF'"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$it = 'FUT'">
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'issueTypeFUT'"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$it"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="outputPath">
        <xsl:param name="pathname"/>
        <xsl:variable name="isawhere" select="starts-with($pathname, '[')"/>
        <xsl:variable name="hasawhere" select="contains($pathname, '[')"/>
        <xsl:if test="$hasawhere">
            <xsl:if test="not($isawhere)">
                <span style="font-family: Courier, 'Courier New', monospace; font-weight: bold;">
                    <xsl:value-of select="substring-before($pathname, '[')"/>
                </span>
                <br xmlns="http://www.w3.org/1999/xhtml"/>
            </xsl:if>
            <xsl:call-template name="getMessage">
                <xsl:with-param name="key" select="'whereX'"/>
            </xsl:call-template>
            <xsl:text> </xsl:text>
        </xsl:if>
        <!-- split up pathnames concatenated with | (or) and output them seperately -->
        <xsl:variable name="x">
            <xsl:call-template name="tokenize">
                <xsl:with-param name="string">
                    <xsl:value-of select="$pathname"/>
                </xsl:with-param>
                <xsl:with-param name="delimiters">
                    <xsl:value-of select="string('|')"/>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:variable>
        <xsl:for-each select="$x/token">
            <xsl:if test="count(preceding-sibling::node())">
                <xsl:call-template name="getMessage">
                    <xsl:with-param name="key" select="'orY'"/>
                </xsl:call-template>
                <br xmlns="http://www.w3.org/1999/xhtml"/>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="$hasawhere">
                    <i xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:variable name="thep">
                            <xsl:call-template name="splitString">
                                <xsl:with-param name="str" select="substring(., string-length(substring-before(., '[')) + 1)"/>
                                <xsl:with-param name="del" select="string('/')"/>
                                <xsl:with-param name="preceedIndent" select="string('_')"/>
                            </xsl:call-template>
                        </xsl:variable>
                        <xsl:value-of select="replace($thep, '\[', ' [')"/>
                    </i>
                </xsl:when>
                <xsl:otherwise>
                    <span style="font-family: Courier, 'Courier New', monospace; font-weight: bold;">
                        <xsl:call-template name="splitString">
                            <xsl:with-param name="str" select="."/>
                            <xsl:with-param name="del" select="string('/')"/>
                            <xsl:with-param name="preceedIndent" select="string('_')"/>
                        </xsl:call-template>
                    </span>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="addAssetsHeader">
        <xsl:param name="doTreeTable" as="xs:boolean?"/>
        <xsl:param name="treeTableCollapsed" select="true()" as="xs:boolean"/>
        <xsl:param name="treeTableColumnIndex" select="0" as="xs:integer"/>
        <link href="{$theAssetsDir}decor.css" rel="stylesheet" type="text/css" xmlns="http://www.w3.org/1999/xhtml"/>
        <link href="{$theAssetsDir}favicon.ico" rel="shortcut icon" type="image/x-icon" xmlns="http://www.w3.org/1999/xhtml"/>
        <xsl:choose>
            <xsl:when test="$switchCreateTreeTableHtml = 'true' and $doTreeTable">
                <link href="{$theAssetsDir}css/retrieve-template.css" rel="stylesheet" type="text/css" xmlns="http://www.w3.org/1999/xhtml"/>
                <script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:text>window.treeTableCollapsed = </xsl:text>
                    <xsl:value-of select="$treeTableCollapsed"/>
                    <xsl:text>;</xsl:text>
                    <xsl:text>window.treeTableStringCollapse ='</xsl:text>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Collapse'"/>
                    </xsl:call-template>
                    <xsl:text>';</xsl:text>
                    <xsl:text>window.treeTableStringExpand = '</xsl:text>
                    <xsl:call-template name="getMessage">
                        <xsl:with-param name="key" select="'Expand'"/>
                    </xsl:call-template>
                    <xsl:text>';</xsl:text>
                    <xsl:text>window.treeTableColumn = </xsl:text>
                    <xsl:value-of select="$treeTableColumnIndex"/>
                    <xsl:text>;</xsl:text>
                </script>
                <script src="{$theAssetsDir}scripts/jquery-1.11.3.min.js" type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"/>
                <script src="{$theAssetsDir}scripts/jquery.treetable.js" type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"/>
                <script src="{$theAssetsDir}scripts/retrieve-transaction.js" type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"/>
            </xsl:when>
            <xsl:otherwise>
                <script src="{$theAssetsDir}motoggle.js" type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"/>
                <script src="{$theAssetsDir}mootools-core.js" type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"/>
                <script src="{$theAssetsDir}mootools-more.js" type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"/>
                <script src="{$theAssetsDir}mootools-TabSwapper.js" type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="addAssetsBottom">
        <xsl:param name="doTreeTable" as="xs:boolean?"/>
        <xsl:choose>
            <xsl:when test="$switchCreateTreeTableHtml = 'true' and $doTreeTable"/>
            <xsl:otherwise>
                <script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml">
                function RefreshAccordion (theAccId) {
                    new Fx.Accordion($(theAccId), '#' + theAccId + ' .AccordionPanelTab', '#' + theAccId + ' .AccordionPanelContent', {
                        display: -1,
                        alwaysHide: true
                    });
                };
                window.addEvent('domready', function(){
                    // init accordions
                    /* Accordionds Accordionsi Accordionsc Accordionvs Accordionid Accordionrl Accordionis Accordionce */
                    
                    RefreshAccordion('Accordionds');
                    RefreshAccordion('Accordionsi');
                    RefreshAccordion('Accordionsc');
                    RefreshAccordion('Accordionvs');
                    RefreshAccordion('Accordionid');
                    RefreshAccordion('Accordionrl');
                    RefreshAccordion('Accordionis');
                    RefreshAccordion('Accordionce');
                    //2DO: schematron zip met xhr HEAD
                });
                </script>
                <script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml">
                /* init all tooltips */
                //store titles and text
                $$('a.tipz').each(function(element,index) {
                    var content = element.get('title').split('::');
                    element.store('tip:title', content[0]);
                    element.store('tip:text', content[1]);
                });
                
                //create the tooltips
                var tipz = new Tips('.tipz',{
                    className: 'tip',
                    fixed: true,
                    hideDelay: 50,
                    showDelay: 50
                });
                </script>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="doLabelMiracle">
        <xsl:param name="labelcandidate" as="xs:string"/>
        <xsl:choose>
            <xsl:when test="string-length($labelcandidate) &gt; 9">
                <!-- make it 4 chars (begin) ... 4 chars (end) -->
                <xsl:value-of select="substring($labelcandidate, 1, 4)"/>
                <!--<xsl:value-of select="'…'"/>-->
                <xsl:call-template name="showIcon">
                    <xsl:with-param name="which">dots</xsl:with-param>
                    <xsl:with-param name="tooltip" select="$labelcandidate"/>
                </xsl:call-template>
                <xsl:value-of select="substring($labelcandidate, string-length($labelcandidate) - 3)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$labelcandidate"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:function name="local:doHtmlName" as="xs:string?">
        <!-- Use an DecorObjectType enumeration value, or tab name -->
        <xsl:param name="type" as="xs:string?"/>
        <!-- object id -->
        <xsl:param name="id" as="xs:string?"/>
        <!-- object dateTime or DYNAMIC -->
        <xsl:param name="effectiveDate" as="xs:string?"/>
        <!-- file extension including dot, e.g. .html -->
        <xsl:param name="extension" as="xs:string"/>
        <xsl:value-of select="local:doHtmlName($type, $artdecordeeplinkprefix, $projectPrefix, $id, $effectiveDate, (), (), (), (), $extension, false(), 'html')"/>
    </xsl:function>
    <xsl:function name="local:doHtmlName" as="xs:string?">
        <!-- Use an DecorObjectType enumeration value, or tab name -->
        <xsl:param name="type" as="xs:string?"/>
        <!-- object id -->
        <xsl:param name="id" as="xs:string?"/>
        <!-- object dateTime or DYNAMIC -->
        <xsl:param name="effectiveDate" as="xs:string?"/>
        <!-- file extension including dot, e.g. .html -->
        <xsl:param name="extension" as="xs:string"/>
        <!-- dofile? disregard callerContext and create a real name -->
        <xsl:param name="dofile" as="xs:boolean"/>
        <xsl:value-of select="local:doHtmlName($type, $artdecordeeplinkprefix, $projectPrefix, $id, $effectiveDate, (), (), (), (), $extension, $dofile, 'html')"/>
    </xsl:function>
    <xsl:function name="local:doHtmlName" as="xs:string?">
        <!-- 1 Use an DecorObjectType enumeration value, or tab name -->
        <xsl:param name="type" as="xs:string?"/>
        <!-- 2 Project prefix to get info from, relevant for ART and DECOR links -->
        <xsl:param name="prefix" as="xs:string?"/>
        <!-- 3 object id -->
        <xsl:param name="id" as="xs:string?"/>
        <!-- 4 object dateTime or DYNAMIC -->
        <xsl:param name="effectiveDate" as="xs:string?"/>
        <!-- 5 object subid, e.g. dataset inside transaction -->
        <xsl:param name="subid" as="xs:string?"/>
        <!-- 6 object subeffectiveDate, e.g. dataset inside transaction -->
        <xsl:param name="subeffectiveDate" as="xs:string?"/>
        <!-- 7 object subsubid, e.g. concept inside dataset inside transaction -->
        <xsl:param name="subsubid" as="xs:string?"/>
        <!-- 8 object subsubeffectiveDate, e.g. concept inside dataset inside transaction -->
        <xsl:param name="subsubeffectiveDate" as="xs:string?"/>
        <!-- 9 file extension including dot, e.g. .html -->
        <xsl:param name="extension" as="xs:string"/>
        <!-- 10 dofile? disregard callerContext and create a real name -->
        <xsl:param name="dofile" as="xs:boolean"/>
        <xsl:value-of select="local:doHtmlName($type, $artdecordeeplinkprefix, $prefix, $id, $effectiveDate, $subid, $subeffectiveDate, $subsubid, $subsubeffectiveDate, $extension, $dofile, 'html')"/>
    </xsl:function>
    <xsl:function name="local:doHtmlName" as="xs:string?">
        <!-- 1 Use an DecorObjectType enumeration value, or tab name -->
        <xsl:param name="type" as="xs:string?"/>
        <!-- 2 Project artdecordeeplink to get info from, relevant for ART and DECOR links -->
        <xsl:param name="artdecordeeplink" as="xs:string?"/>
        <!-- 3 Project prefix to get info from, relevant for ART and DECOR links -->
        <xsl:param name="prefix" as="xs:string?"/>
        <!-- 4 object id -->
        <xsl:param name="id" as="xs:string?"/>
        <!-- 5 object dateTime or DYNAMIC -->
        <xsl:param name="effectiveDate" as="xs:string?"/>
        <!-- 6 object subid, e.g. dataset inside transaction -->
        <xsl:param name="subid" as="xs:string?"/>
        <!-- 7 object subeffectiveDate, e.g. dataset inside transaction -->
        <xsl:param name="subeffectiveDate" as="xs:string?"/>
        <!-- 8 object subsubid, e.g. concept inside dataset inside transaction -->
        <xsl:param name="subsubid" as="xs:string?"/>
        <!-- 9 object subsubeffectiveDate, e.g. concept inside dataset inside transaction -->
        <xsl:param name="subsubeffectiveDate" as="xs:string?"/>
        <!-- 10 file extension including dot, e.g. .html -->
        <xsl:param name="extension" as="xs:string"/>
        <!-- 11 dofile? disregard callerContext and create a real name -->
        <xsl:param name="dofile" as="xs:boolean"/>
        <xsl:value-of select="local:doHtmlName($type, $artdecordeeplink, $prefix, $id, $effectiveDate, $subid, $subeffectiveDate, $subsubid, $subsubeffectiveDate, $extension, $dofile, 'html')"/>
    </xsl:function>
    <xsl:function name="local:doHtmlName" as="xs:string?">
        <!-- 1 Use an DecorObjectType enumeration value, or tab name -->
        <xsl:param name="type" as="xs:string?"/>
        <!-- 2 Project artdecordeeplink to get info from, relevant for ART and DECOR links -->
        <xsl:param name="artdecordeeplink" as="xs:string?"/>
        <!-- 3 Project prefix to get info from, relevant for ART and DECOR links -->
        <xsl:param name="prefix" as="xs:string?"/>
        <!-- 4 object id -->
        <xsl:param name="id" as="xs:string?"/>
        <!-- 5 object dateTime or DYNAMIC -->
        <xsl:param name="effectiveDate" as="xs:string?"/>
        <!-- 6 object subid, e.g. dataset inside transaction -->
        <xsl:param name="subid" as="xs:string?"/>
        <!-- 7 object subeffectiveDate, e.g. dataset inside transaction -->
        <xsl:param name="subeffectiveDate" as="xs:string?"/>
        <!-- 8 object subsubid, e.g. concept inside dataset inside transaction -->
        <xsl:param name="subsubid" as="xs:string?"/>
        <!-- 9 object subsubeffectiveDate, e.g. concept inside dataset inside transaction -->
        <xsl:param name="subsubeffectiveDate" as="xs:string?"/>
        <!-- 10 file extension including dot, e.g. .html -->
        <xsl:param name="extension" as="xs:string"/>
        <!-- 11 dofile? disregard callerContext and create a real name -->
        <xsl:param name="dofile" as="xs:boolean"/>
        <!-- 12 format - use this as format specifier. html is default -->
        <xsl:param name="format" as="xs:string"/>
        
        <xsl:variable name="seeThisUrlLocation">
            <xsl:choose>
                <!-- Cannot do non-html on live or live-vue -->
                <xsl:when test="not($format = 'html') and $seeThisUrlLocation = 'live-vue'">live-services-vue</xsl:when>
                <!-- Cannot do non-html on live or live-vue -->
                <xsl:when test="not($format = 'html')">live-services</xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$seeThisUrlLocation"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!-- AD3 API supports view for format=html and extract for all others -->
        <xsl:variable name="extractOrView" select="if ($format = 'html') then '/$view' else concat('/$extract?format=', $format)"/>
        
        <xsl:variable name="seethis" as="xs:string?">
            <xsl:variable name="link" select="($artdecordeeplink[not(. = '')], $artdecordeeplinkprefix)[1]"/>
            <xsl:choose>
                <xsl:when test="$seeThisUrlLocation = 'live'">
                    <xsl:value-of select="replace(replace($link, '/art-decor/', '/art-decor/'), '/decor/services/' , '/art-decor/')"/>
                </xsl:when>
                <xsl:when test="$seeThisUrlLocation = 'live-services'">
                    <xsl:value-of select="replace(replace($link, '/art-decor/', '/decor/services/'), 'localhost:\d+(/exist/apps)?/', 'localhost:8877/exist/apps/')"/>
                </xsl:when>
                <!-- e.g. https://decor.nictiz.nl/ad/#/prefix/terminology/valueset/id/effectiveDate -->
                <xsl:when test="$seeThisUrlLocation = 'live-vue'">
                    <xsl:value-of select="replace(replace($link, '/art-decor/', '/ad/#/'), '/decor/services/' , '/ad/#/')"/>
                </xsl:when>
                <!-- https://decor.nictiz.nl/exist/apps/api/object/id/effectiveDate/$extract?language=nl-NL&amp;format=xml&amp;project=prefix -->
                <xsl:when test="$seeThisUrlLocation = 'live-services-vue'">
                    <xsl:value-of select="replace(replace(replace($link, '/art-decor/', '/exist/apps/api/'), '/decor/services/' , '/exist/apps/api/'), 'localhost:\d+', 'localhost:8877')"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$link"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="string">
            <xsl:choose>
                <xsl:when test="$seeThisUrlLocation = ('live-vue', 'live-services-vue') and not($dofile)">
                    <xsl:value-of select="$seethis"/>
                    <xsl:choose>
                        <!-- Dataset -->
                        <!-- Concept -->
                        <!-- Concept List -->
                        <!-- https://.../ad/#/demo1-/datasets/dataset/id/effectiveDate -->
                        <!-- https://.../ad/#/demo1-/datasets/dataset/id/effectiveDate/concept/id/effectiveDate -->
                        <xsl:when test="$type = ('DS', 'CL', 'tabDataSet')">
                            <xsl:choose>
                                <xsl:when test="$seeThisUrlLocation = 'live-services-vue'">
                                    <xsl:choose>
                                        <xsl:when test="string-length($subid) gt 0">
                                            <xsl:text>concept/</xsl:text>
                                            <xsl:value-of select="encode-for-uri($subid)"/>
                                            <xsl:text>/</xsl:text>
                                            <xsl:value-of select="encode-for-uri($subeffectiveDate)"/>
                                            <xsl:value-of select="$extractOrView"/>
                                        </xsl:when>
                                        <xsl:when test="string-length($id) gt 0">
                                            <xsl:text>dataset/</xsl:text>
                                            <xsl:value-of select="encode-for-uri($id)"/>
                                            <xsl:text>/</xsl:text>
                                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                            <xsl:value-of select="$extractOrView"/>
                                        </xsl:when>
                                    </xsl:choose>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>/datasets/dataset</xsl:text>
                                    <xsl:if test="string-length($id) gt 0">
                                        <xsl:text>/</xsl:text>
                                        <xsl:value-of select="encode-for-uri($id)"/>
                                        <xsl:if test="string-length($effectiveDate) gt 0">
                                            <xsl:text>/</xsl:text>
                                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                            <xsl:if test="string-length($subid) &gt; 0">
                                                <xsl:text>/concept/</xsl:text>
                                                <xsl:value-of select="encode-for-uri($subid)"/>
                                                <xsl:text>/</xsl:text>
                                                <xsl:value-of select="encode-for-uri($subeffectiveDate)"/>
                                            </xsl:if>
                                        </xsl:if>
                                    </xsl:if>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <!-- Scenario -->
                        <!-- Transaction -->
                        <!-- https://.../ad/#/demo1-/scenarios/scenarios/id/effectiveDate -->
                        <!-- https://.../ad/#/demo1-/scenarios/scenarios/id/effectiveDate/concepts/id/effectiveDate -->
                        <xsl:when test="$type = ('SC', 'TR', 'tabScenarios')">
                            <xsl:choose>
                                <xsl:when test="$seeThisUrlLocation = 'live-services-vue' and $type = 'TR'">
                                    <xsl:text>transaction/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($id)"/>
                                    <xsl:text>/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                    <xsl:value-of select="$extractOrView"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>/scenarios/scenarios</xsl:text>
                                    <xsl:if test="string-length($id) gt 0">
                                        <xsl:text>/</xsl:text>
                                        <xsl:value-of select="encode-for-uri($id)"/>
                                        <xsl:if test="string-length($effectiveDate) gt 0">
                                            <xsl:text>/</xsl:text>
                                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                            <xsl:if test="string-length($subid) &gt; 0">
                                                <xsl:text>/concepts/</xsl:text>
                                                <xsl:value-of select="encode-for-uri($subid)"/>
                                                <xsl:text>/</xsl:text>
                                                <xsl:value-of select="encode-for-uri($subeffectiveDate)"/>
                                            </xsl:if>
                                        </xsl:if>
                                    </xsl:if>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <!-- Actor -->
                        <!-- https://.../ad/#/demo1-/scenarios/actors -->
                        <xsl:when test="$type = 'AC'">
                            <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                            <xsl:text>/scenarios/actors</xsl:text>
                        </xsl:when>
                        <!-- CodeSystem -->
                        <!-- https://.../ad/#/peri20-/terminology/codesystems/id/effectiveDate -->
                        <xsl:when test="$type = 'CS'">
                            <xsl:choose>
                                <xsl:when test="$seeThisUrlLocation = 'live-services-vue'">
                                    <xsl:text>codesystem/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($id)"/>
                                    <xsl:text>/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                    <xsl:value-of select="$extractOrView"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>/terminology/codesystems</xsl:text>
                                    <xsl:if test="string-length($id) gt 0">
                                        <xsl:text>/</xsl:text>
                                        <xsl:value-of select="encode-for-uri($id)"/>
                                        <xsl:if test="string-length($effectiveDate) gt 0">
                                            <xsl:text>/</xsl:text>
                                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                        </xsl:if>
                                    </xsl:if>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <!-- ValueSet  -->
                        <!-- https://.../ad/#/peri20-/terminology/valueset/id/effectiveDate -->
                        <xsl:when test="$type = ('VS', 'tabTerminology')">
                            <xsl:choose>
                                <xsl:when test="$seeThisUrlLocation = 'live-services-vue'">
                                    <xsl:text>valueset/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($id)"/>
                                    <xsl:text>/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                    <xsl:value-of select="$extractOrView"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>/terminology/valueset</xsl:text>
                                    <xsl:if test="string-length($id) gt 0">
                                        <xsl:text>/</xsl:text>
                                        <xsl:value-of select="encode-for-uri($id)"/>
                                        <xsl:if test="string-length($effectiveDate) gt 0">
                                            <xsl:text>/</xsl:text>
                                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                        </xsl:if>
                                    </xsl:if>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <!-- ConceptMap -->
                        <!-- https://.../ad/#/demo11-/terminology/conceptmaps/id/effectiveDate -->
                        <xsl:when test="$type = 'MP'">
                            <xsl:choose>
                                <xsl:when test="$seeThisUrlLocation = 'live-services-vue'">
                                    <xsl:text>conceptmap/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($id)"/>
                                    <xsl:text>/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                    <xsl:value-of select="$extractOrView"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>/terminology/conceptmaps</xsl:text>
                                    <xsl:if test="string-length($id) gt 0">
                                        <xsl:text>/</xsl:text>
                                        <xsl:value-of select="encode-for-uri($id)"/>
                                        <xsl:if test="string-length($effectiveDate) gt 0">
                                            <xsl:text>/</xsl:text>
                                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                        </xsl:if>
                                    </xsl:if>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <!-- Issue  -->
                        <!-- https://decor.nictiz.nl/ad/#/demo1-/issues/issues/id -->
                        <xsl:when test="$type = ('IS', 'tabIssues')">
                            <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                            <xsl:text>/issues/issues</xsl:text>
                            <xsl:choose>
                                <xsl:when test="string-length($subid) = 0">
                                    <xsl:text>/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($id)"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($subid)"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <!-- Rules  -->
                        <!-- Template  -->
                        <!-- Template Element -->
                        <!-- https://decor.nictiz.nl/ad/#/demo1-/rules/templates  -->
                        <xsl:when test="$type = ('RL', 'TM', 'EL', 'tabRules')">
                            <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                            <xsl:text>/rules/templates</xsl:text>
                            <xsl:if test="string-length($id) gt 0">
                                <xsl:text>/</xsl:text>
                                <xsl:value-of select="encode-for-uri($id)"/>
                                <xsl:if test="string-length($effectiveDate) gt 0">
                                    <xsl:text>/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                </xsl:if>
                            </xsl:if>
                        </xsl:when>
                        <!-- Questionnaire  -->
                        <!-- https://.../ad/#/demo10-/rules/questionnaires/id/effectiveDate -->
                        <xsl:when test="$type = 'QQ'">
                            <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                            <xsl:text>/rules/questionnaires</xsl:text>
                            <xsl:if test="string-length($id) gt 0">
                                <xsl:text>/</xsl:text>
                                <xsl:value-of select="encode-for-uri($id)"/>
                                <xsl:if test="string-length($effectiveDate) gt 0">
                                    <xsl:text>/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                </xsl:if>
                            </xsl:if>
                        </xsl:when>
                        <!-- Scenario test -->
                        <xsl:when test="$type = 'SX'"><!-- not supported --></xsl:when>
                        <!-- Dataelement test -->
                        <xsl:when test="$type = 'TX'"><!-- not supported --></xsl:when>
                        <!-- Transaction test -->
                        <xsl:when test="$type = 'EX'"><!-- not supported --></xsl:when>
                        <!-- Requirement test -->
                        <xsl:when test="$type = 'QX'"><!-- not supported --></xsl:when>
                        <!-- Community -->
                        <!-- https://.../ad/#/demo1-/project/community/communityName/associations/dataset/id/effectiveDate/conceptId/conceptEffectiveDate -->
                        <xsl:when test="$type = 'CM'">
                            <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                            <xsl:text>/project/community</xsl:text>
                            <xsl:if test="string-length($id) gt 0">
                                <xsl:text>/</xsl:text>
                                <xsl:value-of select="encode-for-uri($id)"/>
                                <xsl:text>/associations</xsl:text>
                                <xsl:if test="string-length($subid) gt 0">
                                    <xsl:text>/dataset/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($subid)"/>
                                    <xsl:if test="string-length($subeffectiveDate) gt 0">
                                        <xsl:text>/</xsl:text>
                                        <xsl:value-of select="encode-for-uri($subeffectiveDate)"/>
                                        <xsl:if test="string-length($subsubid) gt 0">
                                            <xsl:text>/</xsl:text>
                                            <xsl:value-of select="encode-for-uri($subsubid)"/>
                                            <xsl:if test="string-length($subsubeffectiveDate) gt 0">
                                                <xsl:text>/</xsl:text>
                                                <xsl:value-of select="encode-for-uri($subsubeffectiveDate)"/>
                                            </xsl:if>
                                        </xsl:if>
                                    </xsl:if>
                                </xsl:if>
                            </xsl:if>
                        </xsl:when>
                        <xsl:otherwise/>
                    </xsl:choose>
                </xsl:when>
                <xsl:when test="$seeThisUrlLocation = ('live', 'live-services') and not($dofile)">
                    <xsl:value-of select="$seethis"/>
                    <xsl:choose>
                        <!-- Dataset -->
                        <xsl:when test="$type = ('DS', 'tabDataSet')">
                            <xsl:choose>
                                <xsl:when test="contains($seethis, 'decor/services')">
                                    <xsl:text>RetrieveDataSet?format=</xsl:text>
                                    <xsl:value-of select="$format"/>
                                    <xsl:text>&amp;collapsable=true&amp;prefix=</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>&amp;version=</xsl:text>
                                    <xsl:value-of select="$latestVersion"/>
                                    <xsl:text>&amp;</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>decor-datasets--</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>?</xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text>id=</xsl:text>
                            <xsl:value-of select="encode-for-uri($id)"/>
                            <xsl:text>&amp;effectiveDate=</xsl:text>
                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                            <xsl:if test="string-length($subid) &gt; 0">
                                <xsl:text>&amp;conceptId=</xsl:text>
                                <xsl:value-of select="encode-for-uri($subid)"/>
                                <xsl:text>&amp;conceptEffectiveDate=</xsl:text>
                                <xsl:value-of select="encode-for-uri($subeffectiveDate)"/>
                            </xsl:if>
                        </xsl:when>
                        <!-- Scenario -->
                        <xsl:when test="$type = ('SC', 'tabScenarios')">
                            <xsl:text>decor-scenarios--</xsl:text>
                            <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                            <xsl:text>?id=</xsl:text>
                            <xsl:choose>
                                <xsl:when test="string-length($subid) = 0">
                                    <xsl:value-of select="encode-for-uri($id)"/>
                                    <xsl:text>&amp;effectiveDate=</xsl:text>
                                    <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="encode-for-uri($subid)"/>
                                    <xsl:text>&amp;effectiveDate=</xsl:text>
                                    <xsl:value-of select="encode-for-uri($subeffectiveDate)"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <!-- Transaction -->
                        <xsl:when test="$type = 'TR'">
                            <xsl:choose>
                                <xsl:when test="contains($seethis, 'decor/services')">
                                    <xsl:text>RetrieveTransaction?format=</xsl:text>
                                    <xsl:value-of select="$format"/>
                                    <xsl:text>&amp;collapsable=true&amp;prefix=</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>&amp;version=</xsl:text>
                                    <xsl:value-of select="$latestVersion"/>
                                    <xsl:text>&amp;</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>decor-scenarios--</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>?</xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text>id=</xsl:text>
                            <xsl:value-of select="encode-for-uri($id)"/>
                            <xsl:text>&amp;effectiveDate=</xsl:text>
                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                            <xsl:if test="string-length($subid) &gt; 0">
                                <xsl:text>&amp;datasetId=</xsl:text>
                                <xsl:value-of select="encode-for-uri($subid)"/>
                                <xsl:text>&amp;datasetEffectiveDate=</xsl:text>
                                <xsl:value-of select="encode-for-uri($subeffectiveDate)"/>
                                <xsl:if test="string-length($subsubid) &gt; 0">
                                    <xsl:text>&amp;conceptId=</xsl:text>
                                    <xsl:value-of select="encode-for-uri($subsubid)"/>
                                    <xsl:text>&amp;conceptEffectiveDate=</xsl:text>
                                    <xsl:value-of select="encode-for-uri($subsubeffectiveDate)"/>
                                </xsl:if>
                            </xsl:if>
                        </xsl:when>
                        <!-- Actor -->
                        <xsl:when test="$type = 'AC'">
                            <xsl:text>decor-scenarios--</xsl:text>
                            <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                            <xsl:text>?section=actors</xsl:text>
                        </xsl:when>
                        <!-- Valueset  -->
                        <xsl:when test="$type = ('VS', 'tabTerminology')">
                            <xsl:choose>
                                <xsl:when test="contains($seethis, 'decor/services')">
                                    <xsl:text>RetrieveValueSet?format=</xsl:text>
                                    <xsl:value-of select="$format"/>
                                    <xsl:text>&amp;collapsable=true&amp;prefix=</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>&amp;version=</xsl:text>
                                    <xsl:value-of select="$latestVersion"/>
                                    <xsl:text>&amp;</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>decor-valuesets--</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>?</xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text>id=</xsl:text>
                            <xsl:value-of select="encode-for-uri($id)"/>
                            <xsl:text>&amp;effectiveDate=</xsl:text>
                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                        </xsl:when>
                        <!-- Issue  -->
                        <xsl:when test="$type = ('IS', 'tabIssues')">
                            <xsl:text>decor-issues--</xsl:text>
                            <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                            <xsl:text>?id=</xsl:text>
                            <xsl:choose>
                                <xsl:when test="string-length($subid) = 0">
                                    <xsl:value-of select="encode-for-uri($id)"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="encode-for-uri($subid)"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <!-- Rules  -->
                        <xsl:when test="$type = ('RL', 'tabRules')">
                            <xsl:choose>
                                <xsl:when test="contains($seethis, 'decor/services')">
                                    <xsl:text>RetrieveTemplate?format=</xsl:text>
                                    <xsl:value-of select="$format"/>
                                    <xsl:text>&amp;collapsable=true&amp;prefix=</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>&amp;version=</xsl:text>
                                    <xsl:value-of select="$latestVersion"/>
                                    <xsl:text>&amp;</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>decor-templates--</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>?</xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:value-of select="encode-for-uri($id)"/>
                            <xsl:text>&amp;effectiveDate=</xsl:text>
                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                        </xsl:when>
                        <!-- Template  -->
                        <xsl:when test="$type = 'TM'">
                            <xsl:choose>
                                <xsl:when test="contains($seethis, 'decor/services')">
                                    <xsl:text>RetrieveTemplate?format=</xsl:text>
                                    <xsl:value-of select="$format"/>
                                    <xsl:text>&amp;collapsable=true&amp;prefix=</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>&amp;version=</xsl:text>
                                    <xsl:value-of select="$latestVersion"/>
                                    <xsl:text>&amp;</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>decor-templates--</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>?</xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text>id=</xsl:text>
                            <xsl:value-of select="encode-for-uri($id)"/>
                            <xsl:text>&amp;effectiveDate=</xsl:text>
                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                        </xsl:when>
                        <!-- Questionnaire  -->
                        <!-- http://localhost:8877/exist/apps/decor/services/RetrieveQuestionnaire?qrid=3fec5d40-168b-41de-ac5d-40168bc1dea8&amp;id=2.16.840.1.113883.3.1937.99.60.10.4.8&amp;effectiveDate=2023-02-23T00:00:00&amp;language=en-US&amp;ui=en-US&amp;format=html -->
                        <xsl:when test="$type = 'QQ'">
                            <xsl:choose>
                                <xsl:when test="contains($seethis, 'decor/services')">
                                    <xsl:text>RetrieveQuestionnaire?format=</xsl:text>
                                    <xsl:value-of select="$format"/>
                                    <xsl:text>&amp;prefix=</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>&amp;version=</xsl:text>
                                    <xsl:value-of select="$latestVersion"/>
                                    <xsl:text>&amp;id=</xsl:text>
                                    <xsl:value-of select="encode-for-uri($id)"/>
                                    <xsl:text>&amp;effectiveDate=</xsl:text>
                                    <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>/scenarios/questionnaires/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($id)"/>
                                    <xsl:text>/</xsl:text>
                                    <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <!-- Concept list  -->
                        <xsl:when test="$type = 'CL'">
                            <xsl:text>decor-datasets--</xsl:text>
                            <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                            <xsl:text>?id=</xsl:text>
                            <xsl:value-of select="encode-for-uri($id)"/>
                            <xsl:text>&amp;effectiveDate=</xsl:text>
                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                            <xsl:if test="string-length($subid) &gt; 0">
                                <xsl:text>&amp;conceptId=</xsl:text>
                                <xsl:value-of select="encode-for-uri($subid)"/>
                                <xsl:text>&amp;conceptEffectiveDate=</xsl:text>
                                <xsl:value-of select="encode-for-uri($subeffectiveDate)"/>
                            </xsl:if>
                        </xsl:when>
                        <!-- Template Element -->
                        <xsl:when test="$type = 'EL'">
                            <xsl:choose>
                                <xsl:when test="contains($seethis, 'decor/services')">
                                    <xsl:text>RetrieveTemplate?format=</xsl:text>
                                    <xsl:value-of select="$format"/>
                                    <xsl:text>&amp;collapsable=true&amp;prefix=</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>&amp;version=</xsl:text>
                                    <xsl:value-of select="$latestVersion"/>
                                    <xsl:text>&amp;</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>decor-templates--</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>?</xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:value-of select="encode-for-uri($id)"/>
                            <xsl:text>&amp;effectiveDate=</xsl:text>
                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                        </xsl:when>
                        <!-- Scenario test -->
                        <xsl:when test="$type = 'SX'"><!-- not supported --></xsl:when>
                        <!-- Dataelement test -->
                        <xsl:when test="$type = 'TX'"><!-- not supported --></xsl:when>
                        <!-- Transaction test -->
                        <xsl:when test="$type = 'EX'"><!-- not supported --></xsl:when>
                        <!-- Requirement test -->
                        <xsl:when test="$type = 'QX'"><!-- not supported --></xsl:when>
                        <!-- Community -->
                        <xsl:when test="$type = 'CM'">
                            <xsl:text>decor-mycommunity--</xsl:text>
                            <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                            <xsl:text>?name=</xsl:text>
                            <xsl:value-of select="encode-for-uri($id)"/>
                            <xsl:if test="string-length($subid) &gt; 0">
                                <xsl:text>&amp;datasetId=</xsl:text>
                                <xsl:value-of select="encode-for-uri($subid)"/>
                                <xsl:text>&amp;datasetEffectiveDate=</xsl:text>
                                <xsl:value-of select="encode-for-uri($subeffectiveDate)"/>
                                <xsl:if test="string-length($subsubid) &gt; 0">
                                    <xsl:text>&amp;conceptId=</xsl:text>
                                    <xsl:value-of select="encode-for-uri($subsubid)"/>
                                    <xsl:text>&amp;conceptEffectiveDate=</xsl:text>
                                    <xsl:value-of select="encode-for-uri($subsubeffectiveDate)"/>
                                </xsl:if>
                            </xsl:if>
                        </xsl:when>
                        <!-- Codesystem -->
                        <xsl:when test="$type = 'CS'">
                            <xsl:choose>
                                <xsl:when test="contains($seethis, 'decor/services')">
                                    <xsl:text>RetrieveCodeSystem?format=</xsl:text>
                                    <xsl:value-of select="$format"/>
                                    <xsl:text>&amp;collapsable=true&amp;prefix=</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>&amp;version=</xsl:text>
                                    <xsl:value-of select="$latestVersion"/>
                                    <xsl:text>&amp;</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>decor-codesystems--</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>?</xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text>id=</xsl:text>
                            <xsl:value-of select="encode-for-uri($id)"/>
                            <xsl:text>&amp;effectiveDate=</xsl:text>
                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                        </xsl:when>
                        <!-- ConceptMap -->
                        <xsl:when test="$type = 'MP'">
                            <xsl:choose>
                                <xsl:when test="contains($seethis, 'decor/services')">
                                    <xsl:text>RetrieveConceptMap?format=</xsl:text>
                                    <xsl:value-of select="$format"/>
                                    <xsl:text>&amp;collapsable=true&amp;prefix=</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>&amp;version=</xsl:text>
                                    <xsl:value-of select="$latestVersion"/>
                                    <xsl:text>&amp;</xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>decor-conceptmaps--</xsl:text>
                                    <xsl:value-of select="($prefix[not(. = '')], $projectPrefix)[1]"/>
                                    <xsl:text>?</xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                            <xsl:text>id=</xsl:text>
                            <xsl:value-of select="encode-for-uri($id)"/>
                            <xsl:text>&amp;effectiveDate=</xsl:text>
                            <xsl:value-of select="encode-for-uri($effectiveDate)"/>
                        </xsl:when>
                        <xsl:otherwise/>
                    </xsl:choose>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:variable name="tabName" select="$tabnameslist/tab[@key = $type]/@filename" as="xs:string?"/>
                    <xsl:variable name="fprefix" as="xs:string?">
                        <xsl:choose>
                            <xsl:when test="not(empty($tabName))"/>
                            <!-- Dataset -->
                            <xsl:when test="$type = 'DS'">ds</xsl:when>
                            <!-- Scenario -->
                            <xsl:when test="$type = 'SC'">sc</xsl:when>
                            <!-- Transaction -->
                            <xsl:when test="$type = 'TR'">tr</xsl:when>
                            <!-- Actor -->
                            <xsl:when test="$type = 'AC'">ac</xsl:when>
                            <!-- Valueset  -->
                            <xsl:when test="$type = 'VS'">voc</xsl:when>
                            <!-- Issue  -->
                            <xsl:when test="$type = 'IS'">iss</xsl:when>
                            <!-- Rules  -->
                            <xsl:when test="$type = 'RL'">rl</xsl:when>
                            <!-- Template  -->
                            <xsl:when test="$type = 'TM'">tmp</xsl:when>
                            <!-- Questionnaire -->
                            <xsl:when test="$type = 'QQ'">qq</xsl:when>
                            <!-- Concept list  -->
                            <xsl:when test="$type = 'CL'">cl</xsl:when>
                            <!-- Template Element -->
                            <xsl:when test="$type = 'EL'">el</xsl:when>
                            <!-- Scenario test -->
                            <xsl:when test="$type = 'SX'">sx</xsl:when>
                            <!-- Dataelement test -->
                            <xsl:when test="$type = 'TX'">tx</xsl:when>
                            <!-- Transaction test -->
                            <xsl:when test="$type = 'EX'">ex</xsl:when>
                            <!-- Requirement test -->
                            <xsl:when test="$type = 'QX'">qx</xsl:when>
                            <!-- Community -->
                            <xsl:when test="$type = 'CM'">cm</xsl:when>
                            <!-- Codesystem -->
                            <xsl:when test="$type = 'CS'">cs</xsl:when>
                            <!-- Codesystem -->
                            <xsl:when test="$type = 'MP'">mp</xsl:when>
                            <xsl:otherwise/>
                        </xsl:choose>
                    </xsl:variable>
                    <xsl:choose>
                        <xsl:when test="string-length($tabName) &gt; 0">
                            <xsl:value-of select="$tabName"/>
                        </xsl:when>
                        <xsl:when test="string-length($fprefix) &gt; 0 and string-length($effectiveDate) &gt; 0">
                            <xsl:value-of select="concat(string-join(($fprefix, $id, upper-case(replace($effectiveDate, ':', ''))), '-'), '.', replace($extension, '^\.+', ''))"/>
                        </xsl:when>
                        <xsl:when test="string-length($fprefix) &gt; 0">
                            <xsl:value-of select="concat(string-join(($fprefix, $id), '-'), '.', replace($extension, '^\.+', ''))"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="logMessage">
                                <xsl:with-param name="level" select="$logFATAL"/>
                                <xsl:with-param name="terminate" select="true()"/>
                                <xsl:with-param name="msg">
                                    <xsl:text>+++ (doHtmlName) Could not make a file name for type="</xsl:text>
                                    <xsl:value-of select="$type"/>
                                    <xsl:text>" - id="</xsl:text>
                                    <xsl:value-of select="$id"/>
                                    <xsl:text>" - effectiveDate="</xsl:text>
                                    <xsl:value-of select="$effectiveDate"/>
                                    <xsl:text>" - extension="</xsl:text>
                                    <xsl:value-of select="$extension"/>
                                    <xsl:text>"</xsl:text>
                                </xsl:with-param>
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:if test="string-length($subid) &gt; 0">
                        <xsl:text>#</xsl:text>
                        <xsl:value-of select="local:doHtmlAnchor($subid, $subeffectiveDate)"/>
                    </xsl:if>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:call-template name="logMessage">
            <xsl:with-param name="level" select="$logALL"/>
            <xsl:with-param name="msg">
                <xsl:text>+++ (doHtmlName) Result="</xsl:text>
                <xsl:value-of select="$string"/>
                <xsl:text>" Input - type="</xsl:text>
                <xsl:value-of select="$type"/>
                <xsl:text>" - id="</xsl:text>
                <xsl:value-of select="$id"/>
                <xsl:text>" - effectiveDate="</xsl:text>
                <xsl:value-of select="$effectiveDate"/>
                <xsl:text>" - subid="</xsl:text>
                <xsl:value-of select="$subid"/>
                <xsl:text>" - subeffectiveDate="</xsl:text>
                <xsl:value-of select="$subeffectiveDate"/>
                <xsl:text>" - subsubid="</xsl:text>
                <xsl:value-of select="$subid"/>
                <xsl:text>" - subsubeffectiveDate="</xsl:text>
                <xsl:value-of select="$subeffectiveDate"/>
                <xsl:text>" - extension="</xsl:text>
                <xsl:value-of select="$extension"/>
                <xsl:text>" - forschematron="</xsl:text>
                <xsl:value-of select="$dofile"/>
                <xsl:text>"</xsl:text>
                <xsl:text>" - format="</xsl:text>
                <xsl:value-of select="$format"/>
                <xsl:text>"</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:value-of select="$string"/>
    </xsl:function>
    <!-- build an HTML anchor that is unique AND stable over multiple builds. Don't include # so we can reuse for href too -->
    <xsl:function name="local:doHtmlAnchor" as="xs:string">
        <!-- Dataset concepts: id + effectiveTime -->
        <!-- Template elements: id -->
        <xsl:param name="id" as="xs:string"/>
        <xsl:param name="effectiveDate" as="xs:string?"/>
        <xsl:variable name="cleanId" select="replace($id, '\s', '')"/>
        <xsl:variable name="cleanDate" select="replace($effectiveDate, '[\sT:-]', '')"/>
        <xsl:value-of select="upper-case(concat('_', string-join(($cleanId, $cleanDate), '_')))"/>
    </xsl:function>
    <!-- show binding strength correctly -->
    <xsl:function name="local:getBindingStrength" as="xs:string?">
        <xsl:param name="os" as="xs:string?"/>
        <xsl:choose>
            <xsl:when test="$os = ('CNE', 'required')">required</xsl:when>
            <xsl:when test="$os = ('CWE', 'extensible')">extensible</xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$os"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:function>
    <xsl:function name="local:showBindingStrength" as="xs:string?">
        <xsl:param name="os" as="xs:string?"/>
        <xsl:param name="doHelp" as="xs:boolean"/>
        <xsl:if test="string-length($os) gt 0">
            <xsl:variable name="components" as="xs:string*">
                <xsl:choose>
                    <xsl:when test="$os = ('required', 'extensible', 'extensible', 'example')">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="
                                    concat('bindingStrength-', $os, if ($doHelp) then
                                        '-help'
                                    else
                                        ())"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:when test="$os = ('CNE')">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="
                                    concat('bindingStrength-', 'required', if ($doHelp) then
                                        '-help'
                                    else
                                        ())"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:when test="$os = ('CWE')">
                        <xsl:call-template name="getMessage">
                            <xsl:with-param name="key" select="
                                    concat('bindingStrength-', 'extensible', if ($doHelp) then
                                        '-help'
                                    else
                                        ())"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$os"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:choose>
                <xsl:when test="$doHelp">
                    <xsl:value-of select="string-join($components, '')"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="string-join(('(', $components, ')'), '')"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:function>
</xsl:stylesheet>
