<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>
	<!-- 
  Property : Belgian Ministry of Health
  Author   : Dr André Vandenberghe, Dominique Tesse, Department of Medical Information, CHU de Charleroi
  Date     : 17/07/2002
  
  Kmehr-Bis
  
  Validation XSLT
 -->

<xsl:variable name="VERBOSE">false</xsl:variable>

 <xsl:template match="/">
	<html>
		<head>
			<title>Kmehr validation report</title>
			<link rel="stylesheet" href="../xsl/Kmehr.css" type="text/css"/>
		</head>
		<body background="../img/Kmehrbg.gif">
			<table width="100%">
				<tr>
					<td valign="bottom">
						<span class="h3">Kmehr validation report of the message <xsl:value-of select="//header/id"/></span>
					</td>
					<td width="1"><img border="0" src="../img/Kmehr.gif" alt="" /></td>
				</tr>
			</table>
			<hr/>
			<br/>
			<xsl:if test="$VERBOSE='false'">
				If the following box is empty, your XML file is a valid Kmehr-Bis message. 
				But please read first the following important <a href="http://www.chu-charleroi.be/kmehr/htm/introductionXSLT.htm#warning" class="fixe" target="_blank">warning</a>.
				<table width="100%" border="2">
					<tr>
						<td>
							<xsl:call-template name="test_file"/>
						</td>
					</tr>
				</table>
				Validation process is now finished.
			</xsl:if>
			<xsl:if test="$VERBOSE='true'">
				<xsl:call-template name="test_file"/>
			</xsl:if>
 		</body>
	</html>
</xsl:template>

 <xsl:template match="kmehrmessage" name="test_file">
	<xsl:variable name="count_kmehrmessage" select="count(//kmehrmessage)"/>
  	<xsl:choose>
      		<xsl:when test="$count_kmehrmessage != '1' ">
			<table width="100%">
	         		<tr class="tr-inverse">
	             			<td valign="top" width="210">XML file</td>
	             			<td valign="top" width="200">Fundamental error</td>
	             			<td>
	             				There must be only one kmehrmessage element in a Kmehr-Bis message. 
	             				<br/>
	      					Your message contains <span class="red"><xsl:value-of select="$count_kmehrmessage"/> kmehrmessage element(s)</span>.
	      				</td>
	         		</tr>
	       	</table>
      		</xsl:when>
      		<xsl:otherwise>
			<xsl:for-each select="//kmehrmessage">
				<xsl:variable name="count_messageconfidentiality" select="count(confidentiality)"/>
			 	<xsl:choose>
		      			<xsl:when test="$count_messageconfidentiality > '1' ">
						<table width="100%">
				         		<tr class="tr-inverse">
			       	      			<td valign="top" width="210">kmehrmessage.confidentiality</td>
			             				<td valign="top" width="200">cardinality error</td>
			             				<td>
			             					You can not have more than one confidentiality element within the kmehrmessage. 
			             					<br/>
				      					Your message contains <span class="red"><xsl:value-of select="$count_messageconfidentiality"/> confidentiality elements</span>.
				      				</td>
				         		</tr>
				       	</table>
			      		</xsl:when>
		      			<xsl:when test="$count_messageconfidentiality = '1' ">
						<xsl:apply-templates select="confidentiality"/>
		      			</xsl:when>
			  	</xsl:choose>
				<xsl:variable name="count_messageheader" select="count(header)"/>
			 	<xsl:choose>
		      			<xsl:when test="$count_messageheader > '1' ">
						<table width="100%">
				         		<tr class="tr-inverse">
			       	      			<td valign="top" width="210">kmehrmessage.header</td>
			             				<td valign="top" width="200">cardinality error</td>
			             				<td>
			             					You can not have more than one header element within the kmehrmessage. 
			             					<br/>
				      					Your message contains <span class="red"><xsl:value-of select="$count_messageheader"/> header elements</span>.
				      				</td>
				         		</tr>
				       	</table>
			      		</xsl:when>
		      			<xsl:when test="$count_messageheader = '0' ">
						<table width="100%">
				         		<tr class="tr-inverse">
			       	      			<td valign="top" width="210">kmehrmessage.header</td>
			             				<td valign="top" width="200">cardinality error</td>
			             				<td>
			             					You must have one header element within the kmehrmessage. 
			             					<br/>
				      					Your message contains <span class="red"><xsl:value-of select="$count_messageheader"/> header element</span>.
				      				</td>
				         		</tr>
				       	</table>
			      		</xsl:when>
		      			<xsl:when test="$count_messageheader = '1' ">
						<xsl:apply-templates select="header"/>
		      			</xsl:when>
			  	</xsl:choose>
				<xsl:variable name="count_messagefolder" select="count(folder)"/>
			 	<xsl:choose>
		      			<xsl:when test="$count_messagefolder =  '0' ">
						<table width="100%">
				         		<tr class="tr-inverse">
			       	      			<td valign="top" width="210">kmehrmessage.folder</td>
			             				<td valign="top" width="200">cardinality error</td>
			             				<td>
			             					You must have at least one folder element within the kmehrmessage. 
			             					<br/>
				      					Your message contains <span class="red"><xsl:value-of select="$count_messagefolder"/> folder element</span>.
				      				</td>
				         		</tr>
				       	</table>
			      		</xsl:when>
		      			<xsl:otherwise>
						<xsl:for-each select="folder">
							<xsl:apply-templates select="."/>
						</xsl:for-each>
		      			</xsl:otherwise>
			  	</xsl:choose>
			  </xsl:for-each>
	      </xsl:otherwise>
  	</xsl:choose>
</xsl:template>



<!-- ************************* HEADER ************************* -->
<xsl:template match="header" name="header">
	<xsl:variable name="count_headerconfidentiality" select="count(confidentiality)"/>
 	<xsl:choose>
		<xsl:when test="$count_headerconfidentiality > '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">header.confidentiality</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You can not have more than one confidentiality element within the header
			             		<br/>
				      		Your header contains <span class="red"><xsl:value-of select="$count_headerconfidentiality"/> confidentiality elements</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headerconfidentiality = '1' ">
			<xsl:for-each select="confidentiality">
				<xsl:call-template name="confidentiality"/>
			</xsl:for-each>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_headerstandard" select="count(standard)"/>
 	<xsl:choose>
		<xsl:when test="$count_headerstandard != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">header.standard</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one standard element within the header
			             		<br/>
				      		Your header contains <span class="red"><xsl:value-of select="$count_headerstandard"/> standard element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headerstandard = '1' ">
			<xsl:apply-templates select="standard"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_headerkmehrid" select="count(id[@S='ID-KMEHR'])"/>
 	<xsl:choose>
		<xsl:when test="$count_headerkmehrid != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">header.id</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one kmehr id within the header
			             		<br/>
				      		Your header contains <span class="red"><xsl:value-of select="$count_headerkmehrid"/> kmehr id element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headerkmehrid = '1' ">
			<xsl:apply-templates select="id"/>
		</xsl:when>
	</xsl:choose>
	<xsl:for-each select="id[@S!='ID-KMEHR']">
		<xsl:apply-templates select="id"/>
	</xsl:for-each>		
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
	<xsl:variable name="count_headerdate" select="count(date)"/>
 	<xsl:choose>
		<xsl:when test="$count_headerdate != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">header.date</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one date element within the header
			             		<br/>
				      		Your header contains <span class="red"><xsl:value-of select="$count_headerdate"/> date element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headerdate = '1' ">
			<xsl:apply-templates select="date"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_headertime" select="count(time)"/>
 	<xsl:choose>
		<xsl:when test="$count_headertime != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">header.time</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one time element within the header
			             		<br/>
				      		Your header contains <span class="red"><xsl:value-of select="$count_headertime"/> time element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headertime = '1' ">
			<xsl:apply-templates select="time"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_headersender" select="count(sender)"/>
 	<xsl:choose>
		<xsl:when test="$count_headersender != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">header.sender</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one sender element within the header
			             		<br/>
				      		Your header contains <span class="red"><xsl:value-of select="$count_headersender"/> sender element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headersender = '1' ">
			<xsl:apply-templates select="sender"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_headerrecipient" select="count(recipient)"/>
	<xsl:choose>
		<xsl:when test="$count_headerrecipient =  '0' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">header.recipient</td>
             				<td valign="top" width="200">cardinality error</td>
             				<td>
            					You must have at least one recipient element within the header
			             		<br/>
				      		Your message contains <span class="red"><xsl:value-of select="$count_headerrecipient"/> recipient element</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:otherwise>
			<xsl:for-each select="recipient">
				<xsl:apply-templates select="."/>
			</xsl:for-each>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:variable name="count_headerurgency" select="count(urgency)"/>
 	<xsl:choose>
		<xsl:when test="$count_headerurgency > '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">header.urgency</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You can not have more than one urgency element within the header
			             		<br/>
				      		Your header contains <span class="red"><xsl:value-of select="$count_headerurgency"/> urgency elements</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headerurgency = '1' ">
			<xsl:apply-templates select="urgency"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_headeracknowledgment" select="count(acknowledgment)"/>
 	<xsl:choose>
		<xsl:when test="$count_headeracknowledgment > '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">header.acknowledgment</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You can not have more than one acknowledgment element within the header
			             		<br/>
				      		Your header contains <span class="red"><xsl:value-of select="$count_headeracknowledgment"/> acknowledgment elements</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headeracknowledgment = '1' ">
			<xsl:apply-templates select="acknowledgment"/>
		</xsl:when>
	</xsl:choose>
	<xsl:for-each select="text">
		<xsl:apply-templates select="."/>
	</xsl:for-each>
	<xsl:for-each select="lnk">
		<xsl:apply-templates select="."/>
	</xsl:for-each>
</xsl:template>

<xsl:template match="standard" name="standard">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_standardkmehrcd" select="count(cd[@S='CD-STANDARD'])"/>
 	<xsl:choose>
		<xsl:when test="$count_standardkmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">standard.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official standard cd within the standard.
			             		<br/>
				      		Your standard contains <span class="red"><xsl:value-of select="$count_standardkmehrcd"/> official standard cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_standardkmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="acknowledgment" name="acknowledgment">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_acknowledgmentkmehrcd" select="count(cd[@S='CD-ACKNOWLEDGMENT'])"/>
 	<xsl:choose>
		<xsl:when test="$count_acknowledgmentkmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">acknowledgment.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official acknowledgment cd within the acknowledgment.
			             		<br/>
				      		Your acknowledgment contains <span class="red"><xsl:value-of select="$count_acknowledgmentkmehrcd"/> official acknowledgment cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_acknowledgmentkmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>
<!-- *********************** HEADER ************************* -->


