<!--
    Copyright © ART-DECOR Expert Group and ART-DECOR Open Tools
    see https://docs.art-decor.org/copyright and https://docs.art-decor.org/licenses
    
    This program is free software; you can redistribute it and/or modify it under the terms of the
    GNU Lesser General Public License as published by the Free Software Foundation; either version
    2.1 of the License, or (at your option) any later version.
    
    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU Lesser General Public License for more details.
    
    The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
-->
<parts xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:widget="http://orbeon.org/oxf/xml/widget" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <!-- 
      Decor Concept readonly view
      Used in:
      decor-issues.xhtml
      decor-mycommunity.xhtml
      decor-scenarios.xhtml
      decor-template-editor.xhtml
      decor-template-mapping.xhtml
      decor-terminology.xhtml
      
      Requires variables:
      $decor-external-exist
      $resources
      $maxValueSetItems
     
      Requires instances:
      decor-types
      concept-associations
   -->
    <part id="concept-readonly">
        <xhtml:table class="detail spaced" width="100%">
            <!-- id and effectiveDate -->
            <xhtml:tr>
                <!-- id -->
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/id"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:output ref="if (@iddisplay) then @iddisplay else (@id)"/>
                </xhtml:td>
                <!-- effectiveDate -->
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/version"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:output ref="@effectiveDate" xxforms:format="if (. castable as xs:dateTime) then replace(format-dateTime(xs:dateTime(.),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else (.)"/>
                </xhtml:td>
            </xhtml:tr>
            <!-- statusCode and versionLabel -->
            <xhtml:tr>
                <!-- statusCode -->
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/status"/>
                </xhtml:td>
                <xhtml:td>
                    <xxforms:variable name="statusCode" select="@statusCode"/>
                    <xforms:output ref="instance('decor-types')/ItemStatusCodeLifeCycle/enumeration[@value=$statusCode]/label[@language=$resources/@xml:lang]" class="node-s{$statusCode}"/>
                </xhtml:td>
                <!-- versionLabel -->
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/versionLabel"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:output ref="@versionLabel"/>
                </xhtml:td>
            </xhtml:tr>
            <!-- header with ref -->
            <xforms:repeat ref="inherit | contains">
                <xhtml:tr class="not-selectable">
                    <xhtml:td colspan="4">
                        <xhtml:div class="h2">
                            <xxforms:variable name="prefix" select="@prefix"/>
                            <xxforms:variable name="datasetid" select="@datasetId"/>
                            <xxforms:variable name="dataseteff" select="@datasetEffectiveDate"/>
                            <xxforms:variable name="id" select="@ref"/>
                            <xxforms:variable name="effectiveDate" select="@flexibility[string-length()&gt;0] | @effectiveDate[string-length() gt 0]"/>
                            <xxforms:variable name="iddisplay" select="if (@iddisplay) then @iddisplay else ($id)"/>
                            <xxforms:variable name="statusCode" select="@iStatusCode"/>
                            <xxforms:variable name="versionLabel" select="@iVersionLabel"/>
                            <xforms:output ref="concat(if (self::contains) then $resources/reference else $resources/inherited-from,': ')"/>
                            <xforms:group ref=".[string-length($datasetid)&gt;0]">
                                <xforms:trigger appearance="minimal" class="node-s{$statusCode}">
                                    <xforms:label>
                                        <xforms:output ref="$iddisplay"/>
                                        <xforms:group ref="$effectiveDate">
                                            <xforms:output ref="$resources/as-of"/>
                                            <xforms:output ref="if ($effectiveDate castable as xs:dateTime) then replace(format-dateTime(xs:dateTime($effectiveDate),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else ($effectiveDate)"/>
                                        </xforms:group>
                                        <xforms:output ref="if (string-length($versionLabel)&gt;0) then concat(' (',$versionLabel,')') else ()"/>
                                    </xforms:label>
                                    <xforms:action ev:event="DOMActivate">
                                        <xforms:load resource="/decor-datasets--{$prefix}?id={$datasetid}&amp;effectiveDate={$dataseteff}&amp;conceptId={$id}&amp;conceptEffectiveDate={$effectiveDate}" show="new"/>
                                    </xforms:action>
                                </xforms:trigger>
                            </xforms:group>
                            <xforms:group ref=".[string-length($datasetid)=0]">
                                <xforms:output ref="$iddisplay"/>
                                <xforms:group ref="$effectiveDate">
                                    <xforms:output ref="$resources/as-of"/>
                                    <xforms:output ref="if ($effectiveDate castable as xs:dateTime) then replace(format-dateTime(xs:dateTime($effectiveDate),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else ($effectiveDate)"/>
                                </xforms:group>
                                <xforms:output ref="if (string-length($versionLabel)&gt;0) then concat(' (',$versionLabel,')') else ()"/>
                            </xforms:group>
                        </xhtml:div>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:repeat>
            <!-- concept synonym -->
            <xforms:group ref=".[synonym[@language=instance('language')]]">
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/synonym"/>
                    </xhtml:td>
                    <xhtml:td colspan="3">
                        <xhtml:table width="100%">
                            <xforms:repeat nodeset="synonym[@language=instance('language')]">
                                <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                    <xhtml:td>
                                        <xforms:output ref="."/>
                                    </xhtml:td>
                                </xhtml:tr>
                            </xforms:repeat>
                        </xhtml:table>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
            <!-- concept description -->
            <xhtml:tr>
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/description"/>
                </xhtml:td>
                <xhtml:td colspan="3">
                    <xforms:output mediatype="text/html" ref="desc[@language=instance('language')]"/>
                </xhtml:td>
            </xhtml:tr>
            <!-- concept relationship -->
            <xforms:group ref=".[relationship/@ref[not(.='')]]">
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/relations"/>
                    </xhtml:td>
                    <xhtml:td colspan="3">
                        <xhtml:table class="zebra-table" width="100%">
                            <xforms:repeat nodeset="relationship">
                                <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                    <xhtml:td>
                                        <!-- READONLY -->
                                        <xxforms:variable name="type" select="@type"/>
                                        <xforms:output ref="instance('decor-types')/RelationshipTypes/enumeration[@value=$type]/label[@language=$resources/@xml:lang]"/>
                                    </xhtml:td>
                                    <xhtml:td>
                                        <!--
                                            <relationship type="ADAPT" ref="2.16.840.1.113883.2.4.3.11.60.101.1.1" flexibility="2013-03-25T14:13:00" prefix="naw-" iStatusCode="final" iExpirationDate="" iVersionLabel="" iddisplay="naw-1" localInherit="false">
                                                <name language="nl-NL">Demografische gegevens</name>
                                            </relationship>
                                        -->
                                        <xxforms:variable name="id" select="@ref"/>
                                        <xxforms:variable name="effectiveDate" select="@flexibility"/>
                                        <xxforms:variable name="iddisplay" select="if (string-length(@iddisplay)&gt;0) then @iddisplay else $id"/>
                                        <xxforms:variable name="datasetid" select="@datasetId"/>
                                        <xxforms:variable name="dataseteff" select="@datasetEffectiveDate"/>
                                        <xxforms:variable name="statusCode" select="@iStatusCode"/>
                                        <xxforms:variable name="versionLabel" select="@iVersionLabel"/>
                                        <xxforms:variable name="prefix" select="@prefix"/>
                                        <xforms:group ref=".[string-length($prefix)&gt;0]">
                                            <xforms:trigger appearance="minimal" class="node-s{$statusCode}">
                                                <xforms:label>
                                                    <xforms:output ref="if (name[@language=instance('language')]) then name[@language=instance('language')] else name[1]"/>
                                                    <xforms:output ref="if (string-length($versionLabel)&gt;0) then concat(' (',$versionLabel,')') else ()"/>
                                                    <xforms:output ref="concat(' - ',$iddisplay)"/>
                                                    <xforms:group ref="$effectiveDate">
                                                        <xforms:output ref="$resources/as-of"/>
                                                        <xforms:output ref="if ($effectiveDate castable as xs:dateTime) then replace(format-dateTime(xs:dateTime($effectiveDate),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else ($resources/dynamic)"/>
                                                    </xforms:group>
                                                </xforms:label>
                                                <xforms:action ev:event="DOMActivate">
                                                    <xforms:load resource="/decor-datasets--{$prefix}?id={$datasetid}&amp;effectiveDate={$dataseteff}&amp;conceptId={$id}&amp;conceptEffectiveDate={$effectiveDate}" show="new"/>
                                                </xforms:action>
                                            </xforms:trigger>
                                            <xforms:output ref="concat(' (', $resources/repository, ': ', @prefix, ')')"/>
                                        </xforms:group>
                                        <xforms:group ref=".[string-length($prefix)=0]">
                                            <xforms:output ref="$iddisplay"/>
                                            <xforms:group ref="$effectiveDate">
                                                <xforms:output ref="$resources/as-of"/>
                                                <xforms:output ref="$effectiveDate" xxforms:format="if (. castable as xs:dateTime) then replace(format-dateTime(xs:dateTime(.),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else (.)"/>
                                            </xforms:group>
                                            <xforms:output ref="if (string-length($versionLabel)&gt;0) then concat(' (',$versionLabel,')') else ()"/>
                                        </xforms:group>
                                    </xhtml:td>
                                </xhtml:tr>
                            </xforms:repeat>
                        </xhtml:table>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
            <!-- concept source -->
            <xforms:group ref="source">
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/source"/>
                    </xhtml:td>
                    <xhtml:td colspan="3">
                        <xforms:output mediatype="text/html" ref=".[@language=instance('language')]"/>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
            <!-- concept rationale -->
            <xforms:group ref="rationale">
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/rationale"/>
                    </xhtml:td>
                    <xhtml:td colspan="3">
                        <xforms:output mediatype="text/html" ref=".[@language=instance('language')]"/>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
            <!-- concept comments and inherited comments -->
            <xforms:group ref=".[comment|inheritedComment]">
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/comment"/>
                    </xhtml:td>
                    <xhtml:td colspan="3">
                        <xhtml:table width="100%">
                            <xforms:repeat nodeset="comment|inheritedComment">
                                <xhtml:tr class="not-selectable">
                                    <xhtml:td>
                                        <xforms:output mediatype="text/html" ref=".[@language=instance('language')]"/>
                                    </xhtml:td>
                                </xhtml:tr>
                            </xforms:repeat>
                        </xhtml:table>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
            <!-- concept properties -->
            <xforms:group ref=".[property]">
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/properties"/>
                    </xhtml:td>
                    <xhtml:td colspan="3">
                        <fr:accordion class="fr-accordion-lnf">
                            <fr:case selected="false">
                                <fr:label ref="$resources/properties"/>
                                <xhtml:table class="detail spaced">
                                    <xforms:repeat nodeset="property[string-length()&gt;0]">
                                        <xhtml:tr class="not-selectable">
                                            <xhtml:td class="item-label">
                                                <xforms:output ref="@name"/>
                                            </xhtml:td>
                                            <xhtml:td>
                                                <xforms:output mediatype="text/html" ref="."/>
                                            </xhtml:td>
                                        </xhtml:tr>
                                    </xforms:repeat>
                                </xhtml:table>
                            </fr:case>
                        </fr:accordion>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
            <!-- concept operationalization -->
            <xforms:group ref="operationalization">
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/operationalization"/>
                    </xhtml:td>
                    <xhtml:td colspan="3">
                        <xforms:output mediatype="text/html" ref=".[@language=instance('language')]"/>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
            <!-- group for concept associations -->
            <xxforms:variable name="conceptId" select="@id"/>
            <xxforms:variable name="inhConceptId" select="inherit/@ref | contains/@ref"/>
            <xxforms:variable name="orgConceptId" select="inherit/@originalId"/>
            <xxforms:variable name="saved-associations" select="instance('concept-associations')/terminologyAssociation[@conceptId=($conceptId, $inhConceptId, $orgConceptId)]"/>
            <xforms:group ref=".[$saved-associations]">
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/terminology-association"/>
                    </xhtml:td>
                    <xhtml:td colspan="3">
                        <xhtml:table width="100%" class="detail zebra-table">
                            <xhtml:tr>
                                <xhtml:td class="item-label">
                                    <xforms:output ref="$resources/code"/>
                                </xhtml:td>
                                <xhtml:td class="item-label">
                                    <xforms:output ref="$resources/displayName"/>
                                </xhtml:td>
                                <xhtml:td class="item-label">
                                    <xforms:output ref="$resources/codesystem"/>
                                </xhtml:td>
                                <xhtml:td class="item-label">
                                    <xforms:output ref="$resources/association-equivalence"/>
                                </xhtml:td>
                            </xhtml:tr>
                            <xforms:repeat nodeset="$saved-associations">
                                <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                    <xhtml:td>
                                        <xforms:group ref=".[@transactionId]">
                                            <xhtml:img src="img/pill-sc.png" alt="" title="{$resources/transaction-specific}" height="20" width="20"/>
                                        </xforms:group>
                                        <xforms:output ref="@code"/>
                                    </xhtml:td>
                                    <xhtml:td>
                                        <xforms:output ref="@displayName"/>
                                    </xhtml:td>
                                    <xhtml:td>
                                        <xforms:output ref="if (string-length(@codeSystemName)&gt;0) then @codeSystemName else @codeSystem"/>
                                    </xhtml:td>
                                    <xhtml:td>
                                        <xforms:output ref="instance('decor-types')/EquivalencyType/enumeration[@value = current()/@equivalence]/label[@language=$resources/@xml:lang]"/>
                                    </xhtml:td>
                                </xhtml:tr>
                            </xforms:repeat>
                        </xhtml:table>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
            <xxforms:variable name="saved-id-associations" select="instance('concept-associations')/identifierAssociation[@conceptId=($conceptId, $inhConceptId, $orgConceptId)]"/>
            <!-- valueDomain -->
            <xforms:group ref="valueDomain">
                <xxforms:variable name="valueDomainType" select="@type"/>
                <xhtml:tr>
                    <xhtml:td colspan="4" style="background-color : #f6f3ee;">
                        <fr:accordion class="fr-accordion-lnf">
                            <fr:case selected="true">
                                <fr:label ref="$resources/value"/>
                                <xhtml:table width="100%" class="detail spaced">
                                    <!-- value type select -->
                                    <xhtml:tr>
                                        <xhtml:td class="item-label">
                                            <xforms:output ref="$resources/type"/>
                                        </xhtml:td>
                                        <xhtml:td>
                                            <xxforms:variable name="datatype" select="@type"/>
                                            <xforms:trigger appearance="minimal">
                                                <xforms:label ref="instance('decor-types')/DataSetValueType/enumeration[@value=$datatype]/label[@language=$resources/@xml:lang]"/>
                                                <xforms:action ev:event="DOMActivate">
                                                    <xforms:load resource="https://art-decor.org/mediawiki/index.php?title=DECOR-dataset#{$datatype}" show="new"/>
                                                </xforms:action>
                                            </xforms:trigger>
                                        </xhtml:td>
                                    </xhtml:tr>
                                    <!-- case switch for different valueDomain types -->
                                    <xforms:group ref=".[$saved-id-associations]">
                                        <xhtml:tr>
                                            <xhtml:td class="item-label">
                                                <xforms:output ref="$resources/identifier-association"/>
                                            </xhtml:td>
                                            <xhtml:td colspan="3">
                                                <xhtml:table width="100%" class="detail zebra-table">
                                                    <xhtml:tr>
                                                        <xhtml:td class="item-label">
                                                            <xforms:output ref="$resources/displayName"/>
                                                        </xhtml:td>
                                                        <xhtml:td class="item-label">
                                                            <xforms:output ref="$resources/id"/>
                                                        </xhtml:td>
                                                    </xhtml:tr>
                                                    <xforms:repeat nodeset="$saved-id-associations">
                                                        <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                                            <xhtml:td>
                                                                <xforms:group ref=".[@transactionId]">
                                                                    <xhtml:img src="img/pill-sc.png" alt="" title="{$resources/transaction-specific}" height="20" width="20"/>
                                                                </xforms:group>
                                                                <xforms:output ref="@refdisplay"/>
                                                            </xhtml:td>
                                                            <xhtml:td>
                                                                <xforms:output ref="@ref"/>
                                                            </xhtml:td>
                                                        </xhtml:tr>
                                                    </xforms:repeat>
                                                </xhtml:table>
                                            </xhtml:td>
                                        </xhtml:tr>
                                    </xforms:group>
                                    <xforms:group ref=".[@type=('code','ordinal')]">
                                        <!-- group for conceptList associations -->
                                        <xxforms:variable name="conceptListId" select="conceptList/(@id|@ref)"/>
                                        <xxforms:variable name="conceptListRef" select="conceptList/(@id|@ref)"/>
                                        <xxforms:variable name="conceptListConcepts" select="conceptList/concept"/>
                                        <xxforms:variable name="associatedValuesets" select="instance('concept-associated-valuesets')//valueSet[@conceptId=$conceptListId]"/>
                                        <xxforms:variable name="saved-associations" select="instance('concept-associations')/terminologyAssociation[@conceptId=($conceptListId)]"/>
                                        <xforms:group ref=".[$saved-associations]">
                                            <xhtml:tr>
                                                <xhtml:td class="item-label">
                                                    <xforms:output ref="$resources/valueset-association"/>
                                                </xhtml:td>
                                                <xhtml:td>
                                                    <xhtml:table width="100%">
                                                        <xforms:repeat nodeset="$saved-associations">
                                                            <xxforms:variable name="valueSetRef" select="@valueSet"/>
                                                            <xxforms:variable name="valueSetEff" select="if (@flexibility castable as xs:dateTime) then @flexibility else 'dynamic'"/>
                                                            <xxforms:variable name="valueSetName" select="if (string-length(@valueSetName)&gt;0) then (@valueSetName) else (@valueSet)"/>
                                                            <xxforms:variable name="flexibility" select="if (@flexibility castable as xs:dateTime) then replace(format-dateTime(xs:dateTime(@flexibility),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else ($resources/dynamic)"/>
                                                            <xxforms:variable name="strength" select="@strength"/>
                                                            <xxforms:variable name="strengthHint" select="if ($strength = 'required') then $resources/binding-strength-required else if ($strength = 'preferred') then $resources/binding-strength-preferred else if ($strength = 'extensible') then $resources/binding-strength-extensible else if ($strength = 'example') then $resources/binding-strength-example else ('')"/>
                                                            <!-- except a concept not to be connected to >1 versions of a valueset, otherwise this statement below is incomplete -->
                                                            <xxforms:variable name="valueSet" select="instance('concept-associated-valuesets')//valueSet[(@id|@name)=$valueSetRef]"/>
                                                            <xhtml:tr class="not-selectable">
                                                                <!--<xhtml:td style="width: 45px;">
                                                                    <xhtml:div style="float: right; margin-right: 5px;">
                                                                        <xforms:trigger appearance="minimal">
                                                                            <xforms:label>
                                                                                <xhtml:img src="/img/eye.png" alt=""/>
                                                                            </xforms:label>
                                                                            <xforms:hint ref="concat($resources/show, ' ''',$valueSetName,'''')"/>
                                                                            <xforms:action ev:event="DOMActivate">
                                                                                <xforms:setvalue ref="instance('valueset-navigation')/@ref" value="$valueSetRef"/>
                                                                                <xforms:setvalue ref="instance('valueset-navigation')/@flexibility" value="$valueSetEff"/>
                                                                                <xforms:setvalue ref="instance('valueset-navigation')/@url" value="if ($valueSet/@url) then $valueSet/@url else (concat($decor-external-exist,'/services'))"/>
                                                                                <xforms:setvalue ref="instance('valueset-navigation')/@ident" value="if ($valueSet/@ident) then $valueSet/@ident else (instance('document'))"/>
                                                                                <xxforms:show dialog="show-valueset-dialog"/>
                                                                            </xforms:action>
                                                                        </xforms:trigger>
                                                                    </xhtml:div>
                                                                </xhtml:td>-->
                                                                <xhtml:td>
                                                                    <xforms:group ref=".[@transactionId]">
                                                                        <xhtml:img src="img/pill-sc.png" alt="" title="{$resources/transaction-specific}" height="20" width="20"/>
                                                                    </xforms:group>
                                                                    <xforms:output ref="$strength">
                                                                        <xforms:hint ref="$strengthHint"/>
                                                                    </xforms:output>
                                                                    <xforms:trigger appearance="minimal">
                                                                        <xforms:label>
                                                                            <xforms:output ref="concat($valueSetName,' (',$flexibility,')')"/>
                                                                        </xforms:label>
                                                                        <xforms:hint ref="concat($resources/go-to-valueset, ' ''',$valueSetName,'''')"/>
                                                                        <xforms:action ev:event="DOMActivate">
                                                                            <xforms:load resource="/decor-valuesets--{instance('document')}?id={$valueSetRef}&amp;effectiveDate={$valueSetEff}" show="new"/>
                                                                        </xforms:action>
                                                                    </xforms:trigger>
                                                                </xhtml:td>
                                                            </xhtml:tr>
                                                        </xforms:repeat>
                                                    </xhtml:table>
                                                </xhtml:td>
                                            </xhtml:tr>
                                        </xforms:group>
                                        <!-- Get terminology + associations that tie concepts into HL7(?) codes -->
                                        <xforms:group ref="conceptList[concept | $associatedValuesets]">
                                            <xxforms:variable name="conceptspresent" select="count($conceptListConcepts) gt 0"/>
                                            <xxforms:variable name="valueSetItems" select="if ($conceptspresent) then () else ($associatedValuesets//completeCodeSystem | $associatedValuesets//concept | $associatedValuesets//exception)[position() lt $maxValueSetItems]"/>
                                            <xxforms:variable name="synonymspresent" select="count($conceptListConcepts/synonym[@language=instance('language')]) gt 0"/>
                                            <xxforms:variable name="descpresent" select="count($conceptListConcepts/desc[@language=instance('language')]) gt 0"/>
                                            <!-- conceptList/concepts or valueSet items -->
                                            <xxforms:variable name="exceptionspresent" select="count($conceptListConcepts[@exception='true']) gt 0"/>
                                            <xxforms:variable name="ordinalConceptpresent" select="$valueDomainType = 'ordinal' and count($conceptListConcepts[@ordinal]) gt 0"/>
                                            <xxforms:variable name="ordinalValueSetpresent" select="count(($associatedValuesets//completeCodeSystem | $associatedValuesets//concept | $associatedValuesets//exception)[position() lt $maxValueSetItems][@ordinal]) gt 0"/>
                                            <xxforms:variable name="lvltyppresent" select="count($conceptListConcepts/@level | $conceptListConcepts/@type | $valueSetItems/@level | $valueSetItems/@type) gt 0"/>
                                            <xxforms:variable name="equivalencypresent" select="count($conceptListConcepts) gt 0"/>
                                            <xhtml:tr class="heading">
                                                <xhtml:td class="heading-var" colspan="2">
                                                    <xforms:output ref="$resources/concepts"/>
                                                    <xforms:group ref="$associatedValuesets[empty($conceptListConcepts)][count($valueSetItems) &gt; $maxValueSetItems]">
                                                        <xforms:output ref="concat(' (',$resources/click-valueset-for-more-detail,'. ',$resources/showing,' ',$maxValueSetItems,' ',$resources/of,' ',count($valueSetItems),')')"/>
                                                    </xforms:group>
                                                </xhtml:td>
                                            </xhtml:tr>
                                            <xhtml:tr>
                                                <xhtml:td colspan="2">
                                                    <xhtml:table width="100%" class="detail zebra-table">
                                                        <xhtml:tr>
                                                            <xhtml:td class="item-label-var" style="{if ($lvltyppresent=true()) then '' else 'display: none;'}">
                                                                <xforms:output ref="$resources/level"/>/<xforms:output ref="$resources/type"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label-var" style="{if ($conceptspresent=true()) then '' else 'display: none;'}">
                                                                <xforms:output ref="$resources/concept"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label-var" style="{if ($synonymspresent=true()) then '' else 'display: none;'}">
                                                                <xforms:output ref="$resources/synonyms"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label-var" style="{if ($ordinalConceptpresent=true()) then '' else 'display: none;'}">
                                                                <xforms:output ref="$resources/ordinal"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label-var" style="{if ($exceptionspresent=true()) then '' else 'display: none;'}">
                                                                <xforms:output ref="$resources/exception"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label-var" style="{if ($descpresent=true()) then '' else 'display: none;'}">
                                                                <xforms:output ref="$resources/description"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label-var" style="{if ($conceptspresent) then 'border-left: 1px solid black;' else ()}">
                                                                <xforms:output ref="$resources/code"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label-var" style="{if ($ordinalValueSetpresent=true()) then '' else 'display: none;'}">
                                                                <xforms:output ref="$resources/ordinal"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label-var">
                                                                <xforms:output ref="$resources/displayName"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label-var">
                                                                <xforms:output ref="$resources/codesystem"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label-var" style="{if ($equivalencypresent=true()) then '' else 'display: none;'}">
                                                                <xforms:output ref="$resources/association-equivalence"/>
                                                            </xhtml:td>
                                                        </xhtml:tr>
                                                        <xforms:repeat nodeset="$valueSetItems">
                                                            <xxforms:variable name="css-margin" select="concat('padding-left: ',number(@level) * 15,'px;')"/>
                                                            <xxforms:variable name="css-font" select="if (@type) then concat('concepttype',@type) else ()"/>
                                                            <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'} concepttype{@type}">
                                                                <xhtml:td style="{if ($lvltyppresent=true()) then '' else 'display: none;'}">
                                                                    <xforms:output ref="if (@level | @type) then concat(@level,'-',@type) else ()"/>
                                                                </xhtml:td>
                                                                <xhtml:td style="{if ($conceptspresent=true()) then '' else 'display: none;'}"/>
                                                                <xhtml:td style="{if ($synonymspresent=true()) then '' else 'display: none;'}"/>
                                                                <xhtml:td style="{if ($ordinalConceptpresent=true()) then '' else 'display: none;'}"/>
                                                                <xhtml:td style="{if ($exceptionspresent=true()) then '' else 'display: none;'}"/>
                                                                <xhtml:td style="{if ($descpresent=true()) then '' else 'display: none;'}"/>
                                                                <xhtml:td style="{$css-margin}">
                                                                    <xforms:group ref=".[$saved-associations/@transactionId]">
                                                                        <xhtml:img src="img/pill-sc.png" alt="" title="{$resources/transaction-specific}" height="20" width="20"/>
                                                                    </xforms:group>
                                                                    <xforms:output ref="@code" class="{$css-font}"/>
                                                                </xhtml:td>
                                                                <xhtml:td style="{if ($ordinalValueSetpresent=true()) then '' else 'display: none;'}">
                                                                    <xforms:output ref="@ordinal"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@displayName" class="{$css-font}"/>
                                                                    <xforms:output ref="if (self::completeCodeSystem/filter) then $resources/complete-codesystem-with-filter else if (self::completeCodeSystem) then $resources/complete-codesystem else ()" class="concepttypeA"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <!--<sourceCodeSystem id="2.16.840.1.113883.3.1937.99.62.3.5.3" identifierName="demo1-codesystem-3" canonicalUri="xs:anyURI"/>-->
                                                                    <xxforms:variable name="codeSystem" select="@codeSystem"/>
                                                                    <xxforms:variable name="codeSystemName" select="ancestor::valueSet/sourceCodeSystem[@id=$codeSystem]/@identifierName"/>
                                                                    <xforms:output ref="if (string-length($codeSystemName)&gt;0) then $codeSystemName else @codeSystem" class="{$css-font}"/>
                                                                </xhtml:td>
                                                            </xhtml:tr>
                                                        </xforms:repeat>
                                                        <!-- Display valueSet if no concepts -->
                                                        <!--<xforms:repeat nodeset="instance('concept-associated-valuesets')//valueSet[@conceptId=$conceptListId]//(concept|exception)[empty($conceptListConcepts)]">
                                                            <xxforms:variable name="css-margin" select="concat('padding-left: ',number(@level) * 15,'px;')"/>
                                                            <xxforms:variable name="css-font" select="if (@type) then concat('concepttype',@type) else ()"/>
                                                            <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'} concepttype{@type}">
                                                                <xhtml:td style="{if ($lvltyppresent=true()) then '' else 'display: none;'}"/>
                                                                <xhtml:td/>
                                                                <xhtml:td style="{if ($synonymspresent=true()) then '' else 'display: none;'}"/>
                                                                <xhtml:td style="{if ($exceptionspresent=true()) then '' else 'display: none;'}"/>
                                                                <xhtml:td style="{if ($descpresent=true()) then '' else 'display: none;'}"/>
                                                                <xhtml:td style="{$css-margin}">
                                                                    <xforms:output ref="@code" class="{$css-font}"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@displayName" class="{$css-font}"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <!-\-<sourceCodeSystem id="2.16.840.1.113883.3.1937.99.62.3.5.3" identifierName="demo1-codesystem-3" canonicalUri="xs:anyURI"/>-\->
                                                                    <xxforms:variable name="codeSystem" select="@codeSystem"/>
                                                                    <xxforms:variable name="codeSystemName" select="ancestor::valueSet/sourceCodeSystem[@id=$codeSystem]/@identifierName"/>
                                                                    <xforms:output ref="if (string-length($codeSystemName)>0) then $codeSystemName else @codeSystem"/>
                                                                </xhtml:td>
                                                            </xhtml:tr>
                                                        </xforms:repeat>-->
                                                        <!-- Display concepts with codes -->
                                                        <xforms:repeat nodeset="$conceptListConcepts">
                                                            <xxforms:variable name="conceptId" select="@id"/>
                                                            <xxforms:variable name="saved-associations" select="instance('concept-associations')/terminologyAssociation[@conceptId=($conceptId)]"/>
                                                            <xxforms:variable name="css-margin" select="concat('padding-left: ',number(@level) * 15,'px;')"/>
                                                            <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                                                <xhtml:td style="{if ($lvltyppresent=true()) then '' else 'display: none;'}">
                                                                    <xforms:output ref="@level"/>-<xforms:output ref="@type"/>
                                                                </xhtml:td>
                                                                <xhtml:td style="{$css-margin}">
                                                                    <xxforms:variable name="css-font" select="if (@type) then concat('concepttype',@type) else ()"/>
                                                                    <xforms:output ref="if (name[@language=instance('language')]) then name[@language=instance('language')] else name[1]" class="{$css-font}"/>
                                                                </xhtml:td>
                                                                <xhtml:td style="{if ($synonymspresent=true()) then '' else 'display: none;'}">
                                                                    <xforms:repeat nodeset="synonym[@language=instance('language')]">
                                                                        <xhtml:div class="not-selectable">
                                                                            <xforms:output ref="."/>
                                                                        </xhtml:div>
                                                                    </xforms:repeat>
                                                                </xhtml:td>
                                                                <xhtml:td style="{if ($ordinalConceptpresent=true()) then '' else 'display: none;'}">
                                                                    <xforms:output ref="@ordinal"/>
                                                                </xhtml:td>
                                                                <xhtml:td style="{if ($exceptionspresent=true()) then '' else 'display: none;'}">
                                                                    <xforms:input ref="@exception" class="xforms-readonly auto-width"/>
                                                                </xhtml:td>
                                                                <xhtml:td style="{if ($descpresent=true()) then '' else 'display: none;'}">
                                                                    <xforms:output mediatype="text/html" ref="desc[@language=instance('language')]"/>
                                                                </xhtml:td>
                                                                <xhtml:td style="border-left: 1px solid black;">
                                                                    <xforms:repeat nodeset="$saved-associations">
                                                                        <xxforms:variable name="code" select="@code"/>
                                                                        <xxforms:variable name="codeSystem" select="@codeSystem"/>
                                                                        <xxforms:variable name="matchcode" select="(instance('concept-associated-valuesets')//valueSet[@conceptId=$conceptListRef]//*[@code=$code][@codeSystem=$codeSystem])[1]"/>
                                                                        <xhtml:div class="not-selectable concepttype{$matchcode/@type} {$matchcode/local-name()}">
                                                                            <xhtml:span style="{concat('margin-left: ',number($matchcode/@level) * 15,'px;')}">
                                                                                <xforms:group ref=".[@transactionId]">
                                                                                    <xhtml:img src="img/pill-sc.png" alt="" title="{$resources/transaction-specific}" height="20" width="20"/>
                                                                                </xforms:group>
                                                                                <xforms:output ref="@code"/>
                                                                            </xhtml:span>
                                                                        </xhtml:div>
                                                                    </xforms:repeat>
                                                                </xhtml:td>
                                                                <xhtml:td style="{if ($ordinalValueSetpresent=true()) then '' else 'display: none;'}">
                                                                    <xforms:repeat nodeset="$saved-associations">
                                                                        <xxforms:variable name="code" select="@code"/>
                                                                        <xxforms:variable name="codeSystem" select="@codeSystem"/>
                                                                        <xxforms:variable name="matchcode" select="(instance('concept-associated-valuesets')//valueSet[@conceptId=$conceptListRef]//*[@code=$code][@codeSystem=$codeSystem])[1]"/>
                                                                        <xhtml:div class="not-selectable concepttype{$matchcode/@type} {$matchcode/local-name()}">
                                                                            <xhtml:span style="{concat('margin-left: ',number($matchcode/@level) * 15,'px;')}">
                                                                                <xforms:output ref="$matchcode/@ordinal"/>
                                                                            </xhtml:span>
                                                                        </xhtml:div>
                                                                    </xforms:repeat>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:repeat nodeset="$saved-associations">
                                                                        <xxforms:variable name="code" select="@code"/>
                                                                        <xxforms:variable name="codeSystem" select="@codeSystem"/>
                                                                        <xxforms:variable name="matchcode" select="(instance('concept-associated-valuesets')//valueSet[@conceptId=$conceptListRef]//*[@code=$code][@codeSystem=$codeSystem])[1]"/>
                                                                        <xhtml:div class="not-selectable concepttype{$matchcode/@type} {$matchcode/local-name()}">
                                                                            <xhtml:span style="{concat('margin-left: ',number($matchcode/@level) * 15,'px;')}">
                                                                                <xforms:output ref="$matchcode/@displayName"/>
                                                                            </xhtml:span>
                                                                        </xhtml:div>
                                                                    </xforms:repeat>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:repeat nodeset="$saved-associations">
                                                                        <xxforms:variable name="code" select="@code"/>
                                                                        <xxforms:variable name="codeSystem" select="@codeSystem"/>
                                                                        <xxforms:variable name="matchcode" select="(instance('concept-associated-valuesets')//valueSet[@conceptId=$conceptListRef]//*[@code=$code][@codeSystem=$codeSystem])[1]"/>
                                                                        <xhtml:div class="not-selectable concepttype{$matchcode/@type} {$matchcode/local-name()}">
                                                                            <xforms:output ref="if (string-length(@codeSystemName)&gt;0) then @codeSystemName else @codeSystem"/>
                                                                        </xhtml:div>
                                                                    </xforms:repeat>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:repeat nodeset="$saved-associations">
                                                                        <xxforms:variable name="code" select="@code"/>
                                                                        <xxforms:variable name="codeSystem" select="@codeSystem"/>
                                                                        <xxforms:variable name="matchcode" select="(instance('concept-associated-valuesets')//valueSet[@conceptId=$conceptListRef]//*[@code=$code][@codeSystem=$codeSystem])[1]"/>
                                                                        <xhtml:div class="not-selectable concepttype{$matchcode/@type} {$matchcode/local-name()}">
                                                                            <xforms:output ref="instance('decor-types')/EquivalencyType/enumeration[@value = current()/@equivalence]/label[@language=$resources/@xml:lang]"/>
                                                                        </xhtml:div>
                                                                    </xforms:repeat>
                                                                </xhtml:td>
                                                            </xhtml:tr>
                                                        </xforms:repeat>
                                                    </xhtml:table>
                                                </xhtml:td>
                                            </xhtml:tr>
                                        </xforms:group>
                                    </xforms:group>
                                    <!-- valueDomain properties -->
                                    <xforms:group ref=".[property]">
                                        <xhtml:tr>
                                            <xhtml:td colspan="2">
                                                <!-- count, decimal -->
                                                <xforms:group ref=".[@type=('count','decimal')]">
                                                    <xhtml:table class="spaced" width="100%">
                                                        <xhtml:tr>
                                                            <xhtml:td class="item-label"/>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/minimum"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/maximum"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/default"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/fixed"/>
                                                            </xhtml:td>
                                                        </xhtml:tr>
                                                        <xforms:repeat nodeset="property">
                                                            <xhtml:tr>
                                                                <xhtml:td class="item-label">
                                                                    <xforms:output ref="$resources/properties"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@minInclude" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@maxInclude" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@default" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@fixed" class="short-number"/>
                                                                </xhtml:td>
                                                            </xhtml:tr>
                                                        </xforms:repeat>
                                                    </xhtml:table>
                                                </xforms:group>
                                            <!-- duration, quantity -->
                                                <xforms:group ref=".[@type=('duration','quantity')]">
                                                    <xhtml:table class="spaced" width="100%">
                                                        <xhtml:tr>
                                                            <xhtml:td class="item-label"/>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/unit"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/minimum"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/maximum"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/decimals"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/default"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/fixed"/>
                                                            </xhtml:td>
                                                        </xhtml:tr>
                                                        <xforms:repeat nodeset="property">
                                                            <xhtml:tr class="not-selectable">
                                                                <xhtml:td class="item-label">
                                                                    <xforms:output ref="$resources/properties"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@unit" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@minInclude" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@maxInclude" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@fractionDigits" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@default" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@fixed" class="short-number"/>
                                                                </xhtml:td>
                                                            </xhtml:tr>
                                                        </xforms:repeat>
                                                    </xhtml:table>
                                                </xforms:group>
                                                <!-- date, dateTime -->
                                                <xforms:group ref=".[@type=('date','datetime')]">
                                                    <xhtml:table class="spaced" width="100%">
                                                        <xhtml:tr>
                                                            <xhtml:td class="item-label"/>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/timestamp-precision"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/default"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/fixed"/>
                                                            </xhtml:td>
                                                        </xhtml:tr>
                                                        <xforms:repeat nodeset="property">
                                                            <xhtml:tr class="not-selectable">
                                                                <xhtml:td class="item-label">
                                                                    <xforms:output ref="$resources/properties"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xxforms:variable name="timeStampPrecision" select="@timeStampPrecision"/>
                                                                    <xforms:output ref="instance('decor-types')/(DataSetTimeStampPrecision | DataSetTimePrecision)/enumeration[@value=$timeStampPrecision]/label[@language=$resources/@xml:lang]"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@default" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@fixed" class="short-number"/>
                                                                </xhtml:td>
                                                            </xhtml:tr>
                                                        </xforms:repeat>
                                                    </xhtml:table>
                                                </xforms:group>
                                                <!-- code, score,'ordinal', boolean -->
                                                <xforms:group ref=".[@type=('code','score','ordinal','boolean')]">
                                                    <xhtml:table class="spaced" width="100%">
                                                        <xhtml:tr>
                                                            <xhtml:td class="item-label"/>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/default"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/fixed"/>
                                                            </xhtml:td>
                                                        </xhtml:tr>
                                                        <xforms:repeat nodeset="property">
                                                            <xhtml:tr class="not-selectable">
                                                                <xhtml:td class="item-label">
                                                                    <xforms:output ref="$resources/properties"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@default" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@fixed" class="short-number"/>
                                                                </xhtml:td>
                                                            </xhtml:tr>
                                                        </xforms:repeat>
                                                    </xhtml:table>
                                                </xforms:group>
                                                <!-- string, text, identifier -->
                                                <xforms:group ref=".[@type=('string','text','identifier')]">
                                                    <xhtml:table class="spaced" width="100%">
                                                        <xhtml:tr>
                                                            <xhtml:td class="item-label"/>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/minimum-length"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/maximum-length"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/default"/>
                                                            </xhtml:td>
                                                            <xhtml:td class="item-label">
                                                                <xforms:output ref="$resources/fixed"/>
                                                            </xhtml:td>
                                                        </xhtml:tr>
                                                        <xforms:repeat nodeset="property">
                                                            <xhtml:tr class="not-selectable">
                                                                <xhtml:td class="item-label">
                                                                    <xforms:output ref="$resources/properties"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@minLength" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@maxLength" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@default" class="short-number"/>
                                                                </xhtml:td>
                                                                <xhtml:td>
                                                                    <xforms:output ref="@fixed" class="short-number"/>
                                                                </xhtml:td>
                                                            </xhtml:tr>
                                                        </xforms:repeat>
                                                    </xhtml:table>
                                                </xforms:group>
                                            </xhtml:td>
                                        </xhtml:tr>
                                    </xforms:group>
                                    <!-- valueDomain examples -->
                                    <xforms:group ref=".[example/text()[string-length()&gt;0]|example/*]">
                                        <xhtml:tr>
                                            <xhtml:td class="item-label">
                                                <xforms:output ref="if (count(example)&gt;1) then $resources/examples else($resources/example)"/>
                                            </xhtml:td>
                                            <xhtml:td>
                                                <xforms:repeat nodeset="example">
                                                    <xhtml:table class="not-selectable" width="100%">
                                                        <xhtml:tr class="{if (@type='error') then 'explabelred' else if (@type='valid') then 'explabelgreen' else 'explabel'}">
                                                            <xhtml:td class="exppad">
                                                                <xforms:group ref=".[@caption]">
                                                                    <xhtml:div class="expcaption">
                                                                        <xforms:output ref="@caption"/>
                                                                    </xhtml:div>
                                                                </xforms:group>
                                                            <xhtml:tt>
                                                                    <xforms:output value="."/>
                                                                </xhtml:tt>
                                                            </xhtml:td>
                                                        </xhtml:tr>
                                                    </xhtml:table>
                                                </xforms:repeat>
                                            </xhtml:td>
                                        </xhtml:tr>
                                    </xforms:group>
                                </xhtml:table>
                            </fr:case>
                        </fr:accordion>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
        </xhtml:table>
    </part>
    <!-- 
      Decor New Issue view
      Used in:
      decor-datasets.xhtml
      decor-issues.xhtml
      decor-scenarios.xhtml
      decor-templates.xhtml
      decor-template-mappings.xhtml
      decor-terminology.xhtml
      decor-valuesets.xhtml
      
      Requires variables:
      $resources
      
     
     Requires submissions:
     save-decor-issue-submission for saving the new issue
     get-issues-submission to retrieve latest contents from disk after saving
     
     Requires instances:
     data-safe
     project-instance (with issues/labels, if applicable)
     decor-types
     new-issue-instance / inssue-instance
     
     Requires css classes:
     .labelouterboxitem
     
     Expected use:
     <xforms:group ref="instance('new-issues-instance')/issue">
        <xhtml:tr>
            <xhtml:td class="heading">
                <xhtml:div class="heading">
                    <xforms:output ref="$resources/new-issue"/>
                </xhtml:div>
            </xhtml:td>
        </xhtml:tr>
        <xhtml:tr>
            <xhtml:td>
                <xi:include href="/db/apps/art/resources/xform-parts.xml" xpointer="xpointer(//part[@id='issue-new'])">
                    <xi:fallback>
                        <p>Included document /db/apps/art/resources/xform-parts.xml not found!</p>
                    </xi:fallback>
                </xi:include>
            </xhtml:td>
        </xhtml:tr>
    </xforms:group>
    -->
    <part id="issue-new">
        <xhtml:table width="100%" class="zebra-table detail spaced">
            <!-- issue type -->
            <xhtml:tr>
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/type"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:select1 ref="@type" appearance="minimal">
                        <xforms:itemset nodeset="instance('decor-types')/IssueType/enumeration">
                            <xforms:label ref="label[@language=$resources/@xml:lang]"/>
                            <xforms:value ref="@value"/>
                        </xforms:itemset>
                    </xforms:select1>
                </xhtml:td>
            </xhtml:tr>
            <!-- title -->
            <xhtml:tr>
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/title"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:input ref="@displayName" id="new-issue-title" incremental="true"/>
                    <xforms:group ref=".[string-length(@displayName)=0]">
                        <xforms:output ref="' '"/>
                        <xforms:output mediatype="image/*" value="'/img/exclamation.png'"/>
                    </xforms:group>
                </xhtml:td>
            </xhtml:tr>
            <!-- issue priority -->
            <xhtml:tr>
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/priority"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:select1 ref="@priority" appearance="minimal">
                        <xforms:itemset nodeset="instance('decor-types')/IssuePriority/enumeration">
                            <xforms:label ref="label[@language=$resources/@xml:lang]"/>
                            <xforms:value ref="@value"/>
                        </xforms:itemset>
                    </xforms:select1>
                </xhtml:td>
            </xhtml:tr>
            <!-- issue labels -->
            <xforms:group ref="tracking[exists(instance('project-instance')/labels/label)]">
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/label"/>
                    </xhtml:td>
                    <xhtml:td>
                        <xforms:select ref="@labels" appearance="full" class="inline">
                            <!-- only show labels that are actually used in the issues... -->
                            <xforms:itemset nodeset="instance('project-instance')/labels/label">
                                <xforms:label>
                                    <!-- http://stackoverflow.com/questions/31380880/orbeon-4-7-bug-in-xformslabel-with-html -->
                                    <xforms:output ref="concat('&#160;(',@code,')&#160;',@name,'&#160;')"/>
                                    <!--<xhtml:div class="labelouterboxitem" title="{desc[1]/text()}">
                                        <xhtml:div style="background-color:{@color};width: 10px;display: inline;">    </xhtml:div>
                                        <xhtml:div style="background-color: white;display: inline;">
                                            <xforms:output ref="concat(' (',@code,') ',@name,' ')"/>
                                        </xhtml:div>
                                    </xhtml:div>-->
                                </xforms:label>
                                <xforms:value ref="@code"/>
                            </xforms:itemset>
                        </xforms:select>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
            <!-- description of issue -->
            <xhtml:tr>
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/description"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:textarea mediatype="text/html" ref="tracking/desc" incremental="true"/>
                </xhtml:td>
            </xhtml:tr>
            <!-- assign to -->
            <xhtml:tr>
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/assign-to"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:select1 ref="tracking/@to" appearance="minimal">
                        <xforms:item>
                            <xforms:label ref="concat('--',$resources/not-set,'--')"/>
                            <xforms:value ref="''"/>
                        </xforms:item>
                        <xforms:itemset nodeset="instance('project-instance')/author">
                            <xforms:label ref="."/>
                            <xforms:value ref="@id"/>
                        </xforms:itemset>
                    </xforms:select1>
                </xhtml:td>
            </xhtml:tr>
            <!-- save and cancel buttons -->
            <xhtml:tr>
                <xhtml:td class="item-label" colspan="2">
                    <xhtml:div class="buttons">
                        <xforms:trigger appearance="compact">
                            <xforms:label ref="$resources/cancel"/>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:delete ref="context()"/>
                                <xxforms:hide dialog="new-issue-dialog"/><!-- relevant to datasets/concepts only -->
                            </xforms:action>
                        </xforms:trigger>
                        <xforms:trigger appearance="compact" ref=".[string-length(@displayName)&gt;0]">
                            <xforms:label ref="$resources/save-issue"/>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:send submission="save-decor-issue-submission"/>
                                <xforms:send submission="get-issues-submission"/>
                                <xforms:send submission="get-concept-issues"/><!-- relevant to scenarios only -->
                            </xforms:action>
                        </xforms:trigger>
                    </xhtml:div>
                </xhtml:td>
            </xhtml:tr>
        </xhtml:table>
    </part>
    <!-- 
      Decor Issue readonly view
      Used in:
      decor-datasets.xhtml
      decor-scenarios.xhtml
      decor-valuesets.xhtml
      decor-templates.xhtml
      
      Requires submissions:
      issue-navigation
      update-decor-issue-subscription
      
      Requires variables:
      $resources
      $editor
      $issueCreator
     
     Requires instances:
     decor-types
    -->
    <part id="issue-readonly">
        <!-- Expanded issues carry their own label definitions as copy of the originating project -->
        <xxforms:variable name="labelDefinition" select="(labels | instance('project-instance')/labels)[1]"/>
        <xhtml:table class="detail spaced" width="100%">
            <!-- issue type and priority -->
            <xhtml:tr class="not-selectable">
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/type"/>
                </xhtml:td>
                <xhtml:td>
                    <xxforms:variable name="type" select="@type"/>
                    <xforms:output ref="instance('decor-types')/IssueType/enumeration[@value=$type]/label[@language=$resources/@xml:lang]"/>
                </xhtml:td>
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/status"/>
                </xhtml:td>
                <xhtml:td>
                    <xxforms:variable name="status" select="@currentStatusCode"/>
                    <xforms:output ref="instance('decor-types')/IssueType/enumeration[@value=$type]/label[@language=$resources/@xml:lang]" class="node-issue-{$status}">
                        <xforms:hint>
                            <xforms:output ref="concat($resources/status,' = ')"/>
                            <xforms:output ref="instance('decor-types')/IssueStatusCodeLifeCycle/enumeration[@value=$status]/label[@language=$resources/@xml:lang]"/>
                        </xforms:hint>
                    </xforms:output>
                </xhtml:td>
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/priority"/>
                </xhtml:td>
                <xhtml:td>
                    <xxforms:variable name="priority" select="@priority"/>
                    <xforms:output ref="instance('decor-types')/IssuePriority/enumeration[@value=$priority]/label[@language=$resources/@xml:lang]"/>
                </xhtml:td>
            </xhtml:tr>
            <!-- issue labels -->
            <xforms:group ref=".[string-length(@currentLabels)&gt;0]">
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/current-labels"/>
                    </xhtml:td>
                    <xhtml:td colspan="5">
                        <xforms:repeat nodeset="tokenize(@currentLabels, '\s')" class="not-selectable">
                            <xxforms:variable name="selectedLabelCode" select="."/>
                            <xxforms:variable name="selectedLabelColor" select="$labelDefinition/label[@code=$selectedLabelCode]/@color"/>
                            <xxforms:variable name="selectedLabelName" select="$labelDefinition/label[@code=$selectedLabelCode]/@name"/>
                            <xhtml:div style="background-color: white;color: black;font-weight: bold;font-size: smaller;border: 1px solid black;margin: 0px 5px 0px 0px;padding: 0px 0px 0px 0px;float: left;" title="{$selectedLabelName}">
                                <xhtml:div style="background-color:{$selectedLabelColor};width: 10px;float: left;">&#160;</xhtml:div>
                                <xhtml:div style="float: left;">
                                    <xforms:output ref="concat('&#160;(',$selectedLabelCode,')&#160;',$selectedLabelName,'&#160;')"/>
                                </xhtml:div>
                            </xhtml:div>
                        </xforms:repeat>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:group>
            <!-- issue events -->
            <xhtml:tr class="not-selectable">
                <xhtml:td class="heading" colspan="6">
                    <xhtml:div class="heading">
                        <xforms:output ref="$resources/events"/>
                    </xhtml:div>
                </xhtml:td>
            </xhtml:tr>
            <xhtml:tr class="not-selectable">
                <xhtml:td colspan="6">
                    <xforms:repeat nodeset="tracking|assignment">
                        <xhtml:table width="100%" class="detail spaced not-selectable" style="border: 1px solid #AAA;">
                            <xhtml:tr>
                                <xhtml:td class="item-label">
                                    <xxforms:variable name="status" select="@statusCode"/>
                                    <xforms:group ref=".[name()='assignment']">
                                        <xforms:output mediatype="image/*" value="'/img/arrowright.png'">
                                            <xforms:hint ref="$resources/assignment"/>
                                        </xforms:output>
                                    </xforms:group>
                                    <xforms:group ref=".[name()='tracking']">
                                        <xforms:output mediatype="image/*" value="'/img/tracking.png'" class="node-issue-{$status}">
                                            <xforms:hint>
                                                <xforms:output ref="concat($resources/tracking,' / ',$resources/status,' = ')"/>
                                                <xforms:output ref="instance('decor-types')/IssueStatusCodeLifeCycle/enumeration[@value=$status]/label[@language=$resources/@xml:lang]"/>
                                            </xforms:hint>
                                        </xforms:output>
                                    </xforms:group>
                                </xhtml:td>
                                <xhtml:td class="heading-var" colspan="5">
                                    <!-- date -->
                                    <xforms:output ref="@effectiveDate" xxforms:format="if (. castable as xs:dateTime) then replace(format-dateTime(xs:dateTime(.),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else (.)"/>
                                    <xforms:output ref="': '"/>
                                    <!-- assignment to: -->
                                    <xforms:group ref=".[name()='assignment']">
                                        <xforms:output ref="concat($resources/assigned-to, ' ', @name)"/>
                                    </xforms:group>
                                    <!-- tracking -->
                                    <xforms:group ref=".[name()='tracking']">
                                        <xforms:output ref="$resources/tracking"/>
                                    </xforms:group>
                                    <xforms:output ref="concat(' ', lower-case($resources/by), ' ', author[1])"/>
                                    <!-- labels -->
                                    <xhtml:div style="float: right;">
                                        <xforms:repeat nodeset="tokenize(@labels, '\s')" class="not-selectable">
                                            <xxforms:variable name="selectedLabelCode" select="."/>
                                            <xxforms:variable name="selectedLabelColor" select="$labelDefinition/label[@code=$selectedLabelCode]/@color"/>
                                            <xxforms:variable name="selectedLabelName" select="$labelDefinition/label[@code=$selectedLabelCode]/@name"/>
                                            <xhtml:div style="background-color: white;color: black;font-weight: bold;font-size: smaller;border: 1px solid black;margin: 0px 5px 0px 0px;padding: 0px 0px 0px 0px;float: right;" title="{$selectedLabelName}">
                                                <xhtml:div style="background-color:{$selectedLabelColor};width: 10px;float: left;">&#160;</xhtml:div>
                                                <xhtml:div style="float: left;">
                                                    <xforms:output ref="concat('&#160;',$selectedLabelCode,'&#160;')"/>
                                                </xhtml:div>
                                            </xhtml:div>
                                        </xforms:repeat>
                                    </xhtml:div>
                                </xhtml:td>
                            </xhtml:tr>
                            <xforms:repeat nodeset="desc[string-length(string-join(.//text(),''))&gt;0]">
                                <xhtml:tr class="not-selectable">
                                    <xhtml:td class="item-label">
                                        <xforms:output ref="$resources/description"/>
                                    </xhtml:td>
                                    <xhtml:td colspan="5">
                                        <xforms:output mediatype="text/html" ref="."/>
                                    </xhtml:td>
                                </xhtml:tr>
                            </xforms:repeat>
                        </xhtml:table>
                    </xforms:repeat>
                </xhtml:td>
            </xhtml:tr>
        </xhtml:table>
    </part>
    <!--
        Decor Valueset readonly view
        Used in:
            art/xforms/decor-datasets.xhtml
            art/xforms/decor-issues.xhtml
            art/xforms/decor-terminology.xhtml
            art/xforms/decor-valuesets.xhtml
            art/xforms/decor-valuesets-editor.xhtml
        
        Requires variables:
        $resources
        
        Requires instances:
        project-instance
        version-navigation
        language
    -->
    <part id="valueset-readonly">
        <xxforms:variable name="valueSets" select="parent::*/valueSet"/>
        <xhtml:table class="detail spaced" width="100%">
            <!-- Name and displayName -->
            <xhtml:tr>
                <!-- valueset name -->
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/name"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:output ref="@name"/>
                </xhtml:td>
                <!-- valueset displayName -->
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/display-name"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:output ref="@displayName"/>
                </xhtml:td>
            </xhtml:tr>
            <!-- effectiveDate and status -->
            <xhtml:tr>
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/version"/>
                </xhtml:td>
                <xhtml:td>
                    <!-- We're an object reference in an issue -->
                    <xforms:group ref=".[self::object]">
                        <xforms:output ref="@effectiveDate" xxforms:format="if (. castable as xs:dateTime) then replace(format-dateTime(xs:dateTime(.),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else (.)"/>
                        <xforms:output ref="if (.[@id][@url]) then concat(' (', $resources/repository, ': ', .[@id]/@ident, ')') else ()"/>
                    </xforms:group>
                    <!-- We have only one selected valueSet -->
                    <xforms:group ref=".[not(self::object)][count($valueSets[@effectiveDate])=1]">
                        <xforms:output ref="$valueSets/@effectiveDate" xxforms:format="if (. castable as xs:dateTime) then replace(format-dateTime(xs:dateTime(.),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else (.)"/>
                        <xforms:output ref="if ($valueSets[@id][@url]) then concat(' (', $resources/repository, ': ', $valueSets[@id]/@ident, ')') else ()"/>
                    </xforms:group>
                    <!-- We have multiple selected valueSets. -->
                    <xforms:group ref=".[not(self::object)][count($valueSets[@effectiveDate])&gt;1]">
                        <xforms:select1 ref="instance('version-navigation')" appearance="minimal" class="auto-width">
                            <xforms:itemset nodeset="$valueSets[@effectiveDate]">
                                <xforms:label>
                                    <xforms:output ref="if (@effectiveDate castable as xs:dateTime) then replace(format-dateTime(xs:dateTime(@effectiveDate),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else (@effectiveDate)"/>
                                    <xforms:output ref="if (@versionLabel) then concat(' (', @versionLabel, ')') else ()"/>
                                    <xforms:output ref="if (@url) then concat(' (', $resources/repository, ': ', @ident, ')') else ()"/>
                                </xforms:label>
                                <xforms:value ref="@effectiveDate"/>
                            </xforms:itemset>
                            <xforms:action ev:event="xforms-value-changed">
                                <xforms:send submission="get-valueset-usage"/>
                            </xforms:action>
                        </xforms:select1>
                    </xforms:group>
                </xhtml:td>
                <!-- valueset status -->
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/status"/>
                </xhtml:td>
                <xhtml:td>
                    <xxforms:variable name="statusCode" select="if (self::object) then @statusCode else ($valueSets[@effectiveDate=instance('version-navigation')]/@statusCode)"/>
                    <xforms:output ref="instance('decor-types')/ItemStatusCodeLifeCycle/enumeration[@value=$statusCode]/label[@language=$resources/@xml:lang]" class="node-s{$statusCode}"/>
                </xhtml:td>
            </xhtml:tr>
            <!-- VersionLabel and id -->
            <xhtml:tr>
                <!-- versionLabel -->
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/versionLabel"/>
                </xhtml:td>
                <xhtml:td>
                    <xforms:output ref="if (self::object) then @versionLabel else ($valueSets[@effectiveDate=instance('version-navigation')]/@versionLabel)"/>
                </xhtml:td>
                <!-- id -->
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/id"/>
                </xhtml:td>
                <xhtml:td>
                    <xxforms:variable name="idcurrent" select="if (self::object) then (@iddisplay[string-length()&gt;0]) else ($valueSets[@effectiveDate=instance('version-navigation')]/(@iddisplay|@refdisplay))"/>
                    <xxforms:variable name="id" select="if ($idcurrent[string-length()&gt;0]) then $idcurrent else (@id|@ref)"/>
                    <!--<xforms:output ref="concat(instance('project-instance')/ids/baseId[@id=string-join(tokenize($id,'\.')[position()!=last()],'.') ]/@prefix,tokenize($id,'\.')[last()])"/>-->
                    <xforms:output ref="$id"/>
                </xhtml:td>
            </xhtml:tr>
            <xforms:group ref="self::object | $valueSets[@effectiveDate=instance('version-navigation')]">
                <!-- valueset description -->
                <xhtml:tr>
                    <xhtml:td class="item-label">
                        <xforms:output ref="$resources/description"/>
                    </xhtml:td>
                    <xhtml:td colspan="3">
                        <xforms:output mediatype="text/html" ref="desc[@language=instance('language')]"/>
                    </xhtml:td>
                </xhtml:tr>
                <xhtml:tr>
                    <xhtml:td colspan="4" style="border-bottom:solid 1px #d7b0c6;"/>
                </xhtml:tr>
                <!-- valueset sourceCodeSystems -->
                <xforms:group ref=".[sourceCodeSystem][conceptList/*]">
                    <xhtml:tr>
                        <xhtml:td class="item-label">
                            <xforms:output ref="$resources/source-codesystems"/>
                        </xhtml:td>
                        <xhtml:td colspan="3">
                            <xhtml:table width="100%" class="detail zebra-table">
                                <xforms:repeat nodeset="sourceCodeSystem">
                                    <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                        <xhtml:td>
                                            <xforms:output ref="@id"/>
                                        </xhtml:td>
                                        <xhtml:td>
                                            <xforms:output ref="@identifierName"/>
                                        </xhtml:td>
                                        <xhtml:td>
                                            <xforms:output ref="@canonicalUri"/>
                                        </xhtml:td>
                                    </xhtml:tr>
                                </xforms:repeat>
                            </xhtml:table>
                        </xhtml:td>
                    </xhtml:tr>
                </xforms:group>
                <!-- valueset completeCodeSystems -->
                <!-- <completeCodeSystem codeSystem="" codeSystemName="" codeSystemVersion="" flexibility="dynamic"/> -->
                <xforms:group ref=".[completeCodeSystem]">
                    <!-- valueset codesystems heading -->
                    <xhtml:tr class="heading">
                        <xhtml:td class="heading" colspan="4">
                            <xhtml:div class="heading">
                                <xforms:output ref="$resources/complete-codesystems"/>
                            </xhtml:div>
                        </xhtml:td>
                    </xhtml:tr>
                    <xhtml:tr>
                        <xhtml:td colspan="4">
                            <xxforms:variable name="doCodeSystemType" select="@type"/>
                            <xxforms:variable name="doCodeSystemVersion" select="@codeSystemVersion"/>
                            <xxforms:variable name="doCodeSystemFlexibility" select="@codeSystemFlexibility"/>
                            <xhtml:table width="100%" class="detail zebra-table">
                                <xhtml:tr>
                                    <!--<xforms:group ref=".[$doCodeSystemType]">-->
                                    <xhtml:td class="heading">
                                        <xforms:output ref="$resources/codesystemname"/>
                                    </xhtml:td>
                                    <!--</xforms:group>-->
                                    <xhtml:td class="heading">
                                        <xforms:output ref="$resources/codesystem"/>
                                    </xhtml:td>
                                    <xforms:group ref=".[$doCodeSystemVersion]">
                                        <xhtml:td class="heading">
                                            <xforms:output ref="$resources/codesystemversion"/>
                                        </xhtml:td>
                                    </xforms:group>
                                    <xforms:group ref=".[$doCodeSystemFlexibility]">
                                        <xhtml:td class="heading">
                                            <xforms:output ref="$resources/flexibility"/>
                                        </xhtml:td>
                                    </xforms:group>
                                </xhtml:tr>
                                <xforms:repeat nodeset="completeCodeSystem">
                                    <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                        <!--<xforms:group ref=".[$doCodeSystemType]">-->
                                        <xhtml:td rowspan="{count(filter) + 1}">
                                            <xforms:output ref="@type"/>
                                        </xhtml:td>
                                        <!--</xforms:group>-->
                                        <xhtml:td>
                                            <xxforms:variable name="codeSystem" select="@codeSystem"/>
                                            <xxforms:variable name="codeSystemName" select="../sourceCodeSystem[@id=$codeSystem]/@identifierName"/>
                                            <xhtml:div class="concepttype{@type}">
                                                <xforms:output ref="@codeSystemName | $codeSystemName[1]"/>
                                            </xhtml:div>
                                        </xhtml:td>
                                        <xhtml:td>
                                            <xhtml:div class="concepttype{@type}">
                                                <xforms:output ref="@codeSystem"/>
                                            </xhtml:div>
                                        </xhtml:td>
                                        <!--<xforms:group ref=".[$doCodeSystemVersion]">
                                            <xhtml:td>
                                                <xhtml:div class="concepttype{@type}">
                                                    <xforms:output ref="@codeSystemVersion"/>
                                                </xhtml:div>
                                            </xhtml:td>
                                        </xforms:group>-->
                                        <!--<xforms:group ref=".[$doCodeSystemFlexibility]">-->
                                        <xhtml:td>
                                            <xhtml:div class="concepttype{@type}">
                                                <xforms:output ref="@flexibility"/>
                                            </xhtml:div>
                                        </xhtml:td>
                                        <!--</xforms:group>-->
                                    </xhtml:tr>
                                    <xforms:group ref=".[filter]">
                                        <!-- header row -->
                                        <xhtml:tr class="not-selectable">
                                            <!-- property -->
                                            <xhtml:td class="item-label-var">
                                                <xforms:output ref="concat($resources/filter, ': ', $resources/property)"/>
                                            </xhtml:td>
                                            <!-- op -->
                                            <xhtml:td class="item-label-var">
                                                <xforms:output ref="$resources/intensional-op"/>
                                            </xhtml:td>
                                            <!-- value -->
                                            <xhtml:td class="item-label-var">
                                                <xforms:output ref="$resources/value"/>
                                            </xhtml:td>
                                        </xhtml:tr>
                                        <xforms:repeat nodeset="filter">
                                            <xhtml:tr class="not-selectable" style="border-top: 2px solid black;">
                                                <!-- property -->
                                                <xhtml:td>
                                                    <xforms:output ref="@property"/>
                                                </xhtml:td>
                                                <!-- op -->
                                                <xhtml:td>
                                                    <xforms:output ref="@op"/>
                                                </xhtml:td>
                                                <!-- value -->
                                                <xhtml:td>
                                                    <xforms:output ref="@value"/>
                                                </xhtml:td>
                                            </xhtml:tr>
                                        </xforms:repeat>
                                    </xforms:group>
                                </xforms:repeat>
                            </xhtml:table>
                        </xhtml:td>
                    </xhtml:tr>
                </xforms:group>
                <!-- valueset concepts heading -->
                <xforms:group ref=".[conceptList/(concept|exception)]">
                    <xhtml:tr class="heading">
                        <xhtml:td class="heading" colspan="4">
                            <xhtml:div class="heading">
                                <xforms:output ref="$resources/values"/>
                            </xhtml:div>
                        </xhtml:td>
                    </xhtml:tr>
                    <!-- valueset conceptList without pages -->
                    <xhtml:tr>
                        <xhtml:td colspan="4">
                            <xhtml:div style="width: 100%; max-height: 300px; overflow-x: auto; overflow-y: auto;">
                                <xhtml:table width="100%" class="detail zebra-table">
                                    <xhtml:tr>
                                        <xhtml:td class="heading">
                                            <xforms:output ref="$resources/level"/>/<xforms:output ref="$resources/type"/>
                                        </xhtml:td>
                                        <xhtml:td class="heading">
                                            <xforms:output ref="$resources/code"/>
                                        </xhtml:td>
                                        <xhtml:td class="heading">
                                            <xforms:output ref="$resources/display-name"/>
                                        </xhtml:td>
                                        <xforms:group ref=".[conceptList/*/@ordinal]">
                                            <xhtml:td class="heading">
                                                <xforms:output ref="$resources/ordinal"/>
                                            </xhtml:td>
                                        </xforms:group>
                                        <xhtml:td class="heading">
                                            <xforms:output ref="$resources/codesystem"/>
                                        </xhtml:td>
                                        <xforms:group ref=".[conceptList/*/@codeSystemVersion]">
                                            <xhtml:td class="heading">
                                                <xforms:output ref="$resources/codesystemversion"/>
                                            </xhtml:td>
                                        </xforms:group>
                                        <xhtml:td class="heading">
                                            <xforms:output ref="$resources/description"/>
                                        </xhtml:td>
                                    </xhtml:tr>
                                    <!-- Selection is need in at least decor-valuesets -->
                                    <xforms:repeat nodeset="conceptList/concept|conceptList/exception" id="valueSet-concepts-exceptions">
                                        <xhtml:tr class="zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                            <!-- level / type -->
                                            <xhtml:td>
                                                <xforms:group ref=".[name()='concept']">
                                                    <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                        <xforms:output ref="@level"/>-<xforms:output ref="@type"/>
                                                    </xhtml:span>
                                                </xforms:group>
                                            </xhtml:td>
                                            <!-- code -->
                                            <xhtml:td>
                                                <xhtml:div class="concepttype{@type} {local-name()}">
                                                    <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                        <xforms:output ref="@code"/>
                                                    </xhtml:span>
                                                </xhtml:div>
                                            </xhtml:td>
                                            <!-- displayName / designations -->
                                            <xhtml:td>
                                                <xhtml:div class="concepttype{@type} {local-name()}">
                                                    <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                        <xforms:output ref="@displayName"/>
                                                        <xforms:repeat nodeset="designation">
                                                            <xxforms:variable name="lang" select="@language"/>
                                                            <xxforms:variable name="type" select="@type"/>
                                                            <xxforms:variable name="langname" select="instance('resources-instance')/resources[@xml:lang=$lang]/@displayName"/>
                                                            <xxforms:variable name="typename" select="instance('decor-types')/DesignationType/enumeration[@value = $type]/label[@language=$resources/@xml:lang]"/>
                                                            <xhtml:div class="not-selectable">
                                                                <xhtml:img alt="" style="display: inline; margin-right:4px;" src="/img/flags/{$lang/lower-case(substring(.,4,2))}.png" title="{if ($langname) then $langname else (@language), $typename}"/>
                                                                <xforms:output ref="concat($typename,': ')"/>
                                                                <xforms:output ref="@displayName"/>
                                                            </xhtml:div>
                                                        </xforms:repeat>
                                                    </xhtml:span>
                                                </xhtml:div>
                                            </xhtml:td>
                                            <!-- ordinal -->
                                            <xforms:group ref=".[../*/@ordinal]">
                                                <xhtml:td>
                                                    <xhtml:div class="concepttype{@type} {local-name()}">
                                                        <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                            <xforms:output ref="@ordinal"/>
                                                        </xhtml:span>
                                                    </xhtml:div>
                                                </xhtml:td>
                                            </xforms:group>
                                            <!-- codesystem -->
                                            <xhtml:td>
                                                <xxforms:variable name="codeSystem" select="@codeSystem"/>
                                                <xxforms:variable name="codeSystemName" select="ancestor::valueSet/sourceCodeSystem[@id=$codeSystem]/@identifierName"/>
                                                <xhtml:div class="concepttype{@type} {local-name()}">
                                                    <xforms:output ref="if (string-length($codeSystemName)&gt;0) then $codeSystemName else @codeSystem"/>
                                                </xhtml:div>
                                            </xhtml:td>
                                            <!-- codesystemversion -->
                                            <xforms:group ref=".[../*/@codeSystemVersion]">
                                                <xhtml:td>
                                                    <xhtml:div class="concepttype{@type} {local-name()}">
                                                        <xforms:output ref="@codeSystemVersion"/>
                                                    </xhtml:div>
                                                </xhtml:td>
                                            </xforms:group>
                                            <!-- description -->
                                            <xhtml:td>
                                                <xforms:output mediatype="text/html" ref="desc[@language=instance('language')]"/>
                                            </xhtml:td>
                                        </xhtml:tr>
                                    </xforms:repeat>
                                </xhtml:table>
                            </xhtml:div>
                        </xhtml:td>
                    </xhtml:tr>
                    <xhtml:tr class="heading">
                        <xhtml:td class="heading" colspan="4">
                            <xforms:output ref="$resources/codesystemlegendaline"/>
                        </xhtml:td>
                    </xhtml:tr>
                </xforms:group>
            </xforms:group>
        </xhtml:table>
    </part>
    <!--
        Decor Valueset readonly view contents only. eXist-db doesn't do nested xinclude? would have been better
        Used in:
            art/xforms/decor-valuesets.xhtml for repository searches
        
        Requires variables:
        $resources
        
        Requires instances:
        language
    -->
    <part id="valueset-contents-readonly">
        <!-- valueset description -->
        <xhtml:tr>
            <xhtml:td class="item-label">
                <xforms:output ref="$resources/description"/>
            </xhtml:td>
            <xhtml:td colspan="3">
                <xforms:output mediatype="text/html" ref="desc[@language=instance('language')]"/>
            </xhtml:td>
        </xhtml:tr>
        <xhtml:tr>
            <xhtml:td colspan="4" style="border-bottom:solid 1px #d7b0c6;"/>
        </xhtml:tr>
        <!-- valueset sourceCodeSystems -->
        <xforms:group ref=".[sourceCodeSystem]">
            <xhtml:tr>
                <xhtml:td class="item-label">
                    <xforms:output ref="$resources/source-codesystems"/>
                </xhtml:td>
                <xhtml:td colspan="3">
                    <xhtml:table width="100%" class="detail zebra-table">
                        <xforms:repeat nodeset="sourceCodeSystem">
                            <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                <xhtml:td>
                                    <xforms:output ref="@id"/>
                                </xhtml:td>
                                <xhtml:td>
                                    <xforms:output ref="@identifierName"/>
                                </xhtml:td>
                                <xhtml:td>
                                    <xforms:output ref="@canonicalUri"/>
                                </xhtml:td>
                            </xhtml:tr>
                        </xforms:repeat>
                    </xhtml:table>
                </xhtml:td>
            </xhtml:tr>
        </xforms:group>
        <!-- valueset completeCodeSystems -->
        <!-- <completeCodeSystem codeSystem="" codeSystemName="" codeSystemVersion="" flexibility="dynamic"/> -->
        <xforms:group ref=".[completeCodeSystem]">
            <!-- valueset codesystems heading -->
            <xhtml:tr class="heading">
                <xhtml:td class="heading" colspan="4">
                    <xhtml:div class="heading">
                        <xforms:output ref="$resources/complete-codesystems"/>
                    </xhtml:div>
                </xhtml:td>
            </xhtml:tr>
            <xhtml:tr>
                <xhtml:td colspan="4">
                    <xhtml:table width="100%" class="detail zebra-table">
                        <xhtml:tr>
                            <xhtml:td class="heading">
                                <xforms:output ref="$resources/codesystemname"/>
                            </xhtml:td>
                            <xhtml:td class="heading">
                                <xforms:output ref="$resources/codesystem"/>
                            </xhtml:td>
                            <xhtml:td class="heading">
                                <xforms:output ref="$resources/codesystemversion"/>
                            </xhtml:td>
                            <xhtml:td class="heading">
                                <xforms:output ref="$resources/flexibility"/>
                            </xhtml:td>
                        </xhtml:tr>
                        <xforms:repeat nodeset="completeCodeSystem">
                            <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                <xhtml:td>
                                    <xforms:output ref="@codeSystemName"/>
                                </xhtml:td>
                                <xhtml:td>
                                    <xforms:output ref="@codeSystem"/>
                                </xhtml:td>
                                <xhtml:td>
                                    <xforms:output ref="@codeSystemVersion"/>
                                </xhtml:td>
                                <xhtml:td>
                                    <xforms:output ref="@flexibility"/>
                                </xhtml:td>
                            </xhtml:tr>
                        </xforms:repeat>
                    </xhtml:table>
                </xhtml:td>
            </xhtml:tr>
        </xforms:group>
        <!-- valueset concepts heading -->
        <xforms:group ref=".[conceptList/(concept|exception)]">
            <xhtml:tr class="heading">
                <xhtml:td class="heading" colspan="4">
                    <xhtml:div class="heading">
                        <xforms:output ref="$resources/values"/>
                    </xhtml:div>
                </xhtml:td>
            </xhtml:tr>
            <!-- valueset conceptList without pages -->
            <xhtml:tr>
                <xhtml:td colspan="4">
                    <xhtml:div style="width: 100%; max-height: 300px; overflow-x: auto; overflow-y: auto;">
                        <xhtml:table width="100%" class="detail zebra-table">
                            <xhtml:tr>
                                <xhtml:td class="heading">
                                    <xforms:output ref="$resources/level"/>/<xforms:output ref="$resources/type"/>
                                </xhtml:td>
                                <xhtml:td class="heading">
                                    <xforms:output ref="$resources/code"/>
                                </xhtml:td>
                                <xhtml:td class="heading">
                                    <xforms:output ref="$resources/display-name"/>
                                </xhtml:td>
                                <xforms:group ref=".[conceptList/*/@ordinal]">
                                    <xhtml:td class="heading">
                                        <xforms:output ref="$resources/ordinal"/>
                                    </xhtml:td>
                                </xforms:group>
                                <xhtml:td class="heading">
                                    <xforms:output ref="$resources/codesystem"/>
                                </xhtml:td>
                                <xforms:group ref=".[conceptList/*/@codeSystemVersion]">
                                    <xhtml:td class="heading">
                                        <xforms:output ref="$resources/codesystemversion"/>
                                    </xhtml:td>
                                </xforms:group>
                                <xhtml:td class="heading">
                                    <xforms:output ref="$resources/description"/>
                                </xhtml:td>
                            </xhtml:tr>
                            <xforms:repeat nodeset="conceptList/concept|conceptList/exception">
                                <xhtml:tr class="zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                    <!-- level / type -->
                                    <xhtml:td>
                                        <xforms:group ref=".[name()='concept']">
                                            <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                <xforms:output ref="@level"/>-<xforms:output ref="@type"/>
                                            </xhtml:span>
                                        </xforms:group>
                                    </xhtml:td>
                                    <!-- code -->
                                    <xhtml:td>
                                        <xhtml:div class="concepttype{@type} {local-name()}">
                                            <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                <xforms:output ref="@code"/>
                                            </xhtml:span>
                                        </xhtml:div>
                                    </xhtml:td>
                                    <!-- displayName / designations -->
                                    <xhtml:td>
                                        <xhtml:div class="concepttype{@type} {local-name()}">
                                            <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                <xforms:output ref="@displayName"/>
                                                <xforms:repeat nodeset="designation">
                                                    <xxforms:variable name="lang" select="@language"/>
                                                    <xxforms:variable name="type" select="@type"/>
                                                    <xxforms:variable name="langname" select="instance('resources-instance')/resources[@xml:lang=$lang]/@displayName"/>
                                                    <xxforms:variable name="typename" select="instance('decor-types')/DesignationType/enumeration[@value = $type]/label[@language=$resources/@xml:lang]"/>
                                                    <xhtml:div class="not-selectable">
                                                        <xforms:group ref=".[not(string-length($lang)>=5)]">
                                                            <xforms:output ref="concat('(',$lang,') ')"/>
                                                        </xforms:group>
                                                        <xforms:group ref=".[string-length($lang)>=5]">
                                                            <xhtml:img alt="" style="display: inline; margin-right:4px;" src="/img/flags/{$lang/lower-case(substring(.,4,2))}.png" title="{if ($langname) then $langname else (@language), $typename}"/>
                                                        </xforms:group>
                                                        <xforms:output ref="concat($typename,': ')"/>
                                                        <xforms:output ref="@displayName"/>
                                                    </xhtml:div>
                                                </xforms:repeat>
                                            </xhtml:span>
                                        </xhtml:div>
                                    </xhtml:td>
                                    <!-- ordinal -->
                                    <xforms:group ref=".[../*/@ordinal]">
                                        <xhtml:td>
                                            <xhtml:div class="concepttype{@type} {local-name()}">
                                                <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                    <xforms:output ref="@ordinal"/>
                                                </xhtml:span>
                                            </xhtml:div>
                                        </xhtml:td>
                                    </xforms:group>
                                    <!-- codesystem -->
                                    <xhtml:td>
                                        <xxforms:variable name="codeSystem" select="@codeSystem"/>
                                        <xxforms:variable name="codeSystemName" select="ancestor::valueSet/sourceCodeSystem[@id=$codeSystem]/@identifierName"/>
                                        <xhtml:div class="concepttype{@type} {local-name()}">
                                            <xforms:output ref="if (string-length($codeSystemName)&gt;0) then $codeSystemName else @codeSystem"/>
                                        </xhtml:div>
                                    </xhtml:td>
                                    <!-- codesystemversion -->
                                    <xforms:group ref=".[../*/@codeSystemVersion]">
                                        <xhtml:td>
                                            <xhtml:div class="concepttype{@type} {local-name()}">
                                                <xforms:output ref="@codeSystemVersion"/>
                                            </xhtml:div>
                                        </xhtml:td>
                                    </xforms:group>
                                    <!-- description -->
                                    <xhtml:td>
                                        <xforms:output mediatype="text/html" ref="desc[@language=instance('language')]"/>
                                    </xhtml:td>
                                </xhtml:tr>
                            </xforms:repeat>
                        </xhtml:table>
                    </xhtml:div>
                </xhtml:td>
            </xhtml:tr>
            <xhtml:tr class="heading">
                <xhtml:td class="heading" colspan="4">
                    <xforms:output ref="$resources/codesystemlegendaline"/>
                </xhtml:td>
            </xhtml:tr>
        </xforms:group>
    </part>
    <!--
        Decor CodeSystem readonly view contents only. eXist-db doesn't do nested xinclude? would have been better
        Used in:
            art/xforms/decor-codesystem.xhtml for repository searches
        
        Requires variables:
        $resources
        
        Requires instances:
        language
    -->
    <part id="codesystem-contents-readonly">
        <!-- valueset description -->
        <xhtml:tr>
            <xhtml:td class="item-label">
                <xforms:output ref="$resources/description"/>
            </xhtml:td>
            <xhtml:td colspan="3">
                <xforms:output mediatype="text/html" ref="desc[@language=instance('language')]"/>
            </xhtml:td>
        </xhtml:tr>
        <xhtml:tr>
            <xhtml:td colspan="4" style="border-bottom:solid 1px #d7b0c6;"/>
        </xhtml:tr>
        <!-- codesystem concepts heading -->
        <xforms:group ref=".[conceptList/codedConcept]">
            <xxforms:variable name="doOrdinal" select="exists(conceptList/codedConcept/@ordinal)"/>
            <xxforms:variable name="doEffective" select="exists(conceptList/codedConcept/@effectiveDate)"/>
            <xxforms:variable name="doExpiration" select="exists(conceptList/codedConcept/@expirationDate)"/>
            <xhtml:tr class="heading">
                <xhtml:td class="heading" colspan="4">
                    <xhtml:div class="heading">
                        <xforms:output ref="$resources/values"/>
                    </xhtml:div>
                </xhtml:td>
            </xhtml:tr>
            <!-- codesystem conceptList without pages -->
            <xhtml:tr>
                <xhtml:td colspan="4">
                    <xhtml:div style="width: 100%; max-height: 300px; overflow-x: auto; overflow-y: auto;">
                        <xhtml:table width="100%" class="detail zebra-table">
                            <xhtml:tr>
                                <xhtml:td class="heading">
                                    <xforms:output ref="$resources/level"/>/<xforms:output ref="$resources/type"/>
                                </xhtml:td>
                                <xhtml:td class="heading">
                                    <xforms:output ref="$resources/code"/>
                                </xhtml:td>
                                <xforms:group ref=".[$doOrdinal]">
                                    <xhtml:td class="heading">
                                        <xforms:output ref="$resources/ordinal"/>
                                    </xhtml:td>
                                </xforms:group>
                                <xforms:group ref=".[$doEffective]">
                                    <xhtml:td class="heading">
                                        <xforms:output ref="$resources/effectiveDate"/>
                                    </xhtml:td>
                                </xforms:group>
                                <xforms:group ref=".[$doExpiration]">
                                    <xhtml:td class="heading">
                                        <xforms:output ref="$resources/expiration-date"/>
                                    </xhtml:td>
                                </xforms:group>
                                <xhtml:td class="heading">
                                    <xforms:output ref="$resources/description"/>
                                </xhtml:td>
                            </xhtml:tr>
                            <xforms:repeat nodeset="conceptList/codedConcept">
                                <xhtml:tr class="zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                    <!-- level / type -->
                                    <xhtml:td>
                                        <xforms:group ref=".[name()='concept']">
                                            <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                <xforms:output ref="@level"/>-<xforms:output ref="@type"/>
                                            </xhtml:span>
                                        </xforms:group>
                                    </xhtml:td>
                                    <!-- code -->
                                    <xhtml:td>
                                        <xhtml:div class="concepttype{@type} {local-name()}">
                                            <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                <xforms:output ref="@code" class="node-s{@statusCode}"/>
                                            </xhtml:span>
                                        </xhtml:div>
                                    </xhtml:td>
                                    <!-- displayName / designations -->
                                    <xhtml:td>
                                        <xhtml:div class="concepttype{@type} {local-name()}">
                                            <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                <xforms:output ref="@displayName"/>
                                                <xforms:repeat nodeset="designation">
                                                    <xxforms:variable name="lang" select="@language"/>
                                                    <xxforms:variable name="type" select="@type"/>
                                                    <xxforms:variable name="langname" select="instance('resources-instance')/resources[@xml:lang=$lang]/@displayName"/>
                                                    <xxforms:variable name="typename" select="instance('decor-types')/DesignationType/enumeration[@value = $type]/label[@language=$resources/@xml:lang]"/>
                                                    <xhtml:div class="not-selectable">
                                                        <xforms:group ref=".[not(string-length($lang)>=5)]">
                                                            <xforms:output ref="concat('(',$lang,') ')"/>
                                                        </xforms:group>
                                                        <xforms:group ref=".[string-length($lang)>=5]">
                                                            <xhtml:img alt="" style="display: inline; margin-right:4px;" src="/img/flags/{$lang/lower-case(substring(.,4,2))}.png" title="{if ($langname) then $langname else (@language), $typename}"/>
                                                        </xforms:group>
                                                        <xforms:output ref="concat($typename,': ')"/>
                                                        <xforms:output ref="@displayName"/>
                                                    </xhtml:div>
                                                </xforms:repeat>
                                            </xhtml:span>
                                        </xhtml:div>
                                    </xhtml:td>
                                    <!-- ordinal -->
                                    <xforms:group ref=".[$doOrdinal]">
                                        <xhtml:td>
                                            <xhtml:div class="concepttype{@type} {local-name()}">
                                                <xhtml:span style="{concat('margin-left: ',number(@level) * 15,'px;')}">
                                                    <xforms:output ref="@ordinal"/>
                                                </xhtml:span>
                                            </xhtml:div>
                                        </xhtml:td>
                                    </xforms:group>
                                    <xforms:group ref=".[$doEffective]">
                                        <xhtml:td>
                                            <xhtml:div class="concepttype{@type} {local-name()}">
                                                <xforms:output ref="@effectiveDate"/>
                                            </xhtml:div>
                                        </xhtml:td>
                                    </xforms:group>
                                    <xforms:group ref=".[$doExpiration]">
                                        <xhtml:td>
                                            <xhtml:div class="concepttype{@type} {local-name()}">
                                                <xforms:output ref="@expirationDate"/>
                                            </xhtml:div>
                                        </xhtml:td>
                                    </xforms:group>
                                    <!-- description -->
                                    <xhtml:td>
                                        <xforms:output mediatype="text/html" ref="desc[@language=instance('language')]"/>
                                    </xhtml:td>
                                </xhtml:tr>
                            </xforms:repeat>
                        </xhtml:table>
                    </xhtml:div>
                </xhtml:td>
            </xhtml:tr>
            <xhtml:tr class="heading">
                <xhtml:td class="heading" colspan="4">
                    <xforms:output ref="$resources/codesystemlegendaline"/>
                </xhtml:td>
            </xhtml:tr>
        </xforms:group>
    </part>
    <!--
        Decor dataset concept info from community/communities
        Used in:
            art/xforms/decor-datasets.xhtml
            art/xforms/decor-scenarios.xhtml
            art/xforms/decor-terminology.xhtml
        
        Requires variables:
        $resources
        
        Requires instances:
        selected-concept
    -->
    <part id="concept-community-readonly">
        <xforms:repeat nodeset="community/associations/association/data">
            <xxforms:variable name="type" select="@type"/>
            <xxforms:variable name="datatype" select="//community/prototype/data[@type=$type]/@datatype"/>
            <xhtml:table class="not-selectable" width="100%">
                <xhtml:tr class="heading">
                    <xhtml:td class="heading">
                        <xxforms:variable name="communityName" select="if (ancestor::community/@displayName) then (ancestor::community/@displayName) else (ancestor::community/@name)"/>
                        <xforms:output ref="ancestor::community/prototype/data[@type=$type]/@label"/>
                        <xforms:output ref="concat(' (',$communityName,')')"/>
                    </xhtml:td>
                </xhtml:tr>
                <xhtml:tr>
                    <xhtml:td class="paddedtd">
                        <xhtml:table width="100%" class="detail spaced">
                            <xhtml:tr class="not-selectable">
                                <xforms:group ref=".[$datatype='text']">
                                    <xhtml:td class="item-label">
                                        <xforms:output ref="$resources/text"/>
                                    </xhtml:td>
                                </xforms:group>
                                <xforms:group ref=".[$datatype='code']">
                                    <xhtml:td class="item-label">
                                        <xforms:output ref="$resources/code"/>
                                    </xhtml:td>
                                </xforms:group>
                                <xhtml:td class="not-selectable">
                                    <xforms:output mediatype="text/html" ref="."/>
                                </xhtml:td>
                            </xhtml:tr>
                        </xhtml:table>
                    </xhtml:td>
                </xhtml:tr>
            </xhtml:table>
        </xforms:repeat>
    </part>
    <!--
        LOINC result set display after a search
        Used in:
            art/xforms/decor-terminology.xhtml
            art/xforms/decor-valueset-editor.xhtml
            terminology/xforms/loinc.xhtml
        
        Requires variables:
        
        Requires instances:
        loinc-concept-search
        loinc-concept-itemset
        
        These instances must be declared but may be empty:
        classtype-mapping
        chng_type-mapping
        system-mapping
        property-mapping
        scale-mapping
        timing-mapping
        
        Expects any event listeners to be declared in the form. Logic is form dependant so there's nothing in here
    -->
    <part id="loinc-resultset-readonly">
        <xforms:group ref="instance('loinc-concept-itemset')">
            <xxforms:variable name="firstoffset" select="1"/>
            <xxforms:variable name="prevoffset" select="instance('loinc-concept-search')/xs:integer(@offset) - instance('loinc-concept-search')/xs:integer(@max)"/>
            <xxforms:variable name="nextoffset" select="instance('loinc-concept-search')/xs:integer(@offset) + instance('loinc-concept-search')/xs:integer(@max)"/>
            <xxforms:variable name="lastoffset" select="xs:integer(@total) - (xs:integer(@total) mod instance('loinc-concept-search')/xs:integer(@max)) + 1"/>
            <xhtml:div class="h2">
                <xhtml:span style="margin-right: 1em;">
                    <xforms:group ref=".[instance('loinc-concept-search')[not(panel = 'true')]]">
                        <xforms:output ref="$resources/results"/>
                    </xforms:group>
                    <xforms:group ref=".[instance('loinc-concept-search')[panel = 'true']]">
                        <xforms:output ref="concat($resources/panel, ' [', instance('loinc-concept-itemset')/@total, ']')"/>
                    </xforms:group>
                </xhtml:span>
                
                <!-- if @total = 0 show a zero -->
                <xforms:group ref=".[@total='0']">
                    <xforms:output value="'0'"/>
                </xforms:group>
                <!-- if @total = 0 or empty(@total) then no results at, so don't page 
                    Also don't page for panels, which are never too large, and a consistent set in themselves, so paging makes no sense. -->
                <xforms:group ref=".[not(@total='0')][not(empty(@total))][instance('loinc-concept-search')[not(panel = 'true')]]">
                    <!-- first/previous without link -->
                    <xforms:group ref=".[xs:integer(@offset) = 1][not(@page-total = '1')]">
                        <xhtml:img src="/img/calendar-left-double.png" alt="" style="opacity: 0.5;vertical-align: middle;"/>
                        <xhtml:img src="/img/calendar-left.png" alt="" style="opacity: 0.5;vertical-align: middle;"/>
                    </xforms:group>
                    <!-- first/previous with link -->
                    <xforms:group ref=".[xs:integer(@offset) != 1]">
                        <xforms:trigger appearance="minimal">
                            <xforms:label>
                                <xhtml:img src="/img/calendar-left-double.png" alt=""/>
                            </xforms:label>
                            <xforms:hint ref="$resources/first-page"/>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@offset" value="1"/>
                            </xforms:action>
                        </xforms:trigger>
                        <xforms:trigger appearance="minimal">
                            <xforms:label>
                                <xhtml:img src="/img/calendar-left.png" alt=""/>
                            </xforms:label>
                            <xforms:hint ref="$resources/previous-page"/>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@offset" value="if ($prevoffset &lt; 1) then 1 else ($prevoffset)"/>
                            </xforms:action>
                        </xforms:trigger>
                    </xforms:group>
                    <!-- middle text Page X of Y -->
                    <xforms:group ref=".[xs:integer(@offset) != 1 or xs:integer(@current) &lt; xs:integer(@total)]">
                        <xhtml:span style="font-weight: normal;">
                            <xforms:output ref="concat(@page-current,' / ',@page-total)"/>
                        </xhtml:span>
                    </xforms:group>
                    <!-- next/last without link -->
                    <xforms:group ref=".[not((xs:integer(@offset) + xs:integer(@current)) &lt; xs:integer(@total))][not(@page-total = '1')]">
                        <xhtml:img src="/img/calendar-right.png" alt="" style="opacity: 0.5;vertical-align: middle;"/>
                        <xhtml:img src="/img/calendar-right-double.png" alt="" style="opacity: 0.5;vertical-align: middle;"/>
                    </xforms:group>
                    <!-- next/last with link -->
                    <xforms:group ref=".[(xs:integer(@offset) + xs:integer(@current)) &lt; xs:integer(@total)]">
                        <xforms:trigger appearance="minimal">
                            <xforms:label>
                                <xhtml:img src="/img/calendar-right.png" alt=""/>
                            </xforms:label>
                            <xforms:hint ref="$resources/next-page"/>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@offset" value="$nextoffset"/>
                            </xforms:action>
                        </xforms:trigger>
                        <xforms:trigger appearance="minimal">
                            <xforms:label>
                                <xhtml:img src="/img/calendar-right-double.png" alt=""/>
                            </xforms:label>
                            <xforms:hint ref="$resources/last-page"/>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@offset" value="$lastoffset"/>
                            </xforms:action>
                        </xforms:trigger>
                    </xforms:group>
                    <div class="buttons">[ <xforms:output ref="@offset"/> - <xforms:output ref="xs:integer(@offset) + xs:integer(@current) - 1"/> / <xforms:output ref="@total"/> ]</div>
                </xforms:group>
            </xhtml:div>
        </xforms:group>
        <xhtml:div style="width: 100%; max-height: 300px; overflow-x: auto; overflow-y: auto;">
            <xhtml:table width="100%" class="detail zebra-table">
                <xhtml:tr>
                    <xhtml:td class="heading" width="60">
                        <xforms:trigger appearance="minimal" class="{if (instance('loinc-concept-search')/@sort='LOINC_NUM') then 'sortcolumn' else ()}">
                            <xforms:label>
                                <xforms:output ref="$resources/loinc_col_loinc_num"/>
                            </xforms:label>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@sort" value="'LOINC_NUM'"/>
                            </xforms:action>
                        </xforms:trigger>
                    </xhtml:td>
                    <xhtml:td class="heading">
                        <xforms:trigger appearance="minimal" class="{if (instance('loinc-concept-search')/@sort='LONG_COMMON_NAME') then 'sortcolumn' else ()}">
                            <xforms:label>
                                <xforms:output ref="$resources/loinc_col_long_common_name"/>
                            </xforms:label>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@sort" value="'LONG_COMMON_NAME'"/>
                            </xforms:action>
                        </xforms:trigger>
                    </xhtml:td>
                    <xhtml:td class="heading">
                        <xforms:trigger appearance="minimal" class="{if (instance('loinc-concept-search')/@sort='COMPONENT') then 'sortcolumn' else ()}">
                            <xforms:label>
                                <xforms:output ref="$resources/loinc_col_component"/>
                            </xforms:label>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@sort" value="'COMPONENT'"/>
                            </xforms:action>
                        </xforms:trigger>
                    </xhtml:td>
                    <xhtml:td class="heading">
                        <xforms:trigger appearance="minimal" class="{if (instance('loinc-concept-search')/@sort='PROPERTY') then 'sortcolumn' else ()}">
                            <xforms:label>
                                <xforms:output ref="$resources/loinc_col_property"/>
                            </xforms:label>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@sort" value="'PROPERTY'"/>
                            </xforms:action>
                        </xforms:trigger>
                    </xhtml:td>
                    <xhtml:td class="heading">
                        <xforms:trigger appearance="minimal" class="{if (instance('loinc-concept-search')/@sort='TIME_ASPCT') then 'sortcolumn' else ()}">
                            <xforms:label>
                                <xforms:output ref="$resources/loinc_col_time_aspct"/>
                            </xforms:label>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@sort" value="'TIME_ASPCT'"/>
                            </xforms:action>
                        </xforms:trigger>
                    </xhtml:td>
                    <xhtml:td class="heading">
                        <xforms:trigger appearance="minimal" class="{if (instance('loinc-concept-search')/@sort='SYSTEM') then 'sortcolumn' else ()}">
                            <xforms:label>
                                <xforms:output ref="$resources/loinc_col_system"/>
                            </xforms:label>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@sort" value="'SYSTEM'"/>
                            </xforms:action>
                        </xforms:trigger>
                    </xhtml:td>
                    <xhtml:td class="heading">
                        <xforms:trigger appearance="minimal" class="{if (instance('loinc-concept-search')/@sort='SCALE_TYPE') then 'sortcolumn' else ()}">
                            <xforms:label>
                                <xforms:output ref="$resources/loinc_col_scale_typ"/>
                            </xforms:label>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@sort" value="'SCALE_TYPE'"/>
                            </xforms:action>
                        </xforms:trigger>
                    </xhtml:td>
                    <xhtml:td class="heading">
                        <xforms:trigger appearance="minimal" class="{if (instance('loinc-concept-search')/@sort='METHOD_TYP') then 'sortcolumn' else ()}">
                            <xforms:label>
                                <xforms:output ref="$resources/loinc_col_method_typ"/>
                            </xforms:label>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:setvalue ref="instance('loinc-concept-search')/@sort" value="'METHOD_TYP'"/>
                            </xforms:action>
                        </xforms:trigger>
                    </xhtml:td>
                </xhtml:tr>
                <xxforms:variable name="searchlang" select="instance('loinc-concept-search')/@language"/>
                <xforms:repeat nodeset="instance('loinc-concept-itemset')//concept[@loinc_num]" id="loinc-concepts" xxforms:external-events="keydown-pressed keyup-pressed">
                    <xhtml:tr class="zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                        <xhtml:td>
                            <xxforms:variable name="cstatus" select="@status"/>
                            <!-- status is ACTIVE (no bullet) or DEPRECATED DISCOURAGED TRIAL (blue bullet with tip) -->
                            <xforms:group ref=".[@status!='ACTIVE']">
                                <xforms:output ref="@loinc_num" class="{if (matches($cstatus,'(DISCOURAGED|DEPRECATED)')) then 'node-sdeprecated' else if ($cstatus='TRIAL') then 'node-sdraft' else ()}">
                                    <xforms:hint ref="$cstatus"/>
                                </xforms:output>
                            </xforms:group>
                            <xforms:group ref=".[@status='ACTIVE']">
                                <xforms:output ref="@loinc_num"/>
                            </xforms:group>
                        </xhtml:td>
                        <xhtml:td>
                            <!--<xforms:output ref="longName"/>-->
                            <xxforms:variable name="value" select="if (concept[@language=$searchlang]/longName) then (concept[@language=$searchlang][1]/longName) else (longName)"/>
                            <xxforms:variable name="lang" select="if (concept[@language=$searchlang]/longName) then (concept[@language=$searchlang][1]/@language) else ()"/>
                            <xforms:group ref=".[elem[@name='PanelType']]">
                                <xhtml:a href="loinc?conceptId={@loinc_num}&amp;panel=true" target="_blank">
                                    <xforms:output ref="$value"/>
                                </xhtml:a>
                            </xforms:group>
                            <xforms:group ref=".[not(elem[@name='PanelType'])]">
                                <xforms:output ref="$value"/>
                            </xforms:group>
                        </xhtml:td>
                        <xhtml:td>
                            <!--<xforms:output ref="component"/>-->
                            <xxforms:variable name="value" select="if (concept[@language=$searchlang]/component) then (concept[@language=$searchlang][1]/component) else (component)"/>
                            <xxforms:variable name="lang" select="if (concept[@language=$searchlang]/component) then (concept[@language=$searchlang][1]/@language) else ()"/>
                            <xforms:output ref="$value"/>
                        </xhtml:td>
                        <xhtml:td>
                            <!--<xforms:output ref="property"/>-->
                            <xxforms:variable name="value" select="if (concept[@language=$searchlang]/property) then (concept[@language=$searchlang][1]/property) else (property)"/>
                            <xxforms:variable name="lang" select="if (concept[@language=$searchlang]/property) then (concept[@language=$searchlang][1]/@language) else ()"/>
                            <xforms:output ref="$value"/>
                        </xhtml:td>
                        <xhtml:td>
                            <!--<xforms:output ref="timing"/>-->
                            <xxforms:variable name="value" select="if (concept[@language=$searchlang]/timing) then (concept[@language=$searchlang][1]/timing) else (timing)"/>
                            <xxforms:variable name="lang" select="if (concept[@language=$searchlang]/timing) then (concept[@language=$searchlang][1]/@language) else ()"/>
                            <xforms:output ref="$value"/>
                        </xhtml:td>
                        <xhtml:td>
                            <!--<xforms:output ref="system"/>-->
                            <xxforms:variable name="value" select="if (concept[@language=$searchlang]/system) then (concept[@language=$searchlang][1]/system) else (system)"/>
                            <xxforms:variable name="lang" select="if (concept[@language=$searchlang]/system) then (concept[@language=$searchlang][1]/@language) else ()"/>
                            <xforms:output ref="$value"/>
                        </xhtml:td>
                        <xhtml:td>
                            <!--<xforms:output ref="scale"/>-->
                            <xxforms:variable name="value" select="if (concept[@language=$searchlang]/scale) then (concept[@language=$searchlang][1]/scale) else (scale)"/>
                            <xxforms:variable name="lang" select="if (concept[@language=$searchlang]/scale) then (concept[@language=$searchlang][1]/@language) else ()"/>
                            <xforms:output ref="$value"/>
                        </xhtml:td>
                        <xhtml:td>
                            <!--<xforms:output ref="method"/>-->
                            <xxforms:variable name="value" select="if (concept[@language=$searchlang]/method) then (concept[@language=$searchlang][1]/method) else (method)"/>
                            <xxforms:variable name="lang" select="if (concept[@language=$searchlang]/method) then (concept[@language=$searchlang][1]/@language) else ()"/>
                            <xforms:output ref="$value"/>
                        </xhtml:td>
                    </xhtml:tr>
                </xforms:repeat>
            </xhtml:table>
        </xhtml:div>
    </part>
    <!-- 
        Select the (copyright) addrLine/@type
        Used in:
            art/xforms/decor-governance-group.xhtml
            art/xforms/decor-project.xhtml
        
        Requires variables:
        
        Requires instances:
        language
    -->
    <part id="addressline-editor">
        <xforms:group ref=".[not(addrLine)]">
            <xhtml:div style="margin-top: 2px;">
                <xforms:trigger appearance="minimal">
                    <xforms:label>
                        <xhtml:img src="/img/itemadd.png" alt="" style="width: 16px; height: 16px;"/>
                    </xforms:label>
                    <xforms:hint ref="$resources/add"/>
                    <xforms:insert ev:event="DOMActivate" context="." origin="xxforms:element('addrLine',(xxforms:attribute('type','')))"/>
                </xforms:trigger>
            </xhtml:div>
        </xforms:group>
        <xforms:group ref=".[addrLine]">
            <xhtml:table class="spaced" style="width: 100%; margin-left: 0; padding-left: 0;">
                <xforms:repeat nodeset="addrLine">
                    <xhtml:tr class="not-selectable">
                        <xhtml:td>
                            <xforms:trigger appearance="minimal">
                                <xforms:label>
                                    <xhtml:img src="/img/itemadd.png" alt="" style="width: 16px; height: 16px;"/>
                                </xforms:label>
                                <xforms:hint ref="$resources/add"/>
                                <xforms:insert ev:event="DOMActivate" nodeset="." origin="xxforms:element('addrLine',(xxforms:attribute('type','')))"/>
                            </xforms:trigger>
                            <xforms:trigger appearance="minimal">
                                <xforms:label>
                                    <xhtml:img src="/img/itemdelete.png" alt="" style="width: 16px; height: 16px;"/>
                                </xforms:label>
                                <xforms:hint ref="$resources/remove"/>
                                <xforms:delete ev:event="DOMActivate" nodeset="."/>
                            </xforms:trigger>
                        </xhtml:td>
                        <xhtml:td>
                            <xforms:input ref="." class="not-selectable" incremental="true">
                                <xforms:label ref="$resources/address" class="hidden"/>
                            </xforms:input>
                        </xhtml:td>
                        <xhtml:td>
                            <xforms:select1 ref="@type" class="auto-width not-selectable">
                                <xforms:label ref="$resources/type" class="hidden"/>
                                <xforms:item>
                                    <xforms:label ref="$resources/not-set"/>
                                    <xforms:value/>
                                </xforms:item>
                                <xforms:itemset nodeset="instance('decor-types')/AddressLineType/enumeration">
                                    <xforms:label ref="label[@language=instance('language')]"/>
                                    <xforms:value ref="@value"/>
                                </xforms:itemset>
                            </xforms:select1>
                        </xhtml:td>
                    </xhtml:tr>
                </xforms:repeat>
            </xhtml:table>
        </xforms:group>
    </part>
    <!-- 
        View the (copyright) addrLine/@type
        Used in:
            art/xforms/decor-governance-group.xhtml
            art/xforms/decor-project.xhtml
        
        Requires variables:
        
        Requires instances:
        language
    -->
    <part id="addressline-viewer">
        <xforms:repeat nodeset="addrLine">
            <xhtml:div class="not-selectable" style="margin-bottom: 2px;">
                <xxforms:variable name="addresslinetype" select="if (@type) then @type else ('')"/>
                <xxforms:variable name="addresslinedisplay" select="instance('decor-types')/AddressLineType/enumeration[@value=$addresslinetype]/label[@language=instance('language')]"/>
                <xforms:group ref=".[$addresslinetype=('uri')]">
                    <xforms:trigger appearance="minimal">
                        <xforms:label ref="."/>
                        <xforms:load ev:event="DOMActivate" resource="{.}" show="new"/>
                    </xforms:trigger>
                </xforms:group>
                <xforms:group ref=".[$addresslinetype=('facebook','linkedin','twitter')]">
                    <xhtml:img src="/img/{$addresslinetype}-logo.png" alt="" style="max-width: 16px; max-height: 16px; margin-right: 2px;"/>
                    <xforms:output ref="."/>
                </xforms:group>
                <xforms:group ref=".[$addresslinetype=('phone','email')]">
                    <xhtml:img src="/img/{$addresslinetype}.png" alt="" style="max-width: 16px; max-height: 16px; margin-right: 2px;"/>
                    <xforms:output ref="."/>
                </xforms:group>
                <xforms:group ref=".[not($addresslinetype=('email','facebook','linkedin','phone','twitter','uri'))]">
                    <xforms:output ref="if (string-length($addresslinedisplay)&gt;0) then concat(.,' (',$addresslinedisplay,')') else (.)"/>
                </xforms:group>
            </xhtml:div>
        </xforms:repeat>
    </part>
    <!--
        View the issue label
        Used every form with issues:
            art/xforms/decor-issues.xhtml
            
        Requires variables:
            
        Requires instances:
    -->
    <part id="issue-label-viewer" class="not-selectable">
        <xhtml:div class="labelouterboxitem" title="{desc[1]/text()}">
            <xhtml:div style="background-color:{@color}; display: inline; padding-left: 10px; margin: -3px;">&#160;</xhtml:div>
            <xhtml:div style="background-color: white;display: inline;">
                <xforms:output ref="concat('&#160;(',@code,')&#160;',@name,'&#160;')"/>
            </xhtml:div>
        </xhtml:div>
    </part>
    <!-- 
        Dialog for setting statusCode that you need want to hide from view
        Used in every form that does status based filtering:
            art/xforms/decor-datasets.xhtml
            art/xforms/decor-scenarios.xhtml
            art/xforms/decor-terminology.xhtml
            art/xforms/decor-template-mapping.xhtml
        
        Requires variables:
            
        Requires instances: 
            decor-types
            hide-statuses
     -->
    <part id="hide-status-dialog">
        <xxforms:dialog id="hide-status-dialog" appearance="minimal" level="modal" close="false" draggable="true" visible="false">
            <xforms:label ref="$resources/filter"/>
            <xhtml:table>
                <xhtml:tr>
                    <xhtml:td class="item-label" style="padding-right: 10px;padding-left: 10px;">
                        <xhtml:img src="/img/filter.png" alt="" align="right" title="{$resources/filter}"/>
                    </xhtml:td>
                    <xhtml:td>
                        <xforms:select ref="instance('hide-statuses')" appearance="full" class="inline">
                            <xforms:item>
                                <xforms:label ref="instance('decor-types')/ItemStatusCodeLifeCycle/enumeration[@value='cancelled']/label[@language=$resources/@xml:lang]"/>
                                <xforms:value>cancelled</xforms:value>
                            </xforms:item>
                            <xforms:item>
                                <xforms:label ref="instance('decor-types')/ItemStatusCodeLifeCycle/enumeration[@value='deprecated']/label[@language=$resources/@xml:lang]"/>
                                <xforms:value>deprecated</xforms:value>
                            </xforms:item>
                            <xforms:item>
                                <xforms:label ref="instance('decor-types')/ItemStatusCodeLifeCycle/enumeration[@value='rejected']/label[@language=$resources/@xml:lang]"/>
                                <xforms:value>rejected</xforms:value>
                            </xforms:item>
                        </xforms:select>
                    </xhtml:td>
                    <xhtml:td>
                        <xforms:trigger appearance="compact">
                            <xforms:label ref="$resources/close"/>
                            <xxforms:hide ev:event="DOMActivate" dialog="hide-status-dialog"/>
                        </xforms:trigger>
                    </xhtml:td>
                </xhtml:tr>
            </xhtml:table>
        </xxforms:dialog>
    </part>
    <!-- 
        Dialog for setting statusCode that you need want to hide from view
        Used in every form that does status based filtering:
            art/xforms/decor-templates.xhtml
        
        Requires variables:
        
        Requires instances:
        hide-templatestatuses
     -->
    <part id="hide-templatestatus-dialog">
        <xxforms:dialog id="hide-templatestatus-dialog" appearance="minimal" level="modal" close="false" draggable="true" visible="false">
            <xforms:label ref="$resources/filter"/>
            <xhtml:table>
                <xhtml:tr>
                    <xhtml:td class="item-label" style="padding-right: 10px;padding-left: 10px;">
                        <xhtml:img src="/img/filter.png" alt="" align="right" title="{$resources/filter}"/>
                    </xhtml:td>
                    <xhtml:td>
                        <xforms:select ref="instance('hide-templatestatuses')" appearance="full" class="inline">
                            <xforms:item>
                                <xforms:label ref="instance('decor-types')/TemplateStatusCodeLifeCycle/enumeration[@value='cancelled']/label[@language=$resources/@xml:lang]"/>
                                <xforms:value>cancelled</xforms:value>
                            </xforms:item>
                            <xforms:item>
                                <xforms:label ref="instance('decor-types')/TemplateStatusCodeLifeCycle/enumeration[@value='retired']/label[@language=$resources/@xml:lang]"/>
                                <xforms:value>retired</xforms:value>
                            </xforms:item>
                            <xforms:item>
                                <xforms:label ref="instance('decor-types')/TemplateStatusCodeLifeCycle/enumeration[@value='rejected']/label[@language=$resources/@xml:lang]"/>
                                <xforms:value>rejected</xforms:value>
                            </xforms:item>
                        </xforms:select>
                    </xhtml:td>
                    <xhtml:td>
                        <xforms:trigger appearance="compact">
                            <xforms:label ref="$resources/close"/>
                            <xxforms:hide ev:event="DOMActivate" dialog="hide-templatestatus-dialog"/>
                        </xforms:trigger>
                    </xhtml:td>
                </xhtml:tr>
            </xhtml:table>
        </xxforms:dialog>
    </part>
    <!-- View the objects history
        Used every form with history:
            art/xforms/decor-templates.xhtml
            art/xforms/decor-valuesets.xhtml
        
        Usage example:
        <xforms:group ref="instance('valueset-history')[history]">
            <xhtml:tr>
                <xhtml:td colspan="4">
                    <xi:include href="/db/apps/art/resources/xform-parts.xml" xpointer="xpointer(//part[@id='object-history'])">
                        <xi:fallback>
                            <xhtml:p>Included document /db/apps/art/resources/xform-parts.xml not found!</xhtml:p>
                        </xi:fallback>
                    </xi:include>
                </xhtml:td>
            </xhtml:tr>
        </xforms:group>
        
        Requires variables:
            
        Requires instances: 
            resources
            decor-types
    -->
    <part id="object-history">
        <fr:accordion class="fr-accordion-lnf">
            <fr:case>
                <fr:label ref="concat($resources/history,' (',count(history),')')"/>
                <xhtml:table width="100%" class="detail zebra-table">
                    <!-- concept history -->
                    <xhtml:tr>
                        <xhtml:td class="item-label">
                            <xforms:output ref="$resources/date"/>
                        </xhtml:td>
                        <xhtml:td class="item-label">
                            <xforms:output ref="$resources/author"/>
                        </xhtml:td>
                        <xhtml:td class="item-label">
                            <xforms:output ref="$resources/status"/>
                        </xhtml:td>
                        <xhtml:td class="item-label">
                            <xforms:output ref="$resources/type"/>
                        </xhtml:td>
                    </xhtml:tr>
                    <xforms:repeat nodeset="history">
                        <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                            <xhtml:td>
                                <xhtml:img src="/img/blueclock.png" alt="" title="{$resources/history}" width="16"/>
                                <xforms:output ref="' '"/>
                                <xforms:output ref="@date" xxforms:format="if (. castable as xs:dateTime) then replace(format-dateTime(xs:dateTime(.),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else (.)"/>
                            </xhtml:td>
                            <xhtml:td>
                                <xforms:output ref="@author"/>
                            </xhtml:td>
                            <xhtml:td>
                                <xxforms:variable name="statusCode" select="@artefactStatusCode"/>
                                <xforms:output ref="instance('decor-types')/ItemStatusCodeLifeCycle/enumeration[@value=$statusCode]/label[@language=$resources/@xml:lang]" class="node-s{$statusCode}"/>
                            </xhtml:td>
                            <xhtml:td>
                                <xforms:output ref="@intention"/>
                            </xhtml:td>
                        </xhtml:tr>
                    </xforms:repeat>
                </xhtml:table>
            </fr:case>
        </fr:accordion>
    </part>
    <!-- Publication filter 
        Used in:
            art/xforms/decor-development.xhtml
            art/xforms/decor-project.xhtml
        
        Requires instance:
            resource
            publication-parameters
            decor-types
            switches
    -->
    <part id="publication-filters">
        <xforms:group ref="instance('publication-parameters')/filters">
            <xxforms:variable name="filterId" select="@filterId"/>
            <xxforms:variable name="activeFilter" select="filters[@id = $filterId]"/>
            <xhtml:table class="detail spaced" width="100%">
                <xhtml:tr>
                    <xhtml:td class="item-label" width="25%">
                        <xforms:output ref="$resources/filter"/>
                        <xhtml:div style="float: right;">
                            <xforms:select1 ref="@filter" class="auto-width">
                                <xforms:label ref="$resources/filter" class="hidden"/>
                                <xforms:item>
                                    <xforms:label ref="$resources/on"/>
                                    <xforms:value>on</xforms:value>
                                </xforms:item>
                                <xforms:item>
                                    <xforms:label ref="$resources/off"/>
                                    <xforms:value>off</xforms:value>
                                </xforms:item>
                            </xforms:select1>
                        </xhtml:div>
                    </xhtml:td>
                    <xhtml:td class="item-label-var">
                        <xforms:select1 ref="@filterId">
                            <xforms:label ref="$resources/filter" class="hidden"/>
                            <xforms:item>
                                <xforms:label ref="concat('-- ', $resources/not-set, ' --')"/>
                                <xforms:value ref="''"/>
                            </xforms:item>
                            <xforms:itemset nodeset="../filters">
                                <xforms:label ref="(@label[not(. = '')], @id)[1]"/>
                                <xforms:value ref="@id"/>
                            </xforms:itemset>
                        </xforms:select1>
                        <xhtml:div class="buttons">
                            <!-- add filter -->
                            <xforms:trigger appearance="compact">
                                <xforms:label ref="$resources/add"/>
                                <xforms:action ev:event="DOMActivate">
                                    <xxforms:variable name="newid" select="max((0, filters/xs:integer(@id)))+1"/>
                                    <xxforms:variable name="newdate" select="substring(string(current-dateTime()), 1, 19)"/>
                                    <xforms:insert context="context()" origin="xxforms:element('filters', (xxforms:attribute('id', $newid), xxforms:attribute('label', concat('Label ', $newid)), xxforms:attribute('created', $newdate), xxforms:attribute('modified', $newdate)))"/>
                                    <xforms:setvalue ref="context()/@filterId" value="$newid"/>
                                    <!--<xforms:setfocus control="label4transaction"/>-->
                                </xforms:action>
                            </xforms:trigger>
                            <!-- remove filter -->
                            <xforms:trigger ref=".[$activeFilter]" appearance="compact">
                                <xforms:label ref="$resources/delete"/>
                                <xforms:action ev:event="DOMActivate">
                                    <xforms:delete nodeset="$activeFilter"/>
                                    <xforms:setvalue ref="context()/@filterId" value="string((context()/filters/@id)[1])"/>
                                </xforms:action>
                            </xforms:trigger>
                        </xhtml:div>
                    </xhtml:td>
                </xhtml:tr>
                <xforms:group ref="$activeFilter">
                    <xhtml:tr>
                        <xhtml:td class="item-label-var" width="25%">
                            <xforms:output ref="$resources/label-of-this-filter"/>
                        </xhtml:td>
                        <xhtml:td>
                            <!--<xforms:input ref="$activeFilter/@label" incremental="true" id="label4transaction">-->
                            <xforms:input ref="$activeFilter/@label" incremental="true">
                                <xforms:label ref="$resources/label-of-this-filter" class="hidden"/>
                                <xforms:alert ref="$resources/required"/>
                            </xforms:input>
                        </xhtml:td>
                    </xhtml:tr>
                    <xhtml:tr>
                        <xhtml:td class="item-label-var" width="25%">
                            <xforms:output ref="$resources/transactions"/>
                            <xhtml:div style="float: right;">
                                <xforms:trigger appearance="compact">
                                    <xforms:label ref="$resources/clear-selection"/>
                                    <xforms:delete ev:event="DOMActivate" ref="node()"/>
                                </xforms:trigger>
                            </xhtml:div>
                        </xhtml:td>
                        <xhtml:td>
                            <fr:accordion class="fr-accordion-lnf">
                                <fr:case selected="true">
                                    <fr:label ref="concat($resources/transactions, ' (', count(transaction), ' / ', count(../../transactions/transaction), ')')"/>
                                    <xhtml:table width="100%" class="detail">
                                        <xforms:repeat nodeset="instance('publication-parameters')/transactions/transaction">
                                            <xxforms:variable name="trid" select="@id"/>
                                            <xxforms:variable name="tred" select="@effectiveDate"/>
                                            <xxforms:variable name="trsc" select="@statusCode"/>
                                            <xxforms:variable name="trnm" select="(name[@language = $resources/xml:lang], name)[1]"/>
                                            <xhtml:tr class="not-selectable zebra-row-{if (position() mod 2 = 0) then 'even' else 'odd'}">
                                                <xhtml:td>
                                                    <!-- add to filter -->
                                                    <xforms:trigger ref="$activeFilter[not(transaction[@ref = $trid][@flexibility = $tred])]" appearance="minimal">
                                                        <xforms:label>
                                                            <xhtml:img src="/img/itemadd.png" alt=""/>
                                                        </xforms:label>
                                                        <xforms:hint ref="$resources/add"/>
                                                        <xforms:action ev:event="DOMActivate">
                                                            <xforms:setvalue ref="context()/@modified" value="substring(string(current-dateTime()), 1, 19)"/>
                                                            <xforms:insert ev:event="DOMActivate" context="." origin="xxforms:element('transaction', (xxforms:attribute('ref', $trid), xxforms:attribute('flexibility', $tred), $trsc, xxforms:attribute('name', $trnm)))"/>
                                                        </xforms:action>
                                                    </xforms:trigger>
                                                    <!-- remove from filter -->
                                                    <xforms:trigger ref="$activeFilter/transaction[@ref = $trid][@flexibility = $tred]" appearance="minimal">
                                                        <xforms:label>
                                                            <xhtml:img src="/img/itemdelete.png" alt=""/>
                                                        </xforms:label>
                                                        <xforms:hint ref="$resources/delete"/>
                                                        <xforms:action ev:event="DOMActivate">
                                                            <xforms:setvalue ref="context()/../@modified" value="substring(string(current-dateTime()), 1, 19)"/>
                                                            <xforms:delete nodeset="."/>
                                                        </xforms:action>
                                                    </xforms:trigger>
                                                </xhtml:td>
                                                <xhtml:td>
                                                    <xhtml:span style="font-weight: {if ($activeFilter/transaction[@ref = $trid][@flexibility = $tred]) then 'bold' else 'inherit'};" title="{(desc[@language = $resources/xml:lang], desc)[1]}">
                                                        <xforms:output ref="$trnm" class="{concat('node-s', $trsc)}"/>
                                                        <xforms:output ref="' - '"/>
                                                        <xforms:output ref="$trid"/>
                                                        <xforms:output ref="' - '"/>
                                                        <xforms:output ref="$tred" xxforms:format="if (. castable as xs:dateTime) then replace(format-dateTime(xs:dateTime(.),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', (), (), ()),' 00:00:00','') else (.)"/>
                                                        <xforms:output ref="if (@versionLabel) then concat(' (', @versionLabel,')') else ''"/>
                                                        <xforms:output ref="' '"/>
                                                        <xforms:output ref="instance('decor-types')/ItemStatusCodeLifeCycle/enumeration[@value=$trsc]/label[@language=$resources/@xml:lang]"/>
                                                    </xhtml:span>
                                                </xhtml:td>
                                            </xhtml:tr>
                                        </xforms:repeat>
                                    </xhtml:table>
                                </fr:case>
                            </fr:accordion>
                        </xhtml:td>
                    </xhtml:tr>
                </xforms:group>
                <!-- Save -->
                <xhtml:tr>
                    <xhtml:td colspan="2">
                        <xhtml:div class="buttons" style="margin-top: 0.5em; margin-bottom: 0.5em;">
                            <xforms:group ref="instance('publication-parameters')/filters[@filter='on']/filters[@id = ../@filterId][empty(transaction)]">
                                <xhtml:img src="/img/exclamation.gif" alt="Warning"/>
                                <xforms:output ref="$resources/empty-selection-in-filter"/>
                            </xforms:group>
                            <xforms:trigger appearance="compact" ref="instance('publication-parameters-safe')">
                                <xforms:label ref="$resources/cancel-changes"/>
                                <xforms:send ev:event="DOMActivate" submission="get-decor-publication-parameters"/>
                            </xforms:trigger>
                            <xforms:trigger appearance="compact" ref="instance('switches')">
                                <xforms:label>
                                    <xhtml:span style="font-weight: {if (instance('publication-parameters-safe') = 'true') then 'inherit' else 'bold'};">
                                        <xforms:output ref="$resources/save-changes"/>
                                    </xhtml:span>
                                </xforms:label>
                                <xforms:send ev:event="DOMActivate" submission="save-decor-publication-parameters"/>
                            </xforms:trigger>
                        </xhtml:div>
                    </xhtml:td>
                </xhtml:tr>
            </xhtml:table>
        </xforms:group>
    </part>
</parts>