Index: /cats/ISOcat/trunk/mod-ISOcat-access-data/access/dc_touch.acc
===================================================================
--- /cats/ISOcat/trunk/mod-ISOcat-access-data/access/dc_touch.acc	(revision 3457)
+++ /cats/ISOcat/trunk/mod-ISOcat-access-data/access/dc_touch.acc	(revision 3458)
@@ -1,3 +1,3 @@
-﻿<accessor debug="false">
+﻿<accessor debug="true">
 	<name>ISOcat.access.data.dc.touch</name>
 	<descr>Touch a DC.</descr>
@@ -43,4 +43,22 @@
 				<type>sloot.cutGoldenThread</type>
 				<param>var:thread</param>
+			</instr>
+			<!-- delete a cache for the DC -->
+			<instr>
+				<type>sloot.xquery</type>
+				<operator>
+					<string>/dc/{string($dc)}</string>
+				</operator>
+				<dc>var:dc</dc>
+				<target>var:cache</target>
+			</instr>
+			<instr>
+				<type>sloot.dbx-cache</type>
+				<entry>var:cache</entry>
+				<target>var:cache</target>
+			</instr>
+			<instr>
+				<type>log</type>
+				<operand>var:cache</operand>
 			</instr>
 			<!-- (re)check the DC -->
Index: /cats/ISOcat/trunk/mod-ISOcat-access-data/access/dc_update.acc
===================================================================
--- /cats/ISOcat/trunk/mod-ISOcat-access-data/access/dc_update.acc	(revision 3457)
+++ /cats/ISOcat/trunk/mod-ISOcat-access-data/access/dc_update.acc	(revision 3458)
@@ -194,5 +194,24 @@
 			</instr>
 		</accessor-debug>
-
+		
+		<!-- determine the direction of the DC check propagation -->
+		<instr>
+			<type>sloot.xquery</type>
+			<operator>
+				<string xmlns:dcif="http://www.isocat.org/ns/dcif">{if ($dc/dcif:dataCategorySelection/dcif:dataCategory/@type='simple') then ('up') else ('down')}</string>
+			</operator>
+			<dc>var:dc</dc>
+			<target>var:dir</target>
+		</instr>
+		
+		<!-- touch the updated DC -->
+		<instr>
+			<type>ISOcat.access.data.dc.touch</type>
+			<dc>var:id</dc>
+			<check>var:check</check>
+			<dir>var:dir</dir>
+			<target>var:void</target>
+		</instr>
+		
 		<!-- get the updated DCIF -->
 		<instr>
@@ -212,22 +231,4 @@
 		</accessor-debug>
 		
-		<!-- determine the direction of the DC check propagation -->
-		<instr>
-			<type>sloot.xquery</type>
-			<operator>
-				<string xmlns:dcif="http://www.isocat.org/ns/dcif">{if ($dc/dcif:dataCategorySelection/dcif:dataCategory/@type='simple') then ('up') else ('down')}</string>
-			</operator>
-			<dc>var:response</dc>
-			<target>var:dir</target>
-		</instr>
-		<!-- touch the updated DC -->
-		<instr>
-			<type>ISOcat.access.data.dc.touch</type>
-			<dc>var:id</dc>
-			<check>var:check</check>
-			<dir>var:dir</dir>
-			<target>var:void</target>
-		</instr>
-
 		<!-- a nice log message -->
 		<instr>
@@ -240,6 +241,5 @@
 					<xsl:template match="text()"/>
 					<xsl:template match="/dcif:dataCategorySelection/dcif:dataCategory">