<!-- *********************** FOLDER ************************* -->
<xsl:template match="folder" name="folder">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_folderconfidentiality" select="count(confidentiality)"/>
 	<xsl:choose>
		<xsl:when test="$count_folderconfidentiality > '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">folder.confidentiality</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You can not have more than one confidentiality element within the folder
			             		<br/>
				      		Your folder contains <span class="red"><xsl:value-of select="$count_folderconfidentiality"/> confidentiality elements</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_folderconfidentiality = '1' ">
			<xsl:apply-templates select="confidentiality"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_folderkmehrid" select="count(id[@S='ID-KMEHR'])"/>
 	<xsl:choose>
		<xsl:when test="$count_folderkmehrid != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">folder.id</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one kmehr id within the folder
			             		<br/>
				      		Your folder contains <span class="red"><xsl:value-of select="$count_folderkmehrid"/> kmehr id element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_folderkmehrid = '1' ">
			<xsl:apply-templates select="id"/>
		</xsl:when>
	</xsl:choose>
	<xsl:for-each select="id[@S!='ID-KMEHR']">
		<xsl:apply-templates select="id"/>
	</xsl:for-each>		
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
	<xsl:variable name="count_folderpatient" select="count(patient)"/>
 	<xsl:choose>
		<xsl:when test="$count_folderpatient != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">folder.patient</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one patient element within the folder
			             		<br/>
				      		Your folder contains <span class="red"><xsl:value-of select="$count_folderpatient"/> patient element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_folderpatient = '1' ">
			<xsl:for-each select="patient">
				<xsl:call-template name="patient"/>
			</xsl:for-each>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_foldertransaction" select="count(transaction)"/>
	<xsl:choose>
		<xsl:when test="$count_foldertransaction =  '0' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">folder.transaction</td>
             				<td valign="top" width="200">cardinality error</td>
             				<td>
            					You must have at least one transaction element within the folder
			             		<br/>
				      		Your message contains <span class="red"><xsl:value-of select="$count_foldertransaction"/> transaction element</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:otherwise>
			<xsl:for-each select="transaction">
				<xsl:apply-templates select="."/>
			</xsl:for-each>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:for-each select="text">
		<xsl:apply-templates select="."/>
	</xsl:for-each>
	<xsl:for-each select="lnk">
		<xsl:apply-templates select="."/>
	</xsl:for-each>
</xsl:template>
<!-- *********************** FOLDER ************************* -->


<!-- *********************** HCPARTY ************************* -->
<xsl:template match="confidentiality" name="confidentiality">
	<xsl:variable name="count_confidentialityhcparty" select="count(hcparty)"/>
	<xsl:choose>
		<xsl:when test="$count_confidentialityhcparty =  '0' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">confidentiality.hcparty</td>
             				<td valign="top" width="200">cardinality error</td>
             				<td>
            					You must have at least one hcparty element within the confidentiality
			             		<br/>
				      		Your message contains <span class="red"><xsl:value-of select="$count_confidentialityhcparty"/> hcparty element</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:otherwise>
			<xsl:if test="$VERBOSE='true'">
				<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
			</xsl:if>
			<xsl:for-each select="hcparty">
				<xsl:call-template name="hcparty"/>
				<xsl:if test="$VERBOSE='true'">
					<br/>
				</xsl:if>
			</xsl:for-each>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="sender">
	<xsl:variable name="count_senderhcparty" select="count(hcparty)"/>
	<xsl:choose>
		<xsl:when test="$count_senderhcparty =  '0' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">sender.hcparty</td>
             				<td valign="top" width="200">cardinality error</td>
             				<td>
            					You must have at least one hcparty element within the sender
			             		<br/>
				      		Your message contains <span class="red"><xsl:value-of select="$count_senderhcparty"/> hcparty element</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:otherwise>
			<xsl:if test="$VERBOSE='true'">
				<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
			</xsl:if>
			<xsl:for-each select="hcparty">
				<xsl:call-template name="hcparty"/>
				<xsl:if test="$VERBOSE='true'">
					<br/>
				</xsl:if>
			</xsl:for-each>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="recipient">
	<xsl:variable name="count_recipienthcparty" select="count(hcparty)"/>
	<xsl:choose>
		<xsl:when test="$count_recipienthcparty =  '0' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">recipient.hcparty</td>
             				<td valign="top" width="200">cardinality error</td>
             				<td>
            					You must have at least one hcparty element within the recipient
			             		<br/>
				      		Your message contains <span class="red"><xsl:value-of select="$count_recipienthcparty"/> hcparty element</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:otherwise>
			<xsl:if test="$VERBOSE='true'">
				<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
			</xsl:if>
			<xsl:for-each select="hcparty">
				<xsl:call-template name="hcparty"/>
				<xsl:if test="$VERBOSE='true'">
					<br/>
				</xsl:if>
			</xsl:for-each>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="hcparty" name="hcparty">
	<xsl:variable name="hcpartycd" select="cd[@S='CD-HCPARTY']"/>
	<xsl:variable name="count_hcpartycd" select="count(cd[@S='CD-HCPARTY'])"/>
 	<xsl:choose>
		<xsl:when test="$count_hcpartycd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">hcparty.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official hcparty code within the hcparty
			             		<br/>
				      		Your hcparty contains <span class="red"><xsl:value-of select="$count_hcpartycd"/> official cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		--------------------
	</xsl:if>
	<xsl:for-each select="cd">
		<xsl:call-template name="cd"/>
	</xsl:for-each>		
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
	<xsl:variable name="count_hcpartyid" select="count(id[@S='ID-HCPARTY'])"/>
 	<xsl:choose>
		<xsl:when test="$count_hcpartyid &gt; '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">hcparty.id</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official hcparty id within the hcparty
			             		<br/>
				      		Your hcparty contains <span class="red"><xsl:value-of select="$count_hcpartyid"/> official id element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_hcpartyid = '0' ">
			<xsl:choose>
				<xsl:when test="contains($hcpartycd, 'dept')">
				</xsl:when>
				<xsl:otherwise>
					<table width="100%">
			        		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">hcparty.id</td>
			      				<td valign="top" width="200">cardinality error</td>
					             	<td>
					             		You must have one hcparty id within the hcparty
					             		<br/>
						      		Your hcparty contains <span class="red"><xsl:value-of select="$count_hcpartyid"/> official id element</span>.
						      	</td>
						      	<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>
	</xsl:choose>
	<xsl:for-each select="id">
		<xsl:if test="$VERBOSE='true'">
			--------------------
		</xsl:if>
		<xsl:call-template name="id"/>
	</xsl:for-each>
	<xsl:if test="$VERBOSE='true'">
		<xsl:if test="$count_hcpartyid &gt; '0' ">
			<br/>
		</xsl:if>
	</xsl:if>
	<xsl:variable name="count_hcpartyname" select="count(name)"/>
 	<xsl:choose>
		<xsl:when test="$count_hcpartyname = '1' ">
			<xsl:variable name="count_hcpartyfirstname" select="count(firstname)"/>
		 	<xsl:if test="$count_hcpartyfirstname != '0' ">
				<table width="100%">
			       	<tr class="tr-inverse">
			      			<td valign="top" width="210">hcparty.firstname</td>
			      			<td valign="top" width="200">cardinality error</td>
				             	<td>You can not combine a name with a firstname.</td>
						 <td class="auteur"><xsl:value-of select="."/></td>
					</tr>
				</table>
			</xsl:if>
			<xsl:variable name="count_hcpartyfamilyname" select="count(familyname)"/>
		 	<xsl:if test="$count_hcpartyfamilyname != '0' ">
				<table width="100%">
			       	<tr class="tr-inverse">
			      			<td valign="top" width="210">hcparty.familyname</td>
			      			<td valign="top" width="200">cardinality error</td>
				             	<td>You can not combine a name with a familyname.</td>
						 <td class="auteur"><xsl:value-of select="."/></td>
					</tr>
				</table>
			</xsl:if>
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="name"/>
		</xsl:when>
		<xsl:when test="$count_hcpartyname &gt; '1' ">
			<table width="100%">
		       	<tr class="tr-inverse">
		      			<td valign="top" width="210">hcparty.name</td>
		      			<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You can not have multiple name within the hcparty
			             		<br/>
				      		Your hcparty contains <span class="red"><xsl:value-of select="$count_hcpartyname"/> name elements</span>.
				      	</td>
					 <td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:otherwise>
			<xsl:variable name="count_hcpartyfirstname" select="count(firstname)"/>
		 	<xsl:choose>
				<xsl:when test="$count_hcpartyfirstname &gt; '1' ">
					<table width="100%">
			        		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">hcparty.firstname</td>
			      				<td valign="top" width="200">cardinality error</td>
					             	<td>
					             		You must have maximum one firstname element within the hcparty
					             		<br/>
						      		Your hcparty contains <span class="red"><xsl:value-of select="$count_hcpartyfirstname"/> firstname element(s)</span>.
						      	</td>
						      	<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
				</xsl:when>
				<xsl:when test="$count_hcpartyfirstname = '1' ">
					<xsl:if test="$VERBOSE='true'">
						--------------------
					</xsl:if>
					<xsl:apply-templates select="firstname"/>
				</xsl:when>
			</xsl:choose>
			<xsl:variable name="count_hcpartyfamilyname" select="count(familyname)"/>
		 	<xsl:choose>
				<xsl:when test="$count_hcpartyfamilyname &gt; '1' ">
					<table width="100%">
			        		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">hcparty.familyname</td>
			      				<td valign="top" width="200">cardinality error</td>
					             	<td>
					             		You must have maximum one familyname element within the hcparty
					             		<br/>
						      		Your hcparty contains <span class="red"><xsl:value-of select="$count_hcpartyfamilyname"/> familyname element(s)</span>.
						      	</td>
						      	<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
				</xsl:when>
				<xsl:when test="$count_hcpartyfamilyname = '1' ">
					<xsl:if test="$VERBOSE='true'">
						--------------------
					</xsl:if>
					<xsl:apply-templates select="familyname"/>
				</xsl:when>
			</xsl:choose>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:for-each select="address">
		<xsl:if test="$VERBOSE='true'">
			--------------------
		</xsl:if>
		<xsl:apply-templates select="."/>
	</xsl:for-each>
	<xsl:for-each select="telecom">
		<xsl:if test="$VERBOSE='true'">
			--------------------
		</xsl:if>
		<xsl:apply-templates select="."/>
	</xsl:for-each>
</xsl:template>
<!-- *********************** HCPARTY ************************* -->


<!-- *********************** PERSON ************************* -->
<xsl:template match="patient" name="patient">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>----------
	</xsl:if>
	<xsl:variable name="count_personkmehrid" select="count(id[@S='ID-PATIENT'])"/>
 	<xsl:choose>
		<xsl:when test="$count_personkmehrid != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">person.id</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official person id within the person
			             		<br/>
				      		Your person contains <span class="red"><xsl:value-of select="$count_personkmehrid"/> official person id element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_personkmehrid = '1' ">
			<xsl:apply-templates select="id[@S='ID-PATIENT']"/>
		</xsl:when>
	</xsl:choose>
	<xsl:for-each select="id[@S!='ID-PATIENT']">
		<xsl:apply-templates select="."/>
	</xsl:for-each>		
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
	<xsl:call-template name="persons"/>
</xsl:template>

<xsl:template match="person" name="person">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>----------
	</xsl:if>
	<xsl:call-template name="persons"/>
</xsl:template>

<xsl:template match="person" name="persons">
	<xsl:variable name="count_personfirstname" select="count(firstname)"/>
 	<xsl:choose>
		<xsl:when test="$count_personfirstname != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">person.firstname</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one firstname element within the person
			             		<br/>
				      		Your person contains <span class="red"><xsl:value-of select="$count_personfirstname"/> firstname element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_personfirstname = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="firstname"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_personfamilyname" select="count(familyname)"/>
 	<xsl:choose>
		<xsl:when test="$count_personfamilyname != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">person.familyname</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one familyname element within the person
			             		<br/>
				      		Your person contains <span class="red"><xsl:value-of select="$count_personfamilyname"/> familyname element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_personfamilyname = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="familyname"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_personbirthdate" select="count(birthdate)"/>
 	<xsl:choose>
		<xsl:when test="$count_personbirthdate > '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">header.birthdate</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You can not have more than one birthdate element within the person
			             		<br/>
				      		Your person contains <span class="red"><xsl:value-of select="$count_personbirthdate"/> birthdate elements</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_personbirthdate = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="birthdate"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_personsex" select="count(sex)"/>
 	<xsl:choose>
		<xsl:when test="$count_personsex != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">person.sex</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one sex element within the person
			             		<br/>
				      		Your person contains <span class="red"><xsl:value-of select="$count_personsex"/> sex element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_personsex = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="sex"/>
		</xsl:when>
	</xsl:choose>
	<xsl:for-each select="address">
		<xsl:if test="$VERBOSE='true'">
			----------
		</xsl:if>
		<xsl:apply-templates select="."/>
	</xsl:for-each>
	<xsl:for-each select="telecom">
		<xsl:if test="$VERBOSE='true'">
			----------
		</xsl:if>
		<xsl:apply-templates select="."/>
	</xsl:for-each>
</xsl:template>

<xsl:template match="firstname" name="firstname">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="familyname" name="familyname">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="name" name="name">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="sex" name="sex">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="birthdate" name="birthdate">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
	</xsl:if>
	<xsl:variable name="count_birthdatedate" select="count(date)"/>
 	<xsl:choose>
		<xsl:when test="$count_birthdatedate != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">birthdate.date</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one date element within the birthdate
			             		<br/>
				      		Your birthdate contains <span class="red"><xsl:value-of select="$count_birthdatedate"/> date element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_birthdatedate = '1' ">
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="date"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_birthdatetime" select="count(time)"/>
 	<xsl:choose>
		<xsl:when test="$count_birthdatetime &gt; '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">birthdate.time</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have maximum one time element within the birthdate
			             		<br/>
				      		Your birthdate contains <span class="red"><xsl:value-of select="$count_birthdatetime"/> time element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_birthdatetime = '1' ">
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="time"/>
		</xsl:when>
	</xsl:choose>
</xsl:template>
<!-- *********************** PERSON ************************* -->


<!-- *********************** COORDINATES ********************** -->
<xsl:template match="address" name="address">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
	</xsl:if>
	<xsl:variable name="count_addresskmehrcd" select="count(cd[@S='CD-ADDRESS'])"/>
 	<xsl:choose>
		<xsl:when test="$count_addresskmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">address.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official address cd within the address
			             		<br/>
				      		Your address contains <span class="red"><xsl:value-of select="$count_addresskmehrcd"/> official address cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_addresskmehrcd = '1' ">
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="cd"/>
			<xsl:if test="$VERBOSE='true'">
				<br/>
			</xsl:if>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		--------------------
	</xsl:if>
	<xsl:apply-templates select="country"/>
	<xsl:if test="$VERBOSE='true'">
		<br/>
		--------------------
	</xsl:if>
	<xsl:apply-templates select="zip"/>
	<xsl:if test="$VERBOSE='true'">
		--------------------
	</xsl:if>
	<xsl:apply-templates select="city"/>
	<xsl:if test="$VERBOSE='true'">
		--------------------
	</xsl:if>
	<xsl:apply-templates select="street"/>
	<xsl:if test="$VERBOSE='true'">
		--------------------
	</xsl:if>
	<xsl:apply-templates select="housenumber"/>
	<xsl:for-each select="text">
		<xsl:if test="$VERBOSE='true'">
			--------------------
		</xsl:if>
		<xsl:apply-templates select="."/>
	</xsl:for-each>
</xsl:template>

<xsl:template match="country" name="country">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_countrykmehrcd" select="count(cd[@S='CD-COUNTRY'])"/>
 	<xsl:choose>
		<xsl:when test="$count_countrykmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">country.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official country cd within the country element.
			             		<br/>
				      		Your country contains <span class="red"><xsl:value-of select="$count_countrykmehrcd"/> official country cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_countrykmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="zip" name="zip">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="city" name="city">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="street" name="street">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="housenumber" name="housenumber">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="telecom" name="telecom">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
	</xsl:if>
	<xsl:variable name="count_telecomaddresskmehrcd" select="count(cd[@S='CD-ADDRESS'])"/>
 	<xsl:choose>
		<xsl:when test="$count_telecomaddresskmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">telecom.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official address cd within the telecom
			             		<br/>
				      		Your telecom contains <span class="red"><xsl:value-of select="$count_telecomaddresskmehrcd"/> official address cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_telecomaddresskmehrcd = '1' ">
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="cd[@S='CD-ADDRESS']"/>
			<xsl:if test="$VERBOSE='true'">
				<br/>
			</xsl:if>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_telecomkmehrcd" select="count(cd[@S='CD-TELECOM'])"/>
 	<xsl:choose>
		<xsl:when test="$count_telecomkmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">telecom.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official telecom cd within the telecom
			             		<br/>
				      		Your telecom contains <span class="red"><xsl:value-of select="$count_telecomkmehrcd"/> official telecom cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_telecomkmehrcd = '1' ">
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="cd[@S='CD-TELECOM']"/>
			<xsl:if test="$VERBOSE='true'">
				<br/>
			</xsl:if>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_telecomnumber" select="count(telecomnumber)"/>
 	<xsl:choose>
		<xsl:when test="$count_telecomnumber != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">telecom.telecomnumber</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one telecomnumber within the telecom
			             		<br/>
				      		Your telecom contains <span class="red"><xsl:value-of select="$count_telecomnumber"/> telecomnumber element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_telecomnumber = '1' ">
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="telecomnumber"/>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="telecomnumber" name="telecomnumber">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>
<!-- *********************** COORDINATES ********************** -->


<!-- *********************** INSURANCE ********************** -->
<xsl:template match="insurance" name="insurance">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
	</xsl:if>
	<xsl:variable name="count_insuranceid" select="count( id[@S='ID-INSURANCE'] )"/>
 	<xsl:choose>
		<xsl:when test="$count_insuranceid != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">insurance.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one id within the insurance
			             		<br/>
				      		Your insurance contains <span class="red"><xsl:value-of select="$count_insuranceid"/> id element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_insuranceid = '1' ">
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="id"/>
			<xsl:if test="$VERBOSE='true'">
				<br/>
			</xsl:if>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_insurancemembership" select="count(membership)"/>
 	<xsl:choose>
		<xsl:when test="$count_insurancemembership != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">insurance.membership</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one membership within the insurance
			             		<br/>
				      		Your insurance contains <span class="red"><xsl:value-of select="$count_insurancemembership"/> membership element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_insurancemembership = '1' ">
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="membership"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_insurancebegindate" select="count(begindate)"/>
 	<xsl:choose>
		<xsl:when test="$count_insurancebegindate != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">insurance.begindate</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one begindate within the insurance
			             		<br/>
				      		Your insurance contains <span class="red"><xsl:value-of select="$count_insurancebegindate"/> begindate element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_insurancebegindate = '1' ">
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="begindate"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_insuranceenddate" select="count(enddate)"/>
 	<xsl:choose>
		<xsl:when test="$count_insuranceenddate != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">insurance.enddate</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one enddate within the insurance
			             		<br/>
				      		Your insurance contains <span class="red"><xsl:value-of select="$count_insuranceenddate"/> enddate element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_insuranceenddate = '1' ">
			<xsl:if test="$VERBOSE='true'">
				--------------------
			</xsl:if>
			<xsl:apply-templates select="enddate"/>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="membership" name="membership">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="begindate" name="begindate">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="enddate" name="enddate">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>
<!-- *********************** INSURANCE ********************** -->


<!-- ************************* TRANSACTION ************************* -->
<xsl:template match="transaction" name="transaction">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
	</xsl:if>
	<xsl:variable name="count_transactionconfidentiality" select="count(confidentiality)"/>
 	<xsl:choose>
		<xsl:when test="$count_transactionconfidentiality > '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">transaction.confidentiality</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You can not have more than one confidentiality element within the transaction
			             		<br/>
				      		Your transaction contains <span class="red"><xsl:value-of select="$count_transactionconfidentiality"/> confidentiality elements</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_transactionconfidentiality = '1' ">
				<xsl:for-each select="confidentiality">
				<xsl:if test="$VERBOSE='true'">
					--------------------
				</xsl:if>
				<xsl:call-template name="confidentiality"/>
			</xsl:for-each>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_transactionkmehrid" select="count(id[@S='ID-KMEHR'])"/>
 	<xsl:choose>
		<xsl:when test="$count_transactionkmehrid != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">transaction.id</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one kmehr id within the transaction
			             		<br/>
				      		Your transaction contains <span class="red"><xsl:value-of select="$count_transactionkmehrid"/> kmehr id element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_transactionkmehrid = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="id"/>
		</xsl:when>
	</xsl:choose>
	<xsl:for-each select="id[@S!='ID-KMEHR']">
		<xsl:apply-templates select="id"/>
	</xsl:for-each>		
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
	<xsl:variable name="count_transactionkmehrcd" select="count(cd[@S='CD-TRANSACTION']  |  cd[@S='CD-TRANSACTION-CARENET']  |  cd[@S='LOCAL'])"/>
 	<xsl:choose>
		<xsl:when test="$count_transactionkmehrcd &lt; '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">transaction.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have at least one official kmehr cd within the transaction
			             		<br/>
				      		Your transaction contains <span class="red"><xsl:value-of select="$count_transactionkmehrcd"/> kmehr cd element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		----------
	</xsl:if>
	<xsl:for-each select="cd">
		<xsl:apply-templates select="."/>
	</xsl:for-each>		
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
	<xsl:variable name="count_transactiondate" select="count(date)"/>
 	<xsl:choose>
		<xsl:when test="$count_transactiondate != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">transaction.date</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one date element within the transaction
			             		<br/>
				      		Your transaction contains <span class="red"><xsl:value-of select="$count_transactiondate"/> date element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_transactiondate = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="date"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_transactiontime" select="count(time)"/>
 	<xsl:choose>
		<xsl:when test="$count_transactiontime != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">transaction.time</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one time element within the transaction
			             		<br/>
				      		Your transaction contains <span class="red"><xsl:value-of select="$count_transactiontime"/> time element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_transactiontime = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="time"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_transactionauthor" select="count(author)"/>
 	<xsl:choose>
		<xsl:when test="$count_transactionauthor != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">transaction.author</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one author element within the transaction
			             		<br/>
				      		Your transaction contains <span class="red"><xsl:value-of select="$count_transactionauthor"/> author element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_transactionauthor = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="author"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_transactioniscomplete" select="count(iscomplete)"/>
 	<xsl:choose>
		<xsl:when test="$count_transactioniscomplete != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">transaction.iscomplete</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one iscomplete element within the transaction
			             		<br/>
				      		Your transaction contains <span class="red"><xsl:value-of select="$count_transactioniscomplete"/> iscomplete element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_transactioniscomplete = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="iscomplete"/>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_transactionisvalidated" select="count(isvalidated)"/>
 	<xsl:choose>
		<xsl:when test="$count_transactionisvalidated != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">transaction.isvalidated</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one isvalidated element within the transaction
			             		<br/>
				      		Your transaction contains <span class="red"><xsl:value-of select="$count_transactionisvalidated"/> isvalidated element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_transactionisvalidated = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="isvalidated"/>
			<xsl:if test="$VERBOSE='true'">
				<br/>
			</xsl:if>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_transactioncontent" select="count(heading|item|text|lnk)"/>
 	<xsl:choose>
		<xsl:when test="$count_transactioncontent = '0' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">transaction.content</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
				      		Your transaction is <span class="red">empty</span>. It should at least contain one heading, one item, one text or one lnk.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_transactioncontent &gt; '0' ">
			<xsl:for-each select="heading|item|text|lnk">
				<xsl:if test="$VERBOSE='true'">
					----------
				</xsl:if>
				<xsl:apply-templates select="."/>
			</xsl:for-each>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="iscomplete" name="iscomplete">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:call-template name="boolean"/></span>
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="isvalidated" name="isvalidated">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:call-template name="boolean"/></span>
	</xsl:if>
</xsl:template>