-						<msg>INF: <xsl:value-of select="current-dateTime()"/>: updated
-								DC[<xsl:value-of select="@isocat:id"/>][<xsl:value-of
+						<msg>INF: <xsl:value-of select="current-dateTime()"/>: updated DC[<xsl:value-of select="@isocat:id"/>][<xsl:value-of
 								select="@isocat:owner"/>-<xsl:value-of
 								select="dcif:administrationInformationSection/dcif:administrationRecord/dcif:identifier"
Index: /cats/ISOcat/trunk/mod-ISOcat-access-data/access/dcs_to_dcif.acc
===================================================================
--- /cats/ISOcat/trunk/mod-ISOcat-access-data/access/dcs_to_dcif.acc	(revision 3457)
+++ /cats/ISOcat/trunk/mod-ISOcat-access-data/access/dcs_to_dcif.acc	(revision 3458)
@@ -197,4 +197,10 @@
 			<instr>
 				<type>log</type>
+				<operand>this:response</operand>
+			</instr>
+		</accessor-debug>
+		<accessor-debug>
+			<instr>
+				<type>log</type>
 				<operand>var:cleanup</operand>
 			</instr>
@@ -247,4 +253,54 @@
 				</instr>
 			</then>
+			<cond>
+				<instr>
+					<type>sloot.xpath2eval</type>
+					<operand>var:dcs</operand>
+					<operator>
+						<xpath>exists(/dcs/dc/@rank)</xpath>
+					</operator>
+					<target>this:cond</target>
+				</instr>
+			</cond>
+			<then>
+				<accessor-debug>
+					<instr>
+						<type>sloot.debug</type>
+						<debug>var:accessor-debug</debug>
+						<operand>
+							<msg>DBG: Adding ranking info to the DCIF</msg>
+						</operand>
+					</instr>
+				</accessor-debug>
+				<instr>
+					<type>xslt2</type>
+					<operand>this:response</operand>
+					<operator>
+						<xsl:stylesheet 
+							xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+							version="2.0"
+							xmlns:dcif="http://www.isocat.org/ns/dcif"
+							xmlns:dcr="http://www.isocat.org/ns/dcr"
+							xmlns:isocat="http://www.isocat.org/"
+						>
+							<xsl:output method="xml" encoding="utf-8"/>
+							<xsl:param name="ranks"/>
+							<xsl:template match="dcif:dataCategory">
+								<xsl:copy>
+									<xsl:attribute name="isocat:rank" select="$ranks//dc[@ref=current()/@isocat:id]/@rank"/>
+									<xsl:apply-templates select="@*|node()"/>
+								</xsl:copy>
+							</xsl:template>
+							<xsl:template match="@*|node()">
+								<xsl:copy>
+									<xsl:apply-templates select="@*|node()"/>
+								</xsl:copy>
+							</xsl:template>
+						</xsl:stylesheet>
+					</operator>
+					<ranks>var:dcs</ranks>
+					<target>this:response</target>
+				</instr>
+			</then>
 		</choose>
 	</idoc>
Index: /cats/ISOcat/trunk/mod-ISOcat-access-data/dbx/DCIF.xml
===================================================================
--- /cats/ISOcat/trunk/mod-ISOcat-access-data/dbx/DCIF.xml	(revision 3457)
+++ /cats/ISOcat/trunk/mod-ISOcat-access-data/dbx/DCIF.xml	(revision 3458)
@@ -24,5 +24,4 @@
 	
 	<dbx:variable name="keyset" select="$dcs/dcs/dc/@ref"/>
-	<dbx:variable name="rankset" select="$dcs/dcs/dc/@rank"/>
 
 	<dbx:variable name="suppress-query" when="$suppress-context-type='profile' or $suppress-context-type='dcs'" query="
@@ -313,5 +312,5 @@
 	
 	<dbx:process>
-		<dcif:dataCategorySelection dcif-version="1.2" xmlns:isocat="http://www.isocat.org/">
+		<dcif:dataCategorySelection dcif-version="1.2" xmlns:isocat="http://www.isocat.org/" xmlns:xi="http://www.w3.org/2001/XInclude">
 			<dbx:choose>
 				<dbx:when test="exists($name) and (normalize-space($name)!='')">
@@ -332,373 +331,284 @@
 			</dbx:choose>
 			<dbx:for-each select="$keyset" as="key" min="0" max="*">
-				<dbx:variable name="rank" select="$rankset[$key-pos]"/>
 				<dbx:for-each table="core_data_category" min="1" max="1">
 					<dbx:where field="id" select="$key" type="integer"/>
-					<dcif:dataCategory isocat:id="{$current/id}" isocat:identifier="{$current/identifier}" isocat:name="{$current/name}" isocat:owner_id="{$current/owner}" dcr:datcat="http://www.isocat.org/datcat/DC-48">
-						<dbx:for-each table="core_user" min="0" max="1">
-							<dbx:where field="id" select="$current/owner" type="integer"/>
-							<dbx:attribute name="isocat:owner" select="if (normalize-space($current/last_name)!='') then (if (normalize-space($current/first_name)!='') then (concat($current/last_name,', ',$current/first_name)) else ($current/last_name)) else ($current/login)"/>
-							<dbx:attribute name="isocat:owner_forum" field="forum" when="normalize-space(@*:owner_forum)!=''"/>
-						</dbx:for-each>
-						<dbx:for-each table="core_thematic_domain_group" min="0" max="1">
-							<dbx:where field="id" select="$current/owner" type="integer"/>
-							<dbx:attribute name="isocat:owner" select="concat('TDG: ',$current/name)"/>
-						</dbx:for-each>
-						<dbx:attribute name="isocat:type" field="type"/>
-						<dbx:choose>
-							<dbx:when test="$current/type='simple'">
-								<dbx:attribute name="type" value="simple"/>
-							</dbx:when>
-							<dbx:when test="exists(index-of(('open','constrained','closed'),$current/type))">
-								<dbx:attribute name="type" value="complex"/>
-							</dbx:when>
-							<dbx:when test="$current/type='container'">
-								<dbx:attribute name="type" value="container"/>
-							</dbx:when>
-							<dbx:otherwise>
-								<dbx:attribute name="type" value="unknown"/>
-							</dbx:otherwise>
-						</dbx:choose>
-						<dbx:attribute name="pid" field="pid"/>
-						<dbx:choose>
-							<dbx:when test="$current/private='true'">
-								<dbx:attribute name="isocat:scope" value="private"/>
-							</dbx:when>
-							<dbx:otherwise>
-								<dbx:attribute name="isocat:scope" value="public"/>
-							</dbx:otherwise>
-						</dbx:choose>
-						<dbx:choose>
-							<dbx:when test="exists($rank)">
-								<dbx:attribute name="isocat:rank" select="$rank"/>
-							</dbx:when>
-						</dbx:choose>
-						<dbx:choose>
-							<dbx:when test="$mode!='all'">
-								<dbx:call-template name="data_category-summary"/>
-							</dbx:when>
-						</dbx:choose>
-						<dbx:call-template name="data_category-lineage"/>
-						<dbx:for-each table="core_recommendation" min="0" max="*">
-							<dbx:where field="dc" select="$key" type="integer"/>
-							<dbx:for-each table="core_adhoc_group" min="0" max="1">
-								<dbx:where field="id" select="$current/group" type="integer"/>
-								<isocat:recommendedBy id="{$current/id}" dbx:field="name"/>
+					<dbx:cache id="/dc/{$key}/DCIF-M-{$mode}-S-{$suppress}-{$suppress-context-type}-{$suppress-context}-P-{string-join($profiles,'-')}-WL-{string-join($working-languages,'-')}-OL-{string-join($object-languages,'-')}-X-{$parse-xml-constraints}">
+						<dcif:dataCategory isocat:id="{$current/id}" isocat:identifier="{$current/identifier}" isocat:name="{$current/name}" isocat:owner_id="{$current/owner}" dcr:datcat="http://www.isocat.org/datcat/DC-48">
+							<dbx:for-each table="core_user" min="0" max="1">
+								<dbx:where field="id" select="$current/owner" type="integer"/>
+								<dbx:attribute name="isocat:owner" select="if (normalize-space($current/last_name)!='') then (if (normalize-space($current/first_name)!='') then (concat($current/last_name,', ',$current/first_name)) else ($current/last_name)) else ($current/login)"/>
+								<dbx:attribute name="isocat:owner_forum" field="forum" when="normalize-space(@*:owner_forum)!=''"/>
 							</dbx:for-each>
 							<dbx:for-each table="core_thematic_domain_group" min="0" max="1">
-								<dbx:where field="id" select="$current/group" type="integer"/>
-								<isocat:recommendedBy id="{$current/id}">
-									<dbx:value-of select="concat('TDG: ',$current/name)"/>
-								</isocat:recommendedBy>
+								<dbx:where field="id" select="$current/owner" type="integer"/>
+								<dbx:attribute name="isocat:owner" select="concat('TDG: ',$current/name)"/>
 							</dbx:for-each>
-						</dbx:for-each>
-						<dbx:choose>
-							<dbx:when test="$mode='all'">
-								<dcif:administrationInformationSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-51">
-									<dcif:administrationRecord isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-52">
-										<dcif:identifier dbx:field="identifier" dcr:datcat="http://www.isocat.org/datcat/DC-8"/>
-										<dcif:version dbx:field="version" dcr:datcat="http://www.isocat.org/datcat/DC-2400">
-											<dbx:attribute name="isocat:branch" field="branch"/>
-											<dbx:attribute name="isocat:revision" field="revision"/>
-											<dbx:attribute name="isocat:sidebranches" field="sidebranches"/>
-										</dcif:version>
-										<dcif:registrationStatus dcr:datcat="http://www.isocat.org/datcat/DC-21" dbx:field="registration_status">
-											<dbx:choose>
-												<dbx:when test="$current/registration_status='candidate'">
-													<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-24"/>
-												</dbx:when>
-												<dbx:when test="$current/registration_status='standard'">
-													<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-22"/>
-												</dbx:when>
-												<dbx:when test="$current/registration_status='deprecated'">
-													<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-2401"/>
-												</dbx:when>
-												<dbx:when test="$current/registration_status='superseded'">
-													<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-26"/>
-												</dbx:when>
-											</dbx:choose>
-										</dcif:registrationStatus>
-										<isocat:administrationStatus dcr:datcat="http://www.isocat.org/datcat/DC-2" dbx:field="administration_status"/>
-										<dcif:justification  dbx:field="justification" dcr:datcat="http://www.isocat.org/datcat/DC-2410"  dbx:when="normalize-space(.)!=''"/>
-										<dbx:for-each table="generic_text" min="0" max="*">
+							<dbx:attribute name="isocat:type" field="type"/>
+							<dbx:choose>
+								<dbx:when test="$current/type='simple'">
+									<dbx:attribute name="type" value="simple"/>
+								</dbx:when>
+								<dbx:when test="exists(index-of(('open','constrained','closed'),$current/type))">
+									<dbx:attribute name="type" value="complex"/>
+								</dbx:when>
+								<dbx:when test="$current/type='container'">
+									<dbx:attribute name="type" value="container"/>
+								</dbx:when>
+								<dbx:otherwise>
+									<dbx:attribute name="type" value="unknown"/>
+								</dbx:otherwise>
+							</dbx:choose>
+							<dbx:attribute name="pid" field="pid"/>
+							<dbx:choose>
+								<dbx:when test="$current/private='true'">
+									<dbx:attribute name="isocat:scope" value="private"/>
+								</dbx:when>
+								<dbx:otherwise>
+									<dbx:attribute name="isocat:scope" value="public"/>
+								</dbx:otherwise>
+							</dbx:choose>
+							<dbx:choose>
+								<dbx:when test="$mode!='all'">
+									<dbx:call-template name="data_category-summary"/>
+								</dbx:when>
+							</dbx:choose>
+							<dbx:call-template name="data_category-lineage"/>
+							<dbx:for-each table="core_recommendation" min="0" max="*">
+								<dbx:where field="dc" select="$key" type="integer"/>
+								<dbx:for-each table="core_adhoc_group" min="0" max="1">
+									<dbx:where field="id" select="$current/group" type="integer"/>
+									<isocat:recommendedBy id="{$current/id}" dbx:field="name"/>
+								</dbx:for-each>
+								<dbx:for-each table="core_thematic_domain_group" min="0" max="1">
+									<dbx:where field="id" select="$current/group" type="integer"/>
+									<isocat:recommendedBy id="{$current/id}">
+										<dbx:value-of select="concat('TDG: ',$current/name)"/>
+									</isocat:recommendedBy>
+								</dbx:for-each>
+							</dbx:for-each>
+							<dbx:choose>
+								<dbx:when test="$mode='all'">
+									<dcif:administrationInformationSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-51">
+										<dcif:administrationRecord isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-52">
+											<dcif:identifier dbx:field="identifier" dcr:datcat="http://www.isocat.org/datcat/DC-8"/>
+											<dcif:version dbx:field="version" dcr:datcat="http://www.isocat.org/datcat/DC-2400">
+												<dbx:attribute name="isocat:branch" field="branch"/>
+												<dbx:attribute name="isocat:revision" field="revision"/>
+												<dbx:attribute name="isocat:sidebranches" field="sidebranches"/>
+											</dcif:version>
+											<dcif:registrationStatus dcr:datcat="http://www.isocat.org/datcat/DC-21" dbx:field="registration_status">
+												<dbx:choose>
+													<dbx:when test="$current/registration_status='candidate'">
+														<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-24"/>
+													</dbx:when>
+													<dbx:when test="$current/registration_status='standard'">
+														<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-22"/>
+													</dbx:when>
+													<dbx:when test="$current/registration_status='deprecated'">
+														<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-2401"/>
+													</dbx:when>
+													<dbx:when test="$current/registration_status='superseded'">
+														<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-26"/>
+													</dbx:when>
+												</dbx:choose>
+											</dcif:registrationStatus>
+											<isocat:administrationStatus dcr:datcat="http://www.isocat.org/datcat/DC-2" dbx:field="administration_status"/>
+											<dcif:justification  dbx:field="justification" dcr:datcat="http://www.isocat.org/datcat/DC-2410"  dbx:when="normalize-space(.)!=''"/>
+											<dbx:for-each table="generic_text" min="0" max="*">
+												<dbx:where field="owner" select="$current/id" type="integer"/>
+												<dbx:where field="owner_type" value="data category"       type="string"/>
+												<dbx:where field="text_type"  value="administration note" type="string"/>
+												<isocat:administrationNote isocat:id="{$current/id}" dbx:field="text">
+													<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
+												</isocat:administrationNote>
+											</dbx:for-each>
+											<dcif:origin dbx:field="origin" dcr:datcat="http://www.isocat.org/datcat/DC-19" dbx:when="normalize-space(.)!=''"/>
+											<dbx:for-each table="generic_text" min="0" max="*">
+												<dbx:where field="owner" select="$current/id" type="integer"/>
+												<dbx:where field="owner_type" value="data category"       type="string"/>
+												<dbx:where field="text_type"  value="explanatory comment" type="string"/>
+												<dcif:explanatoryComment isocat:id="{$current/id}" dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-7">
+													<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
+												</dcif:explanatoryComment>
+											</dbx:for-each>
+											<dbx:for-each table="generic_text" min="0" max="*">
+												<dbx:where field="owner" select="$current/id" type="integer"/>
+												<dbx:where field="owner_type" value="data category"    type="string"/>
+												<dbx:where field="text_type"  value="unresolved issue" type="string"/>
+												<dcif:unresolvedIssue isocat:id="{$current/id}" dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-29">
+													<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
+												</dcif:unresolvedIssue>
+											</dbx:for-each>
+											<dcif:effectiveDate dbx:field="effective_date" dcr:datcat="http://www.isocat.org/datcat/DC-6" dbx:when="normalize-space(.)!=''"/>
+											<dcif:untilDate dbx:field="until_date" dcr:datcat="http://www.isocat.org/datcat/DC-30" dbx:when="normalize-space(.)!=''"/>
+											<dbx:for-each table="generic_text" min="1" max="*">
+												<dbx:where field="owner" select="$current/id" type="integer"/>
+												<dbx:where field="owner_type" value="data category" type="string"/>
+												<dbx:where field="text_type"  value="change"        type="string"/>
+												<dbx:sort field="timestamp" order="ascending"/>
+												<dbx:choose>
+													<dbx:when test="$current-pos = 1">
+														<dcif:creation isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2398">
+															<dcif:creationDate dbx:field="date" dcr:datcat="http://www.isocat.org/datcat/DC-5"/>
+															<dcif:changeDescription dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-3">
+																<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
+															</dcif:changeDescription>
+														</dcif:creation>
+													</dbx:when>
+													<dbx:when test="($current-size > 1) and ($current-pos = $current-size)">
+														<dcif:lastChange isocat:id="{$current/id}"  dcr:datcat="http://www.isocat.org/datcat/DC-2399">
+															<dcif:lastChangeDate dbx:field="date" dcr:datcat="http://www.isocat.org/datcat/DC-9"/>
+															<dcif:changeDescription dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-3">
+																<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
+															</dcif:changeDescription>
+														</dcif:lastChange>
+													</dbx:when>
+												</dbx:choose>
+												<isocat:change isocat:id="{$current/id}">
+													<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
+													<dbx:attribute name="timestamp" field="timestamp"/>
+													<dbx:value-of field="text"/>
+												</isocat:change>
+											</dbx:for-each>
+										</dcif:administrationRecord>
+									</dcif:administrationInformationSection>
+								</dbx:when>
+							</dbx:choose>
+							<dbx:choose>
+								<dbx:when test="$mode='all' ">
+									<dcif:descriptionSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-49">
+										<dbx:for-each table="link_profile_members" min="1" max="*">
+											<dbx:where field="dc" select="$current/id"/>
+											<dbx:variable name="profile" select="$current/profile"/>
+											<dbx:variable name="member" value="true"/>
+											<dbx:call-template name="profile-trail"/>
+										</dbx:for-each>
+										<dbx:for-each table="generic_name" min="0" max="*">
 											<dbx:where field="owner" select="$current/id" type="integer"/>
-											<dbx:where field="owner_type" value="data category"       type="string"/>
-											<dbx:where field="text_type"  value="administration note" type="string"/>
-											<isocat:administrationNote isocat:id="{$current/id}" dbx:field="text">
-												<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
-											</isocat:administrationNote>
+											<dbx:where field="owner_type" value="data category"     type="string"/>
+											<dbx:where field="name_type"  value="data element name" type="string"/>
+											<dbx:sort field="id"/>
+											<dcif:dataElementNameSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2402">
+												<dcif:dataElementName dbx:field="name" dcr:datcat="http://www.isocat.org/datcat/DC-56"/>
+												<dcif:source dbx:field="source" dcr:datcat="http://www.isocat.org/datcat/DC-27"/>
+											</dcif:dataElementNameSection>
 										</dbx:for-each>
-										<dcif:origin dbx:field="origin" dcr:datcat="http://www.isocat.org/datcat/DC-19" dbx:when="normalize-space(.)!=''"/>
-										<dbx:for-each table="generic_text" min="0" max="*">
-											<dbx:where field="owner" select="$current/id" type="integer"/>
-											<dbx:where field="owner_type" value="data category"       type="string"/>
-											<dbx:where field="text_type"  value="explanatory comment" type="string"/>
-											<dcif:explanatoryComment isocat:id="{$current/id}" dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-7">
-												<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
-											</dcif:explanatoryComment>
-										</dbx:for-each>
-										<dbx:for-each table="generic_text" min="0" max="*">
-											<dbx:where field="owner" select="$current/id" type="integer"/>
-											<dbx:where field="owner_type" value="data category"    type="string"/>
-											<dbx:where field="text_type"  value="unresolved issue" type="string"/>
-											<dcif:unresolvedIssue isocat:id="{$current/id}" dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-29">
-												<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
-											</dcif:unresolvedIssue>
-										</dbx:for-each>
-										<dcif:effectiveDate dbx:field="effective_date" dcr:datcat="http://www.isocat.org/datcat/DC-6" dbx:when="normalize-space(.)!=''"/>
-										<dcif:untilDate dbx:field="until_date" dcr:datcat="http://www.isocat.org/datcat/DC-30" dbx:when="normalize-space(.)!=''"/>
-										<dbx:for-each table="generic_text" min="1" max="*">
-											<dbx:where field="owner" select="$current/id" type="integer"/>
-											<dbx:where field="owner_type" value="data category" type="string"/>
-											<dbx:where field="text_type"  value="change"        type="string"/>
-											<dbx:sort field="timestamp" order="ascending"/>
-											<dbx:choose>
-												<dbx:when test="$current-pos = 1">
-													<dcif:creation isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2398">
-														<dcif:creationDate dbx:field="date" dcr:datcat="http://www.isocat.org/datcat/DC-5"/>
-														<dcif:changeDescription dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-3">
-															<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
-														</dcif:changeDescription>
-													</dcif:creation>
-												</dbx:when>
-												<dbx:when test="($current-size > 1) and ($current-pos = $current-size)">
-													<dcif:lastChange isocat:id="{$current/id}"  dcr:datcat="http://www.isocat.org/datcat/DC-2399">
-														<dcif:lastChangeDate dbx:field="date" dcr:datcat="http://www.isocat.org/datcat/DC-9"/>
-														<dcif:changeDescription dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-3">
-															<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
-														</dcif:changeDescription>
-													</dcif:lastChange>
-												</dbx:when>
-											</dbx:choose>
-											<isocat:change isocat:id="{$current/id}">
-												<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
-												<dbx:attribute name="timestamp" field="timestamp"/>
-												<dbx:value-of field="text"/>
-											</isocat:change>
-										</dbx:for-each>
-									</dcif:administrationRecord>
-								</dcif:administrationInformationSection>
-							</dbx:when>
-						</dbx:choose>
-						<dbx:choose>
-							<dbx:when test="$mode='all' ">
-								<dcif:descriptionSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-49">
-									<dbx:for-each table="link_profile_members" min="1" max="*">
-										<dbx:where field="dc" select="$current/id"/>
-										<dbx:variable name="profile" select="$current/profile"/>
-										<dbx:variable name="member" value="true"/>
-										<dbx:call-template name="profile-trail"/>
-									</dbx:for-each>
-									<dbx:for-each table="generic_name" min="0" max="*">
-										<dbx:where field="owner" select="$current/id" type="integer"/>
-										<dbx:where field="owner_type" value="data category"     type="string"/>
-										<dbx:where field="name_type"  value="data element name" type="string"/>
-										<dbx:sort field="id"/>
-										<dcif:dataElementNameSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2402">
-											<dcif:dataElementName dbx:field="name" dcr:datcat="http://www.isocat.org/datcat/DC-56"/>
-											<dcif:source dbx:field="source" dcr:datcat="http://www.isocat.org/datcat/DC-27"/>
-										</dcif:dataElementNameSection>
-									</dbx:for-each>
-									<dbx:for-each table="core_language_section" min="0" max="*">
-										<!-- the english language section is mandatory, but you can skip it in a object language view -->
-										<dbx:where field="dc" select="$current/id"/>
-										<dbx:where field="language" operator="in" select="$working-languages//id" type="integer" when="exists($working-languages//id)"/>
-										<dcif:languageSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2412">
-											<dcif:language isocat:id="{$current/language}" isocat:direction="{$core_language//row[id=$current/language]/direction}" isocat:name="{$core_language//row[id=$current/language]/name}" dcr:datcat="http://www.isocat.org/datcat/DC-35">
-												<dbx:value-of select="$core_language//row[id=$current/language]/tag"/>
-											</dcif:language>
-											<dbx:for-each table="generic_name" min="0" max="*">
-												<dbx:where field="owner" select="$current/id" type="integer"/>
-												<dbx:where field="owner_type" value="language section" type="string"/>
-												<dbx:where field="name_type"  value="name section"     type="string"/>
-												<dbx:sort field="status"/>
-												<dbx:sort field="id"/>
-												<dcif:nameSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-50">
-													<dcif:name dbx:field="name" dcr:datcat="http://www.isocat.org/datcat/DC-11">
-														<dbx:for-each table="generic_name" min="1" max="1">
-															<dbx:where field="id" select="$current/id" type="integer"/>
-															<dbx:sort field="id"/>
+										<dbx:for-each table="core_language_section" min="0" max="*">
+											<!-- the english language section is mandatory, but you can skip it in a object language view -->
+											<dbx:where field="dc" select="$current/id"/>
+											<dbx:where field="language" operator="in" select="$working-languages//id" type="integer" when="exists($working-languages//id)"/>
+											<dcif:languageSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2412">
+												<dcif:language isocat:id="{$current/language}" isocat:direction="{$core_language//row[id=$current/language]/direction}" isocat:name="{$core_language//row[id=$current/language]/name}" dcr:datcat="http://www.isocat.org/datcat/DC-35">
+													<dbx:value-of select="$core_language//row[id=$current/language]/tag"/>
+												</dcif:language>
+												<dbx:for-each table="generic_name" min="0" max="*">
+													<dbx:where field="owner" select="$current/id" type="integer"/>
+													<dbx:where field="owner_type" value="language section" type="string"/>
+													<dbx:where field="name_type"  value="name section"     type="string"/>
+													<dbx:sort field="status"/>
+													<dbx:sort field="id"/>
+													<dcif:nameSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-50">
+														<dcif:name dbx:field="name" dcr:datcat="http://www.isocat.org/datcat/DC-11">
+															<dbx:for-each table="generic_name" min="1" max="1">
+																<dbx:where field="id" select="$current/id" type="integer"/>
+																<dbx:sort field="id"/>
+																<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
+																<dbx:attribute name="isocat:direction" select="$core_language//row[id=$current/language]/direction"/>
+															</dbx:for-each>
+														</dcif:name>
+														<dcif:nameStatus dbx:field="status" dcr:datcat="http://www.isocat.org/datcat/DC-12">
+															<dbx:choose>
+																<dbx:when test="$current/status='standardized name'">
+																	<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-13"/>
+																</dbx:when>
+																<dbx:when test="$current/status='preferred name'">
+																	<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-14"/>
+																</dbx:when>
+																<dbx:when test="$current/status='admitted name'">
+																	<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-15"/>
+																</dbx:when>
+																<dbx:when test="$current/status='deprecated name'">
+																	<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-16"/>
+																</dbx:when>
+																<dbx:when test="$current/status='superseded name'">
+																	<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-17"/>
+																</dbx:when>
+															</dbx:choose>
+														</dcif:nameStatus>
+													</dcif:nameSection>
+												</dbx:for-each>
+												<dbx:for-each table="generic_text" min="0" max="*">
+													<dbx:where field="owner" select="$current/id" type="integer"/>
+													<dbx:where field="owner_type" value="language section" type="string"/>
+													<dbx:where field="text_type"  value="definition"       type="string"/>
+													<dbx:sort field="id"/>
+													<dcif:definitionSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2413">
+														<dcif:definition dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-32">
 															<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
 															<dbx:attribute name="isocat:direction" select="$core_language//row[id=$current/language]/direction"/>
+														</dcif:definition>
+														<dcif:source dbx:field="source" dcr:datcat="http://www.isocat.org/datcat/DC-27"/>
+														<dbx:for-each table="generic_text" min="0" max="1">
+															<dbx:where field="owner" select="$current/id" type="integer"/>
+															<dbx:where field="owner_type" value="text" type="string"/>
+															<dbx:where field="text_type"  value="note" type="string"/>
+															<dbx:sort field="id"/>
+															<dcif:note isocat:id="{$current/id}" dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-36">
+																<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
+																<dbx:attribute name="isocat:direction" select="$core_language//row[id=$current/language]/direction"/>
+															</dcif:note>
 														</dbx:for-each>
-													</dcif:name>
-													<dcif:nameStatus dbx:field="status" dcr:datcat="http://www.isocat.org/datcat/DC-12">
-														<dbx:choose>
-															<dbx:when test="$current/status='standardized name'">
-																<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-13"/>
-															</dbx:when>
-															<dbx:when test="$current/status='preferred name'">
-																<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-14"/>
-															</dbx:when>
-															<dbx:when test="$current/status='admitted name'">
-																<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-15"/>
-															</dbx:when>
-															<dbx:when test="$current/status='deprecated name'">
-																<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-16"/>
-															</dbx:when>
-															<dbx:when test="$current/status='superseded name'">
-																<dbx:attribute name="dcr:valueDatcat" value="http://www.isocat.org/datcat/DC-17"/>
-															</dbx:when>
-														</dbx:choose>
-													</dcif:nameStatus>
-												</dcif:nameSection>
-											</dbx:for-each>
-											<dbx:for-each table="generic_text" min="0" max="*">
-												<dbx:where field="owner" select="$current/id" type="integer"/>
-												<dbx:where field="owner_type" value="language section" type="string"/>
-												<dbx:where field="text_type"  value="definition"       type="string"/>
-												<dbx:sort field="id"/>
-												<dcif:definitionSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2413">
-													<dcif:definition dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-32">
+													</dcif:definitionSection>
+												</dbx:for-each>
+												<dbx:for-each table="generic_text" min="0" max="*">
+													<dbx:where field="owner" select="$current/id" type="integer"/>
+													<dbx:where field="owner_type" value="language section" type="string"/>
+													<dbx:where field="text_type"  value="example"          type="string"/>
+													<dbx:sort field="id"/>
+													<dcif:exampleSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2403">
+														<dcif:example dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-33">
+															<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
+															<dbx:attribute name="isocat:direction" select="$core_language//row[id=$current/language]/direction"/>
+														</dcif:example>
+														<dcif:source dbx:field="source" dcr:datcat="http://www.isocat.org/datcat/DC-27" dbx:when="normalize-space(.)!=''"/>
+													</dcif:exampleSection>
+												</dbx:for-each>
+												<dbx:for-each table="generic_text" min="0" max="*">
+													<dbx:where field="owner" select="$current/id" type="integer"/>
+													<dbx:where field="owner_type" value="language section" type="string"/>
+													<dbx:where field="text_type"  value="explanation"      type="string"/>
+													<dbx:sort field="id"/>
+													<dcif:explanationSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2404">
+														<dcif:explanation dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-34">
+															<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
+															<dbx:attribute name="isocat:direction" select="$core_language//row[id=$current/language]/direction"/>
+														</dcif:explanation>
+														<dcif:source dbx:field="source" dcr:datcat="http://www.isocat.org/datcat/DC-27" dbx:when="normalize-space(.)!=''"/>
+													</dcif:explanationSection>
+												</dbx:for-each>
+												<dbx:for-each table="generic_text" min="0" max="*">
+													<dbx:where field="owner" select="$current/id" type="integer"/>
+													<dbx:where field="owner_type" value="language section" type="string"/>
+													<dbx:where field="text_type"  value="note"             type="string"/>
+													<dbx:sort field="id"/>
+													<dcif:note isocat:id="{$current/id}" dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-36">
 														<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
 														<dbx:attribute name="isocat:direction" select="$core_language//row[id=$current/language]/direction"/>
-													</dcif:definition>
-													<dcif:source dbx:field="source" dcr:datcat="http://www.isocat.org/datcat/DC-27"/>
-													<dbx:for-each table="generic_text" min="0" max="1">
-														<dbx:where field="owner" select="$current/id" type="integer"/>
-														<dbx:where field="owner_type" value="text" type="string"/>
-														<dbx:where field="text_type"  value="note" type="string"/>
-														<dbx:sort field="id"/>
-														<dcif:note isocat:id="{$current/id}" dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-36">
-															<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
-															<dbx:attribute name="isocat:direction" select="$core_language//row[id=$current/language]/direction"/>
-														</dcif:note>
-													</dbx:for-each>
-												</dcif:definitionSection>
-											</dbx:for-each>
-											<dbx:for-each table="generic_text" min="0" max="*">
-												<dbx:where field="owner" select="$current/id" type="integer"/>
-												<dbx:where field="owner_type" value="language section" type="string"/>
-												<dbx:where field="text_type"  value="example"          type="string"/>
-												<dbx:sort field="id"/>
-												<dcif:exampleSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2403">
-													<dcif:example dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-33">
-														<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
-														<dbx:attribute name="isocat:direction" select="$core_language//row[id=$current/language]/direction"/>
-													</dcif:example>
-													<dcif:source dbx:field="source" dcr:datcat="http://www.isocat.org/datcat/DC-27" dbx:when="normalize-space(.)!=''"/>
-												</dcif:exampleSection>
-											</dbx:for-each>
-											<dbx:for-each table="generic_text" min="0" max="*">
-												<dbx:where field="owner" select="$current/id" type="integer"/>
-												<dbx:where field="owner_type" value="language section" type="string"/>
-												<dbx:where field="text_type"  value="explanation"      type="string"/>
-												<dbx:sort field="id"/>
-												<dcif:explanationSection isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-2404">
-													<dcif:explanation dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-34">
-														<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
-														<dbx:attribute name="isocat:direction" select="$core_language//row[id=$current/language]/direction"/>
-													</dcif:explanation>
-													<dcif:source dbx:field="source" dcr:datcat="http://www.isocat.org/datcat/DC-27" dbx:when="normalize-space(.)!=''"/>
-												</dcif:explanationSection>
-											</dbx:for-each>
-											<dbx:for-each table="generic_text" min="0" max="*">
-												<dbx:where field="owner" select="$current/id" type="integer"/>
-												<dbx:where field="owner_type" value="language section" type="string"/>
-												<dbx:where field="text_type"  value="note"             type="string"/>
-												<dbx:sort field="id"/>
-												<dcif:note isocat:id="{$current/id}" dbx:field="text" dcr:datcat="http://www.isocat.org/datcat/DC-36">
-													<dbx:attribute name="xml:lang" select="$core_language//row[id=$current/language]/tag"/>
-													<dbx:attribute name="isocat:direction" select="$core_language//row[id=$current/language]/direction"/>
-												</dcif:note>
-											</dbx:for-each>
-										</dcif:languageSection>
-									</dbx:for-each>
-								</dcif:descriptionSection>
-							</dbx:when>
-						</dbx:choose>
-						<dbx:choose>
-							<dbx:when test="$mode!='list'">
-								<dbx:choose>
-									<dbx:when test="$current/type='open'">
-										<dbx:for-each table="link_open_data_category_conceptual_domain" min="1" max="1">
-											<dbx:where field="dc" select="$current/id"/>
-											<dbx:for-each table="core_open_conceptual_domain" min="1" max="1">
-												<dbx:where field="id" select="$current/cd"/>
-												<dcif:conceptualDomain isocat:id="{$current/id}" type="open" dcr:datcat="http://www.isocat.org/datcat/DC-4">
-													<dbx:for-each table="core_conceptual_domain" min="1" max="1">
-														<dbx:where field="id" select="$current/id"/>
-														<dbx:for-each table="core_data_type" min="1" max="1">
-															<dbx:where field="id" select="$current/data_type"/>
-															<dcif:dataType isocat:id="{$current/id}" dbx:field="data_type" dcr:datcat="http://www.isocat.org/datcat/DC-2397"/>
-														</dbx:for-each>
-													</dbx:for-each>
-												</dcif:conceptualDomain>
-											</dbx:for-each>
+													</dcif:note>
+												</dbx:for-each>
+											</dcif:languageSection>
 										</dbx:for-each>
-									</dbx:when>
-									<dbx:when test="$current/type='constrained'">
-										<dbx:for-each table="link_constrained_data_category_conceptual_domains" min="1" max="*">
-											<dbx:where field="dc" select="$current/id"/>
-											<dbx:call-template name="constrained_conceptual_domain"/>
-										</dbx:for-each>
-									</dbx:when>
-									<dbx:when test="$current/type='closed'">
-										<dbx:for-each table="link_closed_data_category_conceptual_domains" min="1" max="*">
-											<dbx:where field="dc" select="$current/id"/>
-											<dbx:for-each table="core_profile_value_domain" min="1" max="1">
-												<dbx:where field="id" select="$current/cd"/>
-												<dbx:where field="profile" operator="in" select="$profiles//id" when="exists($profiles//id)"/>
-												<dcif:conceptualDomain isocat:id="{$current/id}" type="closed" dcr:datcat="http://www.isocat.org/datcat/DC-4">
-													<dbx:choose>
-														<dbx:when test="($suppress='true') and ($suppress-context-type='profile') and ($current/profile!=$suppress-context)">
-															<dbx:attribute name="isocat:suppress" value="true"/>
-														</dbx:when>
-													</dbx:choose>
-													<dbx:for-each table="core_conceptual_domain" min="1" max="1">
-														<dbx:where field="id" select="$current/id"/>
-														<dbx:for-each table="core_data_type" min="1" max="1">
-															<dbx:where field="id" select="$current/data_type"/>
-															<dcif:dataType isocat:id="{$current/id}" dbx:field="data_type" dcr:datcat="http://www.isocat.org/datcat/DC-2397"/>
-														</dbx:for-each>
-													</dbx:for-each>
-													<dbx:for-each table="core_profile" min="1" max="1">
-														<dbx:where field="id" select="$current/profile"/>
-														<dcif:profile isocat:id="{$current/id}" dbx:field="name" dcr:datcat="http://www.isocat.org/datcat/DC-37"/>
-													</dbx:for-each>
-													<dbx:for-each table="link_value_domain_values" min="1" max="*">
-														<dbx:where field="cd" select="$current/id"/>
-														<dbx:call-template name="value"/>
-													</dbx:for-each>
-												</dcif:conceptualDomain>
-											</dbx:for-each>
-										</dbx:for-each>
-									</dbx:when>
-								</dbx:choose>
-								<dbx:choose>
-									<dbx:when test="$current/type='open' or $current/type='constrained'">
-										<dbx:for-each table="core_constrained_linguistic_section" min="0" max="*">
-											<dbx:where field="dc" select="$current/id"/>
-											<dbx:for-each table="core_linguistic_section" min="1" max="1">
-												<dbx:where field="id" select="$current/id"/>
-												<dbx:where field="language" operator="in" select="$object-languages//id" type="integer" when="exists($object-languages//id)"/>
-												<dcif:linguisticSection isocat:id="{$current/id}" type="constrained" dcr:datcat="http://www.isocat.org/datcat/DC-2408">
-													<dbx:call-template name="linguistic_section-core"/>
-													<dbx:for-each table="link_constrained_linguistic_section_conceptual_domains" min="0" max="*">
-														<dbx:where field="ls" select="$current/id"/>
-														<dbx:call-template name="constrained_conceptual_domain"/>
-													</dbx:for-each>
-												</dcif:linguisticSection>
-											</dbx:for-each>
-										</dbx:for-each>
-									</dbx:when>
-									<dbx:when test="$current/type='closed'">
-										<dbx:for-each table="core_closed_linguistic_section" min="0" max="*">
-											<dbx:where field="dc" select="$current/id"/>
-											<dbx:variable name="ol" when="exists($object-languages//id)" query="
-												SELECT
-													language
-												FROM
-													core_linguistic_section
-												WHERE
-													id = {$current/id}
-												;
-											"/>
-											<dbx:variable name="ol" when="empty($object-languages//id)" select="()"/>
-											<dcif:linguisticSection isocat:id="{$current/id}" type="closed" dcr:datcat="http://www.isocat.org/datcat/DC-2408" dbx:when="(empty($object-languages//id)) or (exists($object-languages//id[.=$ol//language]))">
-												<dbx:call-template name="linguistic_section-core"/>
-												<dbx:for-each table="core_value_domain" min="0" max="1">
-													<dbx:where field="id" select="$current/cd" fallback="0"/>
-													<dcif:conceptualDomain type="closed" isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-4">
+									</dcif:descriptionSection>
+								</dbx:when>
+							</dbx:choose>
+							<dbx:choose>
+								<dbx:when test="$mode!='list'">
+									<dbx:choose>
+										<dbx:when test="$current/type='open'">
+											<dbx:for-each table="link_open_data_category_conceptual_domain" min="1" max="1">
+												<dbx:where field="dc" select="$current/id"/>
+												<dbx:for-each table="core_open_conceptual_domain" min="1" max="1">
+													<dbx:where field="id" select="$current/cd"/>
+													<dcif:conceptualDomain isocat:id="{$current/id}" type="open" dcr:datcat="http://www.isocat.org/datcat/DC-4">
 														<dbx:for-each table="core_conceptual_domain" min="1" max="1">
 															<dbx:where field="id" select="$current/id"/>
@@ -708,4 +618,37 @@
 															</dbx:for-each>
 														</dbx:for-each>
+													</dcif:conceptualDomain>
+												</dbx:for-each>
+											</dbx:for-each>
+										</dbx:when>
+										<dbx:when test="$current/type='constrained'">
+											<dbx:for-each table="link_constrained_data_category_conceptual_domains" min="1" max="*">
+												<dbx:where field="dc" select="$current/id"/>
+												<dbx:call-template name="constrained_conceptual_domain"/>
+											</dbx:for-each>
+										</dbx:when>
+										<dbx:when test="$current/type='closed'">
+											<dbx:for-each table="link_closed_data_category_conceptual_domains" min="1" max="*">
+												<dbx:where field="dc" select="$current/id"/>
+												<dbx:for-each table="core_profile_value_domain" min="1" max="1">
+													<dbx:where field="id" select="$current/cd"/>
+													<dbx:where field="profile" operator="in" select="$profiles//id" when="exists($profiles//id)"/>
+													<dcif:conceptualDomain isocat:id="{$current/id}" type="closed" dcr:datcat="http://www.isocat.org/datcat/DC-4">
+														<dbx:choose>
+															<dbx:when test="($suppress='true') and ($suppress-context-type='profile') and ($current/profile!=$suppress-context)">
+																<dbx:attribute name="isocat:suppress" value="true"/>
+															</dbx:when>
+														</dbx:choose>
+														<dbx:for-each table="core_conceptual_domain" min="1" max="1">
+															<dbx:where field="id" select="$current/id"/>
+															<dbx:for-each table="core_data_type" min="1" max="1">
+																<dbx:where field="id" select="$current/data_type"/>
+																<dcif:dataType isocat:id="{$current/id}" dbx:field="data_type" dcr:datcat="http://www.isocat.org/datcat/DC-2397"/>
+															</dbx:for-each>
+														</dbx:for-each>
+														<dbx:for-each table="core_profile" min="1" max="1">
+															<dbx:where field="id" select="$current/profile"/>
+															<dcif:profile isocat:id="{$current/id}" dbx:field="name" dcr:datcat="http://www.isocat.org/datcat/DC-37"/>
+														</dbx:for-each>
 														<dbx:for-each table="link_value_domain_values" min="1" max="*">
 															<dbx:where field="cd" select="$current/id"/>
@@ -714,25 +657,77 @@
 													</dcif:conceptualDomain>
 												</dbx:for-each>
-											</dcif:linguisticSection>
-										</dbx:for-each>
-									</dbx:when>
-								</dbx:choose>
-								<dbx:choose>
-									<dbx:when test="$current/type='simple'">
-										<dbx:for-each table="link_simple_data_category_super" min="0" max="1">
-											<!-- for now there can only be one super for a simple DC -->
-											<dbx:where field="dc" select="$current/id"/>
-											<dbx:for-each table="core_data_category" min="1" max="1">
-												<dbx:where field="id" select="$current/super"/>
-												<dcif:isA dcr:datcat="http://www.isocat.org/datcat/DC-2409">
-													<dbx:call-template name="data_category-reference"/>
-												</dcif:isA>
-											</dbx:for-each>
-										</dbx:for-each>
-									</dbx:when>
-								</dbx:choose>
-							</dbx:when>
-						</dbx:choose>
-					</dcif:dataCategory>
+											</dbx:for-each>
+										</dbx:when>
+									</dbx:choose>
+									<dbx:choose>
+										<dbx:when test="$current/type='open' or $current/type='constrained'">
+											<dbx:for-each table="core_constrained_linguistic_section" min="0" max="*">
+												<dbx:where field="dc" select="$current/id"/>
+												<dbx:for-each table="core_linguistic_section" min="1" max="1">
+													<dbx:where field="id" select="$current/id"/>
+													<dbx:where field="language" operator="in" select="$object-languages//id" type="integer" when="exists($object-languages//id)"/>
+													<dcif:linguisticSection isocat:id="{$current/id}" type="constrained" dcr:datcat="http://www.isocat.org/datcat/DC-2408">
+														<dbx:call-template name="linguistic_section-core"/>
+														<dbx:for-each table="link_constrained_linguistic_section_conceptual_domains" min="0" max="*">
+															<dbx:where field="ls" select="$current/id"/>
+															<dbx:call-template name="constrained_conceptual_domain"/>
+														</dbx:for-each>
+													</dcif:linguisticSection>
+												</dbx:for-each>
+											</dbx:for-each>
+										</dbx:when>
+										<dbx:when test="$current/type='closed'">
+											<dbx:for-each table="core_closed_linguistic_section" min="0" max="*">
+												<dbx:where field="dc" select="$current/id"/>
+												<dbx:variable name="ol" when="exists($object-languages//id)" query="
+													SELECT
+														language
+													FROM
+														core_linguistic_section
+													WHERE
+														id = {$current/id}
+													;
+												"/>
+												<dbx:variable name="ol" when="empty($object-languages//id)" select="()"/>
+												<dcif:linguisticSection isocat:id="{$current/id}" type="closed" dcr:datcat="http://www.isocat.org/datcat/DC-2408" dbx:when="(empty($object-languages//id)) or (exists($object-languages//id[.=$ol//language]))">
+													<dbx:call-template name="linguistic_section-core"/>
+													<dbx:for-each table="core_value_domain" min="0" max="1">
+														<dbx:where field="id" select="$current/cd" fallback="0"/>
+														<dcif:conceptualDomain type="closed" isocat:id="{$current/id}" dcr:datcat="http://www.isocat.org/datcat/DC-4">
+															<dbx:for-each table="core_conceptual_domain" min="1" max="1">
+																<dbx:where field="id" select="$current/id"/>
+																<dbx:for-each table="core_data_type" min="1" max="1">
+																	<dbx:where field="id" select="$current/data_type"/>
+																	<dcif:dataType isocat:id="{$current/id}" dbx:field="data_type" dcr:datcat="http://www.isocat.org/datcat/DC-2397"/>
+																</dbx:for-each>
+															</dbx:for-each>
+															<dbx:for-each table="link_value_domain_values" min="1" max="*">
+																<dbx:where field="cd" select="$current/id"/>
+																<dbx:call-template name="value"/>
+															</dbx:for-each>
+														</dcif:conceptualDomain>
+													</dbx:for-each>
+												</dcif:linguisticSection>
+											</dbx:for-each>
+										</dbx:when>
+									</dbx:choose>
+									<dbx:choose>
+										<dbx:when test="$current/type='simple'">
+											<dbx:for-each table="link_simple_data_category_super" min="0" max="1">
+												<!-- for now there can only be one super for a simple DC -->
+												<dbx:where field="dc" select="$current/id"/>
+												<dbx:for-each table="core_data_category" min="1" max="1">
+													<dbx:where field="id" select="$current/super"/>
+													<dcif:isA dcr:datcat="http://www.isocat.org/datcat/DC-2409">
+														<dbx:call-template name="data_category-reference"/>
+													</dcif:isA>
+												</dbx:for-each>
+											</dbx:for-each>
+										</dbx:when>
+									</dbx:choose>
+								</dbx:when>
+							</dbx:choose>
+						</dcif:dataCategory>
+					</dbx:cache>
 				</dbx:for-each>
 			</dbx:for-each>