<xsl:template match="author" name="author">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
	</xsl:if>
	<xsl:variable name="count_authorhcparty" select="count(hcparty[contains(cd,'pers')])"/>
	<xsl:choose>
		<xsl:when test="$count_authorhcparty =  '0' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">author.hcparty</td>
             				<td valign="top" width="200">cardinality error</td>
             				<td>
            					You must have at least one hcparty element of the type person within the author
			             		<br/>
				      		Your message contains <span class="red"><xsl:value-of select="$count_authorhcparty"/> physical person hcparty element</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:otherwise>
			<xsl:for-each select="hcparty">
				<xsl:call-template name="hcparty"/>
				<xsl:if test="$VERBOSE='true'">
					<br/>
				</xsl:if>
			</xsl:for-each>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<!-- ************************* TRANSACTION ************************* -->


<!-- ************************* HEADING ************************* -->
<xsl:template match="heading" name="heading">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
	</xsl:if>
	<xsl:variable name="count_headingconfidentiality" select="count(confidentiality)"/>
 	<xsl:choose>
		<xsl:when test="$count_headingconfidentiality > '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">heading.confidentiality</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You can not have more than one confidentiality element within the heading
			             		<br/>
				      		Your heading contains <span class="red"><xsl:value-of select="$count_headingconfidentiality"/> confidentiality elements</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headingconfidentiality = '1' ">
				<xsl:for-each select="confidentiality">
				<xsl:if test="$VERBOSE='true'">
					--------------------
				</xsl:if>
				<xsl:call-template name="confidentiality"/>
			</xsl:for-each>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_headingkmehrid" select="count(id[@S='ID-KMEHR'])"/>
 	<xsl:choose>
		<xsl:when test="$count_headingkmehrid != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">heading.id</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one kmehr id within the heading
			             		<br/>
				      		Your heading contains <span class="red"><xsl:value-of select="$count_headingkmehrid"/> kmehr id element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headingkmehrid = '1' ">
			<xsl:if test="$VERBOSE='true'">
				----------
			</xsl:if>
			<xsl:apply-templates select="id"/>
		</xsl:when>
	</xsl:choose>
	<xsl:for-each select="id[@S!='ID-KMEHR']">
		<xsl:apply-templates select="id"/>
	</xsl:for-each>		
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
	<xsl:variable name="count_headingkmehrcd" select="count(cd[@S='CD-HEADING']  |  cd[@S='CD-HEADING-LAB']  |  cd[@S='CD-SITE']   |  cd[@S='LOCAL'])"/>
 	<xsl:choose>
		<xsl:when test="$count_headingkmehrcd &lt; '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">heading.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have at least one official kmehr cd within the heading
			             		<br/>
				      		Your heading contains <span class="red"><xsl:value-of select="$count_headingkmehrcd"/> kmehr cd element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		----------
	</xsl:if>
	<xsl:for-each select="cd">
		<xsl:apply-templates select="."/>
	</xsl:for-each>		
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
	<xsl:variable name="count_headingcontent" select="count(heading|item|text|lnk)"/>
 	<xsl:choose>
		<xsl:when test="$count_headingcontent = '0' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">heading.content</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
				      		Your heading is <span class="red">empty</span>. It should at least contain one heading, one item, one text or one lnk.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_headingcontent &gt; '0' ">
			<xsl:for-each select="heading|item|text|lnk">
				<xsl:if test="$VERBOSE='true'">
					----------
				</xsl:if>
				<xsl:apply-templates select="."/>
			</xsl:for-each>
		</xsl:when>
	</xsl:choose>
</xsl:template>
<!-- ************************* HEADING ************************* -->


<!-- ************************* ITEM ************************* -->
<xsl:template match="item" name="item">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span><br/>
	</xsl:if>
	<xsl:variable name="count_itemconfidentiality" select="count(confidentiality)"/>
 	<xsl:choose>
		<xsl:when test="$count_itemconfidentiality > '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">item.confidentiality</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You can not have more than one confidentiality element within the item
			             		<br/>
				      		Your item contains <span class="red"><xsl:value-of select="$count_itemconfidentiality"/> confidentiality elements</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_itemconfidentiality = '1' ">
				<xsl:for-each select="confidentiality">
				<xsl:if test="$VERBOSE='true'">
					--------------------
				</xsl:if>
				<xsl:call-template name="confidentiality"/>
			</xsl:for-each>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_itemkmehrid" select="count(id[@S='ID-KMEHR'])"/>
 	<xsl:choose>
		<xsl:when test="$count_itemkmehrid != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">item.id</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one kmehr id within the item
			             		<br/>
				      		Your item contains <span class="red"><xsl:value-of select="$count_itemkmehrid"/> kmehr id element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_itemkmehrid = '1' ">
			<xsl:if test="$VERBOSE='true'">
				------------------------------
			</xsl:if>
			<xsl:apply-templates select="id"/>
		</xsl:when>
	</xsl:choose>
	<xsl:for-each select="id[@S!='ID-KMEHR']">
		<xsl:apply-templates select="id"/>
	</xsl:for-each>		
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
	<xsl:variable name="count_itemkmehrcd" select="count(cd[@S='CD-ITEM']  |  cd[@S='CD-ITEM-CARENET']  |  cd[@S='CD-LAB']   |  cd[@S='CD-TECHNICAL']|  cd[@S='CD-CONTACT-PERSON']  |  cd[@S='ICD']    |cd[@S='ICPC']    |  cd[@S='LOCAL'])"/>
 	<xsl:choose>
		<xsl:when test="$count_itemkmehrcd &lt; '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">item.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have at least one official kmehr cd within the item
			             		<br/>
				      		Your item contains <span class="red"><xsl:value-of select="$count_itemkmehrcd"/> kmehr cd element(s)</span>.
				      	</td>
				</tr>
			</table>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		------------------------------
	</xsl:if>
	<xsl:for-each select="cd">
		<xsl:apply-templates select="."/>
	</xsl:for-each>		
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
	<xsl:for-each select="content|author|beginmoment|endmoment|iscomplete|isvalidated|lifecycle|severity|certainty|temporality|urgency|quantity|frequency|site|cost|dayperiod|duration">
		<xsl:if test="$VERBOSE='true'">
			------------------------------
		</xsl:if>
		<xsl:apply-templates select="."/>
	</xsl:for-each>
</xsl:template>
<!-- ************************* ITEM ************************* -->


<!-- *********************** MEDICAL ATTRIBUTES ************************* -->
<xsl:template match="urgency" name="urgency">
	<xsl:if test="$VERBOSE='true'">
		------------------------------<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_urgencykmehrcd" select="count(cd[@S='CD-URGENCY'])"/>
 	<xsl:choose>
		<xsl:when test="$count_urgencykmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">urgency.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official urgency cd within the urgency.
			             		<br/>
				      		Your urgency contains <span class="red"><xsl:value-of select="$count_urgencykmehrcd"/> official urgency cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_urgencykmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="unit" name="unit">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_unitkmehrcd" select="count(cd[@S='CD-UNIT'])"/>
 	<xsl:choose>
		<xsl:when test="$count_unitkmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">unit.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official unit cd within the unit.
			             		<br/>
				      		Your unit contains <span class="red"><xsl:value-of select="$count_unitkmehrcd"/> official unit cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_unitkmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="beginmoment" name="beginmoment">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:apply-templates select="date"/>
	<xsl:apply-templates select="time"/>
	<xsl:apply-templates select="text"/>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="beginmoment" name="endmoment">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:apply-templates select="date"/>
	<xsl:apply-templates select="time"/>
	<xsl:apply-templates select="text"/>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="site" name="site">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:apply-templates select="cd"/>
	<xsl:apply-templates select="text"/>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="quantity" name="quantity">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:apply-templates select="decimal"/>
	<xsl:apply-templates select="unit"/>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="frequency" name="frequency">
	<xsl:call-template name="quantity"/>
</xsl:template>

<xsl:template match="duration" name="duration">
	<xsl:call-template name="quantity"/>
</xsl:template>

<xsl:template match="cost" name="cost">
	<xsl:call-template name="quantity"/>
</xsl:template>

<xsl:template match="dayperiod" name="dayperiod">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_dayperiodkmehrcd" select="count(cd[@S='CD-DAYPERIOD'])"/>
 	<xsl:choose>
		<xsl:when test="$count_dayperiodkmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">dayperiod.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official dayperiod cd within the dayperiod.
			             		<br/>
				      		Your dayperiod contains <span class="red"><xsl:value-of select="$count_dayperiodkmehrcd"/> official dayperiod cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_dayperiodkmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="lifecycle" name="lifecycle">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_lifecyclekmehrcd" select="count(cd[@S='CD-LIFECYCLE'])"/>
 	<xsl:choose>
		<xsl:when test="$count_lifecyclekmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">lifecycle.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official lifecycle cd within the lifecycle.
			             		<br/>
				      		Your lifecycle contains <span class="red"><xsl:value-of select="$count_lifecyclekmehrcd"/> official lifecycle cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_lifecyclekmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="severity" name="severity">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_severitykmehrcd" select="count(cd[@S='CD-SEVERITY'])"/>
 	<xsl:choose>
		<xsl:when test="$count_severitykmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">severity.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official severity cd within the severity.
			             		<br/>
				      		Your severity contains <span class="red"><xsl:value-of select="$count_severitykmehrcd"/> official severity cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_severitykmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="certainty" name="certainty">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_certaintykmehrcd" select="count(cd[@S='CD-CERTAINTY'])"/>
 	<xsl:choose>
		<xsl:when test="$count_certaintykmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">certainty.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official certainty cd within the certainty.
			             		<br/>
				      		Your certainty contains <span class="red"><xsl:value-of select="$count_certaintykmehrcd"/> official certainty cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_certaintykmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="temporality" name="temporality">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_temporalitykmehrcd" select="count(cd[@S='CD-TEMPORALITY'])"/>
 	<xsl:choose>
		<xsl:when test="$count_temporalitykmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">temporality.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official temporality cd within the temporality.
			             		<br/>
				      		Your temporality contains <span class="red"><xsl:value-of select="$count_temporalitykmehrcd"/> official temporality cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_temporalitykmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$VERBOSE='true'">
		<br/>
	</xsl:if>
</xsl:template>
<!-- *********************** MEDICAL ATTRIBUTES ************************* -->


<!-- *********************** BASICS ************************* -->
<xsl:template match="date" name="date">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="time" name="time">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="text" name="text">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> (<xsl:value-of select="@L"/>) = <xsl:value-of select="."/></span><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="decimal" name="decimal">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="."/></span>
	</xsl:if>
</xsl:template>

<xsl:template match="boolean" name="boolean">
 	<xsl:choose>
		<xsl:when test=".='true' ">
			<xsl:value-of select="."/>
		</xsl:when>
		<xsl:when test=".='false' ">
			<xsl:value-of select="."/>
		</xsl:when>
		<xsl:otherwise>
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">boolean</td>
	      				<td valign="top" width="200">value error</td>
			             	<td>
			             		A boolean must have the value <b>true</b> or <b>false</b>.
			             		<br/>
				      		Your boolean contains <span class="red"><xsl:value-of select="."/></span>.
				      	</td>
				</tr>
			</table>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="id" name="id">
	<xsl:variable name="count_idS" select="count(./@S)"/>
	<xsl:if test="$count_idS != 1">
		<table width="100%">
        		<tr class="tr-inverse">
      	      			<td valign="top" width="210">id.@S</td>
      				<td valign="top" width="200">cardinality error</td>
		             	<td>
		             		You must have one and only one <b>S</b> attribute within the id element.
		             		<br/>
			      		Your id contains <span class="red"><xsl:value-of select="$count_idS"/> S attribute(s)</span>.
			      	</td>
			      	<td class="auteur"><xsl:value-of select="."/></td>
			</tr>
		</table>
	</xsl:if>
	<xsl:variable name="count_idSV" select="count(./@SV)"/>
	<xsl:if test="$count_idSV != 1">
		<table width="100%">
        		<tr class="tr-inverse">
      	      			<td valign="top" width="210">id.@SV</td>
      				<td valign="top" width="200">cardinality error</td>
		             	<td>
		             		You must have one and only one <b>SV</b> attribute within the id element.
		             		<br/>
			      		Your id contains <span class="red"><xsl:value-of select="$count_idSV"/> SV attribute(s)</span>.
			      	</td>
			      	<td class="auteur"><xsl:value-of select="."/></td>
			</tr>
		</table>
	</xsl:if>
	<xsl:variable name="count_idSL" select="count(./@SL)"/>
	<xsl:choose>
		<xsl:when test="$count_idSL &gt; 1">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">id.@SL</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one <b>SL</b> attribute within the id element.
			             		<br/>
				      		Your id contains <span class="red"><xsl:value-of select="$count_idSL"/> SL attribute(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_idSL = 1">
			<xsl:choose>
				<xsl:when test="@S != 'LOCAL'">
					<table width="100%">
			        		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">id.@SL</td>
			      				<td valign="top" width="200">cardinality error</td>
					             	<td>You can not specify a <span class="red">local scheme SL</span> when the official scheme is not 'LOCAL'.</td>
						      	<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
				</xsl:when>
				<xsl:otherwise>
					<xsl:if test="$VERBOSE='true'">
						<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="@SL"/>::<xsl:value-of select="."/></span>
					</xsl:if>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>
		<xsl:when test="$count_idSL = 0">
			<xsl:choose>
				<xsl:when test="@S = 'LOCAL'">
					<table width="100%">
			        		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">id.@SL</td>
			      				<td valign="top" width="200">cardinality error</td>
					             	<td>You must specify a <span class="red">local scheme SL</span> when the official scheme='LOCAL'.</td>
						      	<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
				</xsl:when>
				<xsl:otherwise>
					<xsl:if test="$VERBOSE='true'">
						<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="@S"/>::<xsl:value-of select="."/></span>
					</xsl:if>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="cd" name="cd">
	<xsl:variable name="count_cdS" select="count(./@S)"/>
	<xsl:if test="$count_cdS != 1">
		<table width="100%">
        		<tr class="tr-inverse">
      	      			<td valign="top" width="210">cd.@S</td>
      				<td valign="top" width="200">cardinality error</td>
		             	<td>
		             		You must have one and only one <b>S</b> attribute within the cd element.
		             		<br/>
			      		Your cd contains <span class="red"><xsl:value-of select="$count_cdS"/> S attribute(s)</span>.
			      	</td>
			      	<td class="auteur"><xsl:value-of select="."/></td>
			</tr>
		</table>
	</xsl:if>
	<xsl:variable name="count_cdSV" select="count(./@SV)"/>
	<xsl:if test="$count_cdSV != 1">
		<table width="100%">
        		<tr class="tr-inverse">
      	      			<td valign="top" width="210">cd.@SV</td>
      				<td valign="top" width="200">cardinality error</td>
		             	<td>
		             		You must have one and only one <b>SV</b> attribute within the cd element.
		             		<br/>
			      		Your cd contains <span class="red"><xsl:value-of select="$count_cdSV"/> SV attribute(s)</span>.
			      	</td>
			      	<td class="auteur"><xsl:value-of select="."/></td>
			</tr>
		</table>
	</xsl:if>
	<xsl:variable name="count_cdSL" select="count(./@SL)"/>
	<xsl:choose>
		<xsl:when test="$count_cdSL &gt; 1">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">cd.@SL</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one <b>SL</b> attribute within the cd element.
			             		<br/>
				      		Your cd contains <span class="red"><xsl:value-of select="$count_cdSL"/> SL attribute(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_cdSL = 1">
			<xsl:choose>
				<xsl:when test="@S != 'LOCAL'">
					<table width="100%">
			        		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.@SL</td>
			      				<td valign="top" width="200">cardinality error</td>
					             	<td>You can not specify a <span class="red">local scheme SL</span> when the official scheme is not 'LOCAL'.</td>
						      	<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
				</xsl:when>
				<xsl:otherwise>
					<xsl:if test="$VERBOSE='true'">
						<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="@SL"/>::<xsl:value-of select="."/></span>
					</xsl:if>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>
		<xsl:when test="$count_cdSL = 0">
			<xsl:choose>
				<xsl:when test="@S = 'LOCAL'">
					<table width="100%">
			        		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.@SL</td>
			      				<td valign="top" width="200">cardinality error</td>
					             	<td>You must specify a <span class="red">local scheme SL</span> when the official scheme='LOCAL'.</td>
						      	<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
				</xsl:when>
				<xsl:otherwise>
					<xsl:if test="$VERBOSE='true'">
						<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:value-of select="@S"/>::<xsl:value-of select="."/></span>
					</xsl:if>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_cdDN" select="count(./@DN)"/>
	<xsl:choose>
		<xsl:when test="@S = 'LOCAL' and $count_cdDN != 1">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">cd.@SL</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>You must specify a <span class="red">description DN</span> when the official scheme='LOCAL'.</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
	</xsl:choose>
	<xsl:variable name="count_cdL" select="count(./@L)"/>
	<xsl:choose>
		<xsl:when test="@S = 'LOCAL' and $count_cdL != 1">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">cd.@SL</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>You must specify a <span class="red">language</span> when the official scheme='LOCAL'.</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
	</xsl:choose>
	<xsl:choose>
		<xsl:when test="@S = 'CD-TRANSACTION'">
			<xsl:choose>
			          <xsl:when test=". = 'admission' "/>
			          <xsl:when test=". = 'alert' "/>
		       	   	  <xsl:when test=". = 'clinicalsummary' "/>
			          <xsl:when test=". = 'contact' "/>
			          <xsl:when test=". = 'death' "/>
			          <xsl:when test=". = 'discharge' "/>
		       	   <xsl:when test=". = 'dischargereport' "/>
			          <xsl:when test=". = 'epidemiology' "/>
			          <xsl:when test=". ='labrequest' "/>
			          <xsl:when test=". ='labresult' "/>
		       	   <xsl:when test=". ='note' "/>
			          <xsl:when test=". ='nursingsummary' "/>
			          <xsl:when test=". ='pharmaceuticalprescription' "/>
			          <xsl:when test=". ='productdelivery' "/>
		       	   <xsl:when test=". ='quickdischargereport' "/>
			          <xsl:when test=". ='psychiatricsummary' "/>
			          <xsl:when test=". ='referral' "/>
			          <xsl:when test=". ='request' "/>
		       	   <xsl:when test=". ='result' "/>
			          <xsl:when test=". ='vaccination' "/>
			          <xsl:when test=". ='labrequest' "/>
			          <xsl:when test=". ='recordsummary' "/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-HEADING'">
			<xsl:choose>
				<xsl:when test=". = 'assessment' "/>
				<xsl:when test=". = 'clinical'"/>
				<xsl:when test=". = 'clinicalplan'"/>
				<xsl:when test=". = 'subjective'"/>
				<xsl:when test=". = 'technical'"/>
				<xsl:when test=". = 'technicalplan'"/>
				<xsl:when test=". = 'treatment'"/>
				<xsl:when test=". = 'userdefined'"/>
				<xsl:when test=". = 'history'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-SEX'">
			<xsl:choose>
				<xsl:when test=". = 'female'"/>
				<xsl:when test=". = 'male'"/>
				<xsl:when test=". = 'unknown'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-STANDARD'">
			<xsl:choose>
				<xsl:when test=". = '20010424'"/>
				<xsl:when test=". = '20021205'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-SITE'">
			<xsl:choose>
				<xsl:when test=". = 'BE'"/>
				<xsl:when test=". = 'blood'"/>
				<xsl:when test=". = 'BN'"/>
				<xsl:when test=". = 'BU'"/>
				<xsl:when test=". = 'CT'"/>
				<xsl:when test=". = 'LA'"/>
				<xsl:when test=". = 'LAC'"/>
				<xsl:when test=". = 'LACF'"/>
				<xsl:when test=". = 'LD'"/>
				<xsl:when test=". = 'LE'"/>
				<xsl:when test=". = 'LEJ'"/>
				<xsl:when test=". = 'LF'"/>
				<xsl:when test=". = 'LG'"/>
				<xsl:when test=". = 'LH'"/>
				<xsl:when test=". = 'LIJ'"/>
				<xsl:when test=". = 'LLAQ'"/>
				<xsl:when test=". = 'LLFA'"/>
				<xsl:when test=". = 'LMFA'"/>
				<xsl:when test=". = 'LN'"/>
				<xsl:when test=". = 'LPC'"/>
				<xsl:when test=". = 'LSC'"/>
				<xsl:when test=". = 'LT'"/>
				<xsl:when test=". = 'LUA'"/>
				<xsl:when test=". = 'LUAQ'"/>
				<xsl:when test=". = 'LUFA'"/>
				<xsl:when test=". = 'LVG'"/>
				<xsl:when test=". = 'LVL'"/>
				<xsl:when test=". = 'NB'"/>
				<xsl:when test=". = 'OD'"/>
				<xsl:when test=". = 'OS'"/>
				<xsl:when test=". = 'OU'"/>
				<xsl:when test=". = 'PA'"/>
				<xsl:when test=". = 'PERIN'"/>
				<xsl:when test=". = 'RA'"/>
				<xsl:when test=". = 'RAC'"/>
				<xsl:when test=". = 'RACF'"/>
				<xsl:when test=". = 'RD'"/>
				<xsl:when test=". = 'RE'"/>
				<xsl:when test=". = 'REJ'"/>
				<xsl:when test=". = 'RF'"/>
				<xsl:when test=". = 'RG'"/>
				<xsl:when test=". = 'RH'"/>
				<xsl:when test=". = 'RIJ'"/>
				<xsl:when test=". = 'RLAQ'"/>
				<xsl:when test=". = 'RLFA'"/>
				<xsl:when test=". = 'RMFA'"/>
				<xsl:when test=". = 'RN'"/>
				<xsl:when test=". = 'RPC'"/>
				<xsl:when test=". = 'RSC'"/>
				<xsl:when test=". = 'RT'"/>
				<xsl:when test=". = 'RUA'"/>
				<xsl:when test=". = 'RUAQ'"/>
				<xsl:when test=". = 'RUFA'"/>
				<xsl:when test=". = 'RVG'"/>
				<xsl:when test=". = 'RVL'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-ITEM'">
			<xsl:choose>
				<xsl:when test=". = 'admissiontype'"/>
				<xsl:when test=". = 'adr'"/>
				<xsl:when test=". = 'allergy'"/>
				<xsl:when test=". = 'autonomy'"/>
				<xsl:when test=". = 'clinical'"/>
				<xsl:when test=". = 'complaint'"/>
				<xsl:when test=". = 'conclusion'"/>
				<xsl:when test=". = 'contactperson'"/>
				<xsl:when test=". = 'dischargedatetime'"/>
				<xsl:when test=". = 'dischargedestination'"/>
				<xsl:when test=". = 'dischargetype'"/>
				<xsl:when test=". = 'encounterdatetime'"/>
				<xsl:when test=". = 'encounterlocation'"/>
				<xsl:when test=". = 'encounterresponsible'"/>
				<xsl:when test=". = 'encountertype'"/>
				<xsl:when test=". = 'encounterlegalservice'"/>
				<xsl:when test=". = 'transferdatetime'"/>
				<xsl:when test=". = 'evolution'"/>
				<xsl:when test=". = 'expirationdatetime'"/>
				<xsl:when test=". = 'habit'"/>
				<xsl:when test=". = 'hcpartyavailability'"/>
				<xsl:when test=". = 'healthissue'"/>
				<xsl:when test=". = 'healthcareelement'"/>
				<xsl:when test=". = 'medication'"/>
				<xsl:when test=". = 'complementaryproduct'"/>
				<xsl:when test=". = 'requestnumber'"/>
				<xsl:when test=". = 'requestdatetime'"/>
				<xsl:when test=". = 'requestor'"/>
				<xsl:when test=". = 'lab'"/>
				<xsl:when test=". = 'referrer'"/>
				<xsl:when test=". = 'reimbursementcertificate'"/>
				<xsl:when test=". = 'requesteddecisionsharing'"/>
				<xsl:when test=". = 'requestedrecipient'"/>
				<xsl:when test=". = 'requesteddischargedestination'"/>
				<xsl:when test=". = 'requestedencountertype'"/>
				<xsl:when test=". = 'risk'"/>
				<xsl:when test=". = 'specimendatetime'"/>
				<xsl:when test=". = 'technical'"/>
				<xsl:when test=". = 'transactionreason'"/>
				<xsl:when test=". = 'transcriptionist'"/>
				<xsl:when test=". = 'treatment'"/>
				<xsl:when test=". = 'vaccine'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-LAB'">
			<xsl:choose>
				<xsl:when test=". = '11127-8'"/>
				<xsl:when test=". = '11559-2'"/>
				<xsl:when test=". = '13508-7'"/>
				<xsl:when test=". = '6690-2'"/>
				<xsl:when test=". = '704-7'"/>
				<xsl:when test=". = '711-2'"/>
				<xsl:when test=". = '731-0'"/>
				<xsl:when test=". = '740-1'"/>
				<xsl:when test=". = '742-7'"/>
				<xsl:when test=". = '749-2'"/>
				<xsl:when test=". = '751-8'"/>
				<xsl:when test=". = '786-4'"/>
				<xsl:when test=". = '787-2'"/>
				<xsl:when test=". = 'xxx'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-REFSCOPE'">
			<xsl:choose>
				<xsl:when test=". = 'age'"/>
				<xsl:when test=". = 'sex'"/>
				<xsl:when test=". = 'gestationnal'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-DAYPERIOD'">
			<xsl:choose>
				<xsl:when test=". = 'afterbreakfast'"/>
				<xsl:when test=". = 'afterdinner'"/>
				<xsl:when test=". = 'afterlunch'"/>
				<xsl:when test=". = 'afterlunch'"/>
				<xsl:when test=". = 'afternoon'"/>
				<xsl:when test=". = 'beforebreakfast'"/>
				<xsl:when test=". = 'beforedinner'"/>
				<xsl:when test=". = 'beforelunch'"/>
				<xsl:when test=". = 'betweenbreakfastandlunch'"/>
				<xsl:when test=". = 'betweendinnerandsleep'"/>
				<xsl:when test=". = 'betweenlunchanddinner'"/>
				<xsl:when test=". = 'betweenmeals'"/>
				<xsl:when test=". = 'evening'"/>
				<xsl:when test=". = 'morning'"/>
				<xsl:when test=". = 'night'"/>
				<xsl:when test=". = 'thehourofsleep'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-TEMPORALITY'">
			<xsl:choose>
				<xsl:when test=". = 'oneshot'"/>
				<xsl:when test=". = 'acute'"/>
				<xsl:when test=". = 'chronic'"/>
				<xsl:when test=". = 'reactivation'"/>
				<xsl:when test=". = 'remission'"/>
				<xsl:when test=". = 'subacute'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-LIFECYCLE'">
			<xsl:choose>
				<xsl:when test=". = 'active'"/>
				<xsl:when test=". = 'added'"/>
				<xsl:when test=". = 'administrated'"/>
				<xsl:when test=". = 'cancelled'"/>
				<xsl:when test=". = 'completed'"/>
				<xsl:when test=". = 'delivered'"/>
				<xsl:when test=". = 'substituted'"/>
				<xsl:when test=". = 'inactive'"/>
				<xsl:when test=". = 'planned'"/>
				<xsl:when test=". = 'corrected'"/>
				<xsl:when test=". = 'prescribed'"/>
				<xsl:when test=". = 'reported'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-SEVERITY'">
			<xsl:choose>
				<xsl:when test=". = 'abnormal'"/>
				<xsl:when test=". = 'high'"/>
				<xsl:when test=". = 'low'"/>
				<xsl:when test=". = 'normal'"/>
				<xsl:when test=". = 'resistent'"/>
				<xsl:when test=". = 'susceptible'"/>
				<xsl:when test=". = 'susceptibleintermediate'"/>
				<xsl:when test=". = 'veryabnormal'"/>
				<xsl:when test=". = 'veryhigh'"/>
				<xsl:when test=". = 'verylow'"/>
				<xsl:when test=". = 'extremelyhigh'"/>
				<xsl:when test=". = 'extremelylow'"/>
				<xsl:when test=". = 'verysusceptible'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-CERTAINTY'">
			<xsl:choose>
				<xsl:when test=". = 'excluded'"/>
				<xsl:when test=". = 'probable'"/>
				<xsl:when test=". = 'proven'"/>
				<xsl:when test=". = 'unprobable'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-UNIT'">
			<xsl:choose>
				<xsl:when test=". = '%'"/>
				<xsl:when test=". = '%vv'"/>
				<xsl:when test=". = '%wv'"/>
				<xsl:when test=". = '%ww'"/>
				<xsl:when test=". = '1000/mm3'"/>
				<xsl:when test=". = 'mg/dl'"/>
				<xsl:when test=". = 'amp'"/>
				<xsl:when test=". = 'bag'"/>
				<xsl:when test=". = 'bol'"/>
				<xsl:when test=". = 'bot'"/>
				<xsl:when test=". = 'box'"/>
				<xsl:when test=". = 'c'"/>
				<xsl:when test=". = 'can'"/>
				<xsl:when test=". = 'cap'"/>
				<xsl:when test=". = 'cc'"/>
				<xsl:when test=". = 'cm'"/>
				<xsl:when test=". = 'cmm'"/>
				<xsl:when test=". = 'cnt'"/>
				<xsl:when test=". = 'ctr'"/>
				<xsl:when test=". = 'daily'"/>
				<xsl:when test=". = 'day'"/>
				<xsl:when test=". = 'week'"/>
				<xsl:when test=". = 'month'"/>
				<xsl:when test=". = 'dis'"/>
				<xsl:when test=". = 'spoon'"/>
				<xsl:when test=". = 'drm'"/>
				<xsl:when test=". = 'fl'"/>
				<xsl:when test=". = 'fld'"/>
				<xsl:when test=". = 'flo'"/>
				<xsl:when test=". = 'ftc'"/>
				<xsl:when test=". = 'fts'"/>
				<xsl:when test=". = 'g/dl'"/>
				<xsl:when test=". = 'mg'"/>
				<xsl:when test=". = 'mg/ml'"/>
				<xsl:when test=". = 'hour'"/>
				<xsl:when test=". = 'goutte'"/>
				<xsl:when test=". = 'ml'"/>
				<xsl:when test=". = 'ctg'"/>
				<xsl:when test=". = 'gal'"/>
				<xsl:when test=". = 'gm'"/>
				<xsl:when test=". = 'gr'"/>
				<xsl:when test=". = 'in'"/>
				<xsl:when test=". = 'inc'"/>
				<xsl:when test=". = 'jar'"/>
				<xsl:when test=". = 'kg'"/>
				<xsl:when test=". = 'kit'"/>
				<xsl:when test=". = 'l'"/>
				<xsl:when test=". = 'lb'"/>
				<xsl:when test=". = 'lm'"/>
				<xsl:when test=". = 'loz'"/>
				<xsl:when test=". = 'mcg'"/>
				<xsl:when test=". = 'mcl'"/>
				<xsl:when test=". = 'mcm'"/>
				<xsl:when test=". = 'mcn'"/>
				<xsl:when test=". = 'meq'"/>
				<xsl:when test=". = 'mic'"/>
				<xsl:when test=". = 'mil'"/>
				<xsl:when test=". = 'min'"/>
				<xsl:when test=". = 'mis'"/>
				<xsl:when test=". = 'mm'"/>
				<xsl:when test=". = 'mmo'"/>
				<xsl:when test=". = 'mol'"/>
				<xsl:when test=". = 'nl'"/>
				<xsl:when test=". = 'nmg'"/>
				<xsl:when test=". = 'nmo'"/>
				<xsl:when test=". = 'ns'"/>
				<xsl:when test=". = 'oz'"/>
				<xsl:when test=". = 'pel'"/>
				<xsl:when test=". = 'pg'"/>
				<xsl:when test=". = 'pkg'"/>
				<xsl:when test=". = 'pnu'"/>
				<xsl:when test=". = 'ppm'"/>
				<xsl:when test=". = 'pt'"/>
				<xsl:when test=". = 'qs'"/>
				<xsl:when test=". = 'qt'"/>
				<xsl:when test=". = 'sat'"/>
				<xsl:when test=". = 'spr'"/>
				<xsl:when test=". = 'sqc'"/>
				<xsl:when test=". = 'stp'"/>
				<xsl:when test=". = 'sup'"/>
				<xsl:when test=". = 'syr'"/>
				<xsl:when test=". = 'tab'"/>
				<xsl:when test=". = 'tbl'"/>
				<xsl:when test=". = 'tes'"/>
				<xsl:when test=". = 'ton'"/>
				<xsl:when test=". = 'tpn'"/>
				<xsl:when test=". = 'trc'"/>
				<xsl:when test=". = 'tro'"/>
				<xsl:when test=". = 'tsp'"/>
				<xsl:when test=". = 'tub'"/>
				<xsl:when test=". = 'umg'"/>
				<xsl:when test=". = 'unt'"/>
				<xsl:when test=". = 'vil'"/>
				<xsl:when test=". = 'vpr'"/>
				<xsl:when test=". = 'waf'"/>
				<xsl:when test=". = 'x'"/>
				<xsl:when test=". = 'ydl'"/>
				<xsl:when test=". = 'yds'"/>
				<xsl:when test=". = 'ondemand'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-ACKNOWLEDGMENT'">
			<xsl:choose>
				<xsl:when test=". = 'always'"/>
				<xsl:when test=". = 'never'"/>
				<xsl:when test=". = 'onerror'"/>
				<xsl:when test=". = 'onsuccess'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-ADDRESS'">
			<xsl:choose>
				<xsl:when test=". = 'home'"/>
				<xsl:when test=". = 'vacation'"/>
				<xsl:when test=". = 'work'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-URGENCY'">
			<xsl:choose>
				<xsl:when test=". = 'asap'"/>
				<xsl:when test=". = 'hour'"/>
				<xsl:when test=". = '4hours'"/>
				<xsl:when test=". = '12hours'"/>
				<xsl:when test=". = 'day'"/>
				<xsl:when test=". = 'week'"/>
				<xsl:when test=". = 'month'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-TELECOM'">
			<xsl:choose>
				<xsl:when test=". = 'phone'"/>
				<xsl:when test=". = 'mobile'"/>
				<xsl:when test=". = 'fax'"/>
				<xsl:when test=". = 'email'"/>
				<xsl:when test=". = 'carenet'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-COUNTRY'">
			<xsl:choose>
				<xsl:when test=". = 'ad'"/>
				<xsl:when test=". = 'ae'"/>
				<xsl:when test=". = 'af'"/>
				<xsl:when test=". = 'ag'"/>
				<xsl:when test=". = 'ai'"/>
				<xsl:when test=". = 'al'"/>
				<xsl:when test=". = 'am'"/>
				<xsl:when test=". = 'an'"/>
				<xsl:when test=". = 'ao'"/>
				<xsl:when test=". = 'aq'"/>
				<xsl:when test=". = 'ar'"/>
				<xsl:when test=". = 'arpa'"/>
				<xsl:when test=". = 'as'"/>
				<xsl:when test=". = 'at'"/>
				<xsl:when test=". = 'au'"/>
				<xsl:when test=". = 'aw'"/>
				<xsl:when test=". = 'az'"/>
				<xsl:when test=". = 'ba'"/>
				<xsl:when test=". = 'bb'"/>
				<xsl:when test=". = 'bd'"/>
				<xsl:when test=". = 'be'"/>
				<xsl:when test=". = 'bf'"/>
				<xsl:when test=". = 'bg'"/>
				<xsl:when test=". = 'bh'"/>
				<xsl:when test=". = 'bi'"/>
				<xsl:when test=". = 'bj'"/>
				<xsl:when test=". = 'bm'"/>
				<xsl:when test=". = 'bn'"/>
				<xsl:when test=". = 'bo'"/>
				<xsl:when test=". = 'br'"/>
				<xsl:when test=". = 'bs'"/>
				<xsl:when test=". = 'bt'"/>
				<xsl:when test=". = 'bv'"/>
				<xsl:when test=". = 'bw'"/>
				<xsl:when test=". = 'by'"/>
				<xsl:when test=". = 'bz'"/>
				<xsl:when test=". = 'ca'"/>
				<xsl:when test=". = 'cc'"/>
				<xsl:when test=". = 'cf'"/>
				<xsl:when test=". = 'cd'"/>
				<xsl:when test=". = 'cg'"/>
				<xsl:when test=". = 'ch'"/>
				<xsl:when test=". = 'ci'"/>
				<xsl:when test=". = 'ck'"/>
				<xsl:when test=". = 'cl'"/>
				<xsl:when test=". = 'cm'"/>
				<xsl:when test=". = 'cn'"/>
				<xsl:when test=". = 'co'"/>
				<xsl:when test=". = 'com'"/>
				<xsl:when test=". = 'cr'"/>
				<xsl:when test=". = 'cs'"/>
				<xsl:when test=". = 'cu'"/>
				<xsl:when test=". = 'cv'"/>
				<xsl:when test=". = 'cx'"/>
				<xsl:when test=". = 'cy'"/>
				<xsl:when test=". = 'cz'"/>
				<xsl:when test=". = 'de'"/>
				<xsl:when test=". = 'dj'"/>
				<xsl:when test=". = 'dk'"/>
				<xsl:when test=". = 'dm'"/>
				<xsl:when test=". = 'do'"/>
				<xsl:when test=". = 'dz'"/>
				<xsl:when test=". = 'ec'"/>
				<xsl:when test=". = 'edu'"/>
				<xsl:when test=". = 'ee'"/>
				<xsl:when test=". = 'eg'"/>
				<xsl:when test=". = 'eh'"/>
				<xsl:when test=". = 'er'"/>
				<xsl:when test=". = 'es'"/>
				<xsl:when test=". = 'et'"/>
				<xsl:when test=". = 'fi'"/>
				<xsl:when test=". = 'fj'"/>
				<xsl:when test=". = 'fk'"/>
				<xsl:when test=". = 'fm'"/>
				<xsl:when test=". = 'fo'"/>
				<xsl:when test=". = 'fr'"/>
				<xsl:when test=". = 'fx'"/>
				<xsl:when test=". = 'ga'"/>
				<xsl:when test=". = 'gb'"/>
				<xsl:when test=". = 'gd'"/>
				<xsl:when test=". = 'ge'"/>
				<xsl:when test=". = 'gf'"/>
				<xsl:when test=". = 'gh'"/>
				<xsl:when test=". = 'gi'"/>
				<xsl:when test=". = 'gl'"/>
				<xsl:when test=". = 'gm'"/>
				<xsl:when test=". = 'gn'"/>
				<xsl:when test=". = 'gov'"/>
				<xsl:when test=". = 'gp'"/>
				<xsl:when test=". = 'gr'"/>
				<xsl:when test=". = 'gs'"/>
				<xsl:when test=". = 'gt'"/>
				<xsl:when test=". = 'gu'"/>
				<xsl:when test=". = 'gw'"/>
				<xsl:when test=". = 'gy'"/>
				<xsl:when test=". = 'hk'"/>
				<xsl:when test=". = 'hm'"/>
				<xsl:when test=". = 'hn'"/>
				<xsl:when test=". = 'hr'"/>
				<xsl:when test=". = 'ht'"/>
				<xsl:when test=". = 'hu'"/>
				<xsl:when test=". = 'id'"/>
				<xsl:when test=". = 'ie'"/>
				<xsl:when test=". = 'il'"/>
				<xsl:when test=". = 'in'"/>
				<xsl:when test=". = 'int'"/>
				<xsl:when test=". = 'io'"/>
				<xsl:when test=". = 'iq'"/>
				<xsl:when test=". = 'ir'"/>
				<xsl:when test=". = 'is'"/>
				<xsl:when test=". = 'it'"/>
				<xsl:when test=". = 'jm'"/>
				<xsl:when test=". = 'jo'"/>
				<xsl:when test=". = 'jp'"/>
				<xsl:when test=". = 'ke'"/>
				<xsl:when test=". = 'kg'"/>
				<xsl:when test=". = 'kh'"/>
				<xsl:when test=". = 'ki'"/>
				<xsl:when test=". = 'km'"/>
				<xsl:when test=". = 'kn'"/>
				<xsl:when test=". = 'kp'"/>
				<xsl:when test=". = 'kr'"/>
				<xsl:when test=". = 'kw'"/>
				<xsl:when test=". = 'ky'"/>
				<xsl:when test=". = 'kz'"/>
				<xsl:when test=". = 'la'"/>
				<xsl:when test=". = 'lb'"/>
				<xsl:when test=". = 'lc'"/>
				<xsl:when test=". = 'li'"/>
				<xsl:when test=". = 'lk'"/>
				<xsl:when test=". = 'ls'"/>
				<xsl:when test=". = 'lt'"/>
				<xsl:when test=". = 'lu'"/>
				<xsl:when test=". = 'lv'"/>
				<xsl:when test=". = 'ly'"/>
				<xsl:when test=". = 'ma'"/>
				<xsl:when test=". = 'mc'"/>
				<xsl:when test=". = 'md'"/>
				<xsl:when test=". = 'mg'"/>
				<xsl:when test=". = 'mh'"/>
				<xsl:when test=". = 'mil'"/>
				<xsl:when test=". = 'mk'"/>
				<xsl:when test=". = 'ml'"/>
				<xsl:when test=". = 'mm'"/>
				<xsl:when test=". = 'mn'"/>
				<xsl:when test=". = 'mo'"/>
				<xsl:when test=". = 'mp'"/>
				<xsl:when test=". = 'mq'"/>
				<xsl:when test=". = 'mr'"/>
				<xsl:when test=". = 'ms'"/>
				<xsl:when test=". = 'mt'"/>
				<xsl:when test=". = 'mu'"/>
				<xsl:when test=". = 'mv'"/>
				<xsl:when test=". = 'mw'"/>
				<xsl:when test=". = 'mx'"/>
				<xsl:when test=". = 'my'"/>
				<xsl:when test=". = 'mz'"/>
				<xsl:when test=". = 'na'"/>
				<xsl:when test=". = 'nato'"/>
				<xsl:when test=". = 'nc'"/>
				<xsl:when test=". = 'ne'"/>
				<xsl:when test=". = 'net'"/>
				<xsl:when test=". = 'nf'"/>
				<xsl:when test=". = 'ng'"/>
				<xsl:when test=". = 'ni'"/>
				<xsl:when test=". = 'nl'"/>
				<xsl:when test=". = 'no'"/>
				<xsl:when test=". = 'np'"/>
				<xsl:when test=". = 'nr'"/>
				<xsl:when test=". = 'nt'"/>
				<xsl:when test=". = 'nu'"/>
				<xsl:when test=". = 'nz'"/>
				<xsl:when test=". = 'om'"/>
				<xsl:when test=". = 'org'"/>
				<xsl:when test=". = 'pa'"/>
				<xsl:when test=". = 'pe'"/>
				<xsl:when test=". = 'pf'"/>
				<xsl:when test=". = 'pg'"/>
				<xsl:when test=". = 'ph'"/>
				<xsl:when test=". = 'pk'"/>
				<xsl:when test=". = 'pl'"/>
				<xsl:when test=". = 'pm'"/>
				<xsl:when test=". = 'pn'"/>
				<xsl:when test=". = 'pr'"/>
				<xsl:when test=". = 'pt'"/>
				<xsl:when test=". = 'pw'"/>
				<xsl:when test=". = 'py'"/>
				<xsl:when test=". = 'qa'"/>
				<xsl:when test=". = 're'"/>
				<xsl:when test=". = 'ro'"/>
				<xsl:when test=". = 'ru'"/>
				<xsl:when test=". = 'rw'"/>
				<xsl:when test=". = 'sa'"/>
				<xsl:when test=". = 'sb'"/>
				<xsl:when test=". = 'sc'"/>
				<xsl:when test=". = 'sd'"/>
				<xsl:when test=". = 'se'"/>
				<xsl:when test=". = 'sg'"/>
				<xsl:when test=". = 'sh'"/>
				<xsl:when test=". = 'si'"/>
				<xsl:when test=". = 'sj'"/>
				<xsl:when test=". = 'sk'"/>
				<xsl:when test=". = 'sl'"/>
				<xsl:when test=". = 'sm'"/>
				<xsl:when test=". = 'sn'"/>
				<xsl:when test=". = 'so'"/>
				<xsl:when test=". = 'sr'"/>
				<xsl:when test=". = 'st'"/>
				<xsl:when test=". = 'su'"/>
				<xsl:when test=". = 'sv'"/>
				<xsl:when test=". = 'sy'"/>
				<xsl:when test=". = 'sz'"/>
				<xsl:when test=". = 'tc'"/>
				<xsl:when test=". = 'td'"/>
				<xsl:when test=". = 'tf'"/>
				<xsl:when test=". = 'tg'"/>
				<xsl:when test=". = 'th'"/>
				<xsl:when test=". = 'tj'"/>
				<xsl:when test=". = 'tk'"/>
				<xsl:when test=". = 'tm'"/>
				<xsl:when test=". = 'tn'"/>
				<xsl:when test=". = 'to'"/>
				<xsl:when test=". = 'tp'"/>
				<xsl:when test=". = 'tr'"/>
				<xsl:when test=". = 'tt'"/>
				<xsl:when test=". = 'tv'"/>
				<xsl:when test=". = 'tw'"/>
				<xsl:when test=". = 'tz'"/>
				<xsl:when test=". = 'ua'"/>
				<xsl:when test=". = 'ug'"/>
				<xsl:when test=". = 'uk'"/>
				<xsl:when test=". = 'um'"/>
				<xsl:when test=". = 'us'"/>
				<xsl:when test=". = 'uy'"/>
				<xsl:when test=". = 'uz'"/>
				<xsl:when test=". = 'va'"/>
				<xsl:when test=". = 'vc'"/>
				<xsl:when test=". = 've'"/>
				<xsl:when test=". = 'vg'"/>
				<xsl:when test=". = 'vi'"/>
				<xsl:when test=". = 'vn'"/>
				<xsl:when test=". = 'vu'"/>
				<xsl:when test=". = 'wf'"/>
				<xsl:when test=". = 'ws'"/>
				<xsl:when test=". = 'ye'"/>
				<xsl:when test=". = 'yt'"/>
				<xsl:when test=". = 'yu'"/>
				<xsl:when test=". = 'za'"/>
				<xsl:when test=". = 'zm'"/>
				<xsl:when test=". = 'zr'"/>
				<xsl:when test=". = 'zw'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
		<xsl:when test="@S = 'CD-HCPARTY'">
			<xsl:choose>
				<xsl:when test=". = 'application'"/>
				<xsl:when test=". = 'persbiologist'"/>
				<xsl:when test=". = 'deptanatomopathology'"/>
				<xsl:when test=". = 'deptanesthesiology'"/>
				<xsl:when test=". = 'deptbacteriology'"/>
				<xsl:when test=". = 'deptcardiology'"/>
				<xsl:when test=". = 'deptdermatology'"/>
				<xsl:when test=". = 'deptdietetics'"/>
				<xsl:when test=". = 'deptemergency'"/>
				<xsl:when test=". = 'deptoncology'"/>
				<xsl:when test=". = 'deptrhumatology'"/>
				<xsl:when test=". = 'deptnephrology'"/>
				<xsl:when test=". = 'deptgastroenterology'"/>
				<xsl:when test=". = 'deptgeneralpractice'"/>
				<xsl:when test=". = 'deptgenetics'"/>
				<xsl:when test=". = 'deptgeriatry'"/>
				<xsl:when test=". = 'deptgynecology'"/>
				<xsl:when test=". = 'depthematology'"/>
				<xsl:when test=". = 'deptintensivecare'"/>
				<xsl:when test=". = 'deptkinesitherapy'"/>
				<xsl:when test=". = 'deptlaboratory'"/>
				<xsl:when test=". = 'deptmedicine'"/>
				<xsl:when test=". = 'deptmolecularbiology'"/>
				<xsl:when test=". = 'deptneurology'"/>
				<xsl:when test=". = 'deptnte'"/>
				<xsl:when test=". = 'deptnuclear'"/>
				<xsl:when test=". = 'deptophtalmology'"/>
				<xsl:when test=". = 'deptpediatry'"/>
				<xsl:when test=". = 'deptpharmacy'"/>
				<xsl:when test=". = 'deptphysiotherapy'"/>
				<xsl:when test=". = 'deptpneumology'"/>
				<xsl:when test=". = 'deptpsychiatry'"/>
				<xsl:when test=". = 'deptradiology'"/>
				<xsl:when test=". = 'deptradiotherapy'"/>
				<xsl:when test=". = 'deptstomatology'"/>
				<xsl:when test=". = 'deptsurgery'"/>
				<xsl:when test=". = 'depttoxicology'"/>
				<xsl:when test=". = 'depturology'"/>
				<xsl:when test=". = 'orghospital'"/>
				<xsl:when test=". = 'orglaboratory'"/>
				<xsl:when test=". = 'orginsurance'"/>
				<xsl:when test=". = 'persnurse'"/>
				<xsl:when test=". = 'persparamedical'"/>
				<xsl:when test=". = 'perspharmacist'"/>
				<xsl:when test=". = 'persphysician'"/>
				<xsl:when test=". = 'orgpublichealth'"/>
				<xsl:when test=". = 'perssocialworker'"/>
				<xsl:when test=". = 'perstechnician'"/>
			          <xsl:otherwise>
					<table width="100%">
		       	 		<tr class="tr-inverse">
			      	      			<td valign="top" width="210">cd.<xsl:value-of select="@S"/></td>
			      				<td valign="top" width="200">dictionary error</td>
					             	<td>The value <span class="red"><xsl:value-of select="."/></span> is not valid within the <xsl:value-of select="@S"/> scheme.</td>
					      		<td class="auteur"><xsl:value-of select="."/></td>
						</tr>
					</table>
		       	</xsl:otherwise>
		        </xsl:choose>
	   	</xsl:when>
       </xsl:choose>
</xsl:template>
<!-- *********************** BASICS ************************* -->


<!-- *********************** CONTENT ************************* -->
<xsl:template match="content" name="content">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
		<br/>
	</xsl:if>
	<xsl:for-each select="id|cd|decimal|boolean|text|date|time|hcparty|person|insurance|error|medication|holter|ecg|bacteriology|lnk|unit|minref|maxref|refscope">
		<xsl:if test="$VERBOSE='true'">
			----------------------------------------
		</xsl:if>
		<xsl:apply-templates select="."/>
		<xsl:if test="$VERBOSE='true'">
			<xsl:choose>
				<xsl:when test="name()='unit'">
					<br/>
				</xsl:when>
				<xsl:when test="name()='decimal'">
					<br/>
				</xsl:when>
				<xsl:otherwise>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:for-each>
</xsl:template>

<xsl:template match="minref" name="minref">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:for-each select="decimal|text">
		<xsl:apply-templates select="."/>
		<xsl:if test="$VERBOSE='true'">
			<br/>
		</xsl:if>
	</xsl:for-each>
</xsl:template>

<xsl:template match="maxref" name="maxref">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:for-each select="decimal|text">
		<xsl:apply-templates select="."/>
		<xsl:if test="$VERBOSE='true'">
			<br/>
		</xsl:if>
	</xsl:for-each>
</xsl:template>

<xsl:template match="refscope" name="refscope">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
		<br/>
	</xsl:if>
	<xsl:for-each select="code|refvalue">
		<xsl:if test="$VERBOSE='true'">
			--------------------------------------------------
		</xsl:if>
		<xsl:apply-templates select="."/>
		<xsl:if test="$VERBOSE='true'">
			<br/>
		</xsl:if>
	</xsl:for-each>
</xsl:template>

<xsl:template match="refvalue" name="refvalue">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
		<br/>
	</xsl:if>
	<xsl:for-each select="minref|maxref|context">
		<xsl:if test="$VERBOSE='true'">
			------------------------------------------------------------
		</xsl:if>
		<xsl:apply-templates select="."/>
		<xsl:if test="$VERBOSE='true'">
		</xsl:if>
	</xsl:for-each>
</xsl:template>

<xsl:template match="context" name="context">
	<xsl:call-template name="text"/>
</xsl:template>

<xsl:template match="error" name="error">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_errorcd" select="count(cd[@S='CD-ERROR'])"/>
 	<xsl:choose>
		<xsl:when test="$count_errorcd &lt; '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">error.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have at least one error code within the error.
			             		<br/>
				      		Your error contains <span class="red"><xsl:value-of select="$count_errorcd"/> official error cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:otherwise>
			<xsl:for-each select="cd">
				<xsl:apply-templates select="."/>
			</xsl:for-each>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:apply-templates select="description"/>
	<xsl:apply-templates select="url"/>
</xsl:template>

<xsl:template match="description" name="description">
	<xsl:if test="$VERBOSE='true'">
		<xsl:value-of select="."/>
	</xsl:if>
</xsl:template>

<xsl:template match="url" name="url">
	<xsl:if test="$VERBOSE='true'">
		<xsl:value-of select="."/>
	</xsl:if>
</xsl:template>
<!-- *********************** CONTENT ************************* -->


<!-- *********************** MEDICATION ************************* -->
<xsl:template match="medication" name="medication">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
		<br/>
	</xsl:if>
	<xsl:for-each select="cd|inn|magistral|tradename|presentation|strength|route|batch|numberofpackage|package|quantityperpackage|instructionforoverdosing|instructionforpatient|instructionforreimbursement|issubstitutionallowed">
		<xsl:if test="$VERBOSE='true'">
			--------------------------------------------------
		</xsl:if>
		<xsl:apply-templates select="."/>
		<xsl:if test="$VERBOSE='true'">
			<br/>
		</xsl:if>
	</xsl:for-each>
</xsl:template>

<xsl:template match="inn" name="inn">
	<xsl:if test="$VERBOSE='true'">
		<xsl:call-template name="text"/>
	</xsl:if>
</xsl:template>

<xsl:template match="magistral" name="magistral">
	<xsl:if test="$VERBOSE='true'">
		<xsl:call-template name="text"/>
	</xsl:if>
</xsl:template>

<xsl:template match="tradename" name="tradename">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="."/></span>
	</xsl:if>
</xsl:template>

<xsl:template match="presentation" name="presentation">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_presentationkmehrcd" select="count(cd[@S='CD-DRUG-PRESENTATION'])"/>
 	<xsl:choose>
		<xsl:when test="$count_presentationkmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">presentation.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official presentation cd within the presentation.
			             		<br/>
				      		Your presentation contains <span class="red"><xsl:value-of select="$count_presentationkmehrcd"/> official presentation cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_presentationkmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="route" name="route">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_routekmehrcd" select="count(cd[@S='CD-DRUG-ROUTE'])"/>
 	<xsl:choose>
		<xsl:when test="$count_routekmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">route.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official route cd within the route.
			             		<br/>
				      		Your route contains <span class="red"><xsl:value-of select="$count_routekmehrcd"/> official route cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_routekmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="batch" name="batch">
	<xsl:if test="$VERBOSE='true'">
		<xsl:call-template name="text"/>
	</xsl:if>
</xsl:template>

<xsl:template match="numberofpackage" name="numberofpackage">
	<xsl:if test="$VERBOSE='true'">
		<xsl:call-template name="decimal"/>
	</xsl:if>
</xsl:template>

<xsl:template match="package" name="package">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = </span>
	</xsl:if>
	<xsl:variable name="count_packagekmehrcd" select="count(cd[@S='CD-UNIT'])"/>
 	<xsl:choose>
		<xsl:when test="$count_packagekmehrcd != '1' ">
			<table width="100%">
	        		<tr class="tr-inverse">
	      	      			<td valign="top" width="210">package.cd</td>
	      				<td valign="top" width="200">cardinality error</td>
			             	<td>
			             		You must have one and only one official package cd within the package.
			             		<br/>
				      		Your package contains <span class="red"><xsl:value-of select="$count_packagekmehrcd"/> official package cd element(s)</span>.
				      	</td>
				      	<td class="auteur"><xsl:value-of select="."/></td>
				</tr>
			</table>
		</xsl:when>
		<xsl:when test="$count_packagekmehrcd = '1' ">
			<xsl:apply-templates select="cd"/>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="quantityperpackage" name="quantityperpackage">
	<xsl:if test="$VERBOSE='true'">
		<xsl:call-template name="decimal"/>
	</xsl:if>
</xsl:template>

<xsl:template match="instructionforoverdosing" name="instructionforoverdosing">
	<xsl:if test="$VERBOSE='true'">
		<xsl:call-template name="text"/>
	</xsl:if>
</xsl:template>

<xsl:template match="instructionforoverpatient" name="instructionforpatient">
	<xsl:if test="$VERBOSE='true'">
		<xsl:call-template name="text"/>
	</xsl:if>
</xsl:template>

<xsl:template match="instructionforreimbursement" name="instructionforreimbursement">
	<xsl:if test="$VERBOSE='true'">
		<xsl:call-template name="text"/>
	</xsl:if>
</xsl:template>

<xsl:template match="issubstitutionallowed" name="issubstitutionallowed">
	<xsl:if test="$VERBOSE='true'">
		<span class="tr-valid"><xsl:value-of select="name()"/> = <xsl:call-template name="boolean"/></span>
	</xsl:if>
</xsl:template>
<!-- *********************** MEDICATION ************************* -->



<!--TODO -->
<xsl:template match="holter" name="holter">
	<xsl:if test="$VERBOSE='true'">
		Not yet tested: holter <xsl:value-of select="."/><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="ecg" name="ecg">
	<xsl:if test="$VERBOSE='true'">
		Not yet tested: ecg <xsl:value-of select="."/><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="bacteriology" name="bacteriology">
	<xsl:if test="$VERBOSE='true'">
		Not yet tested: bacteriology <xsl:value-of select="."/><br/>
	</xsl:if>
</xsl:template>

<xsl:template match="lnk" name="lnk">
	<xsl:if test="$VERBOSE='true'">
		Not yet tested: lnk <xsl:value-of select="."/><br/>
	</xsl:if>
</xsl:template>

</xsl:stylesheet>
