<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/TR/REC-html40">
	<!-- This is version 2.0 of the newsml conformance stylesheet produced by David Allen, MD IPTC Copyright 2000 IPTC with valued assistance from T Fujiwara 25-08-2001-->
	<!-- It requires the October 2000 version of MSXML3.DLL and IE5.5 to be displayed-->
	<!-- It applies to the NewsMLv1.0 DTD-->
	<xsl:output method="html"/>
	<xsl:template match="NewsML">
		<html>
			<head>
				<title/>
			</head>
			<body>
				<xsl:text>NewsML Instance Compliance Check results</xsl:text>
				<span style="font:bold;color:#00FF00">
					<xsl:text> PASS</xsl:text>
				</span>
				<span style="font:bold;color:#FFBB00">
					<xsl:text> CAUTION</xsl:text>
				</span>
				<span style="font:bold;color:#FF0000">
					<xsl:text> FAIL</xsl:text>
				</span>
				<xsl:apply-templates select="Catalog|TopicSet|NewsEnvelope|NewsItem"/>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="NewsEnvelope">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="NewsItem">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="NewsManagement">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="Identification">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="NewsComponent">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="AdministrativeMetadata">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="Metadata">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="SubjectCode">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="RightsMetadata">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="UsageRights">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="NewsLines">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="HeadLine">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="SubHeadLine">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="ByLine">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="DateLine">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="CreditLine">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="CopyrightLine">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="CopyrightDate">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="CopyrightHolder">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="RightsLine">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="SeriesLine">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="SlugLine">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="KeywordLine">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="NewsLine">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="NewsLineText">
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="Topic">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="FormalName"/>
	<xsl:template match="ContentItem">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="DateId"/>
	<xsl:template match="ProviderId"/>
	<xsl:template match="NewsItemId"/>
	<xsl:template match="NewsItemRef"/>
	<xsl:template match="Update"/>
	<xsl:template match="Description"/>
	<xsl:template match="Comment"/>
	<xsl:template match="DataContent"/>
	<xsl:template match="Resource"/>
	<xsl:template match="BasisForChoice"/>
	<xsl:template match="TransmissionId"/>
	<xsl:template match="FileName"/>
	<xsl:template match="SizeInBytes"/>
	<xsl:template match="SystemIdentifier"/>
	<xsl:template match="FutureStatus|LabelType|Language|MediaType|MetadataType|MimeType|NewsItemType|NewsLineType|NewsProduct|NewsService|Notation|Priority|Role|Status|Urgency">
		<xsl:if test="name(.)='Language'">
			<xsl:if test="@DateAndTime">
				<xsl:call-template name="checkdate">
					<xsl:with-param name="datestr" select="@DateAndTime"/>
					<xsl:with-param name="elename" select="name()"/>
				</xsl:call-template>
			</xsl:if>
		</xsl:if>
		<xsl:choose>
			<xsl:when test="@Vocabulary">
				<xsl:variable name="hsceme" select="@Scheme"/>
				<xsl:variable name="hfoname" select="@FormalName"/>
				<xsl:variable name="helename" select="name()"/>
				<xsl:variable name="hvocstr" select="@Vocabulary"/>
				<xsl:choose>
					<xsl:when test="substring(@Vocabulary,1,7)='http://' or substring(@Vocabulary,1,1)='.'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by url.</xsl:text>
							</span>
						</div>
						<xsl:variable name="fndata">
							<xsl:call-template name="xvoc">
								<xsl:with-param name="scema1" select="$hsceme"/>
								<xsl:with-param name="foname1" select="$hfoname"/>
								<xsl:with-param name="elename1" select="$helename"/>
								<xsl:with-param name="vocstr1" select="$hvocstr"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:choose>
							<xsl:when test="$fndata!=''">
								<xsl:copy-of select="$fndata"/>
							</xsl:when>
							<xsl:otherwise>
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
									<span style="color:#FF0000">
										<span style="font:italic">
											<xsl:value-of select="$helename"/>
										</span>
										<xsl:text> FormalName not located in remote TopicSet.</xsl:text>
									</span>
									<xsl:call-template name="PrintAdditionalInfo">
										<xsl:with-param name="schValue" select="$hsceme"/>
										<xsl:with-param name="forValue" select="$hfoname"/>
										<xsl:with-param name="topicUrl" select="$hvocstr"/>
									</xsl:call-template>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="substring(@Vocabulary,1,11)='urn:newsml:'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
							<span style="color:#FFBB00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by urn.</xsl:text>
							</span>
						</div>
						<xsl:for-each select="//Catalog">
							<xsl:choose>
								<xsl:when test="@Href">
									<xsl:if test="substring(@Href,1,7)='http://' or substring(@Href,1,1)='.'">
										<xsl:variable name="caturl1" select="@Href"/>
										<xsl:for-each select="document($caturl1)//Catalog/Resource">
											<xsl:if test="Urn=$hvocstr">
												<xsl:variable name="turl" select="Url"/>
												<xsl:variable name="fndata1">
													<xsl:call-template name="xvoc">
														<xsl:with-param name="scema1" select="$hsceme"/>
														<xsl:with-param name="foname1" select="$hfoname"/>
														<xsl:with-param name="elename1" select="$helename"/>
														<xsl:with-param name="vocstr1" select="$turl"/>
													</xsl:call-template>
												</xsl:variable>
												<xsl:choose>
													<xsl:when test="$fndata1!=''">
														<xsl:copy-of select="$fndata1"/>
													</xsl:when>
													<xsl:otherwise>
														<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
															<span style="color:#FF0000">
																<span style="font:italic">
																	<xsl:value-of select="$helename"/>
																</span>
																<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
															</span>
															<xsl:call-template name="PrintAdditionalInfo">
																<xsl:with-param name="schValue" select="$hsceme"/>
																<xsl:with-param name="forValue" select="$hfoname"/>
																<xsl:with-param name="topicUrl" select="$turl"/>
															</xsl:call-template>
														</div>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:if>
										</xsl:for-each>
									</xsl:if>
								</xsl:when>
								<xsl:otherwise>
									<xsl:for-each select="Resource">
										<xsl:if test="Urn=$hvocstr">
											<xsl:variable name="turl" select="Url"/>
											<xsl:variable name="fndata1">
												<xsl:call-template name="xvoc">
													<xsl:with-param name="scema1" select="$hsceme"/>
													<xsl:with-param name="foname1" select="$hfoname"/>
													<xsl:with-param name="elename1" select="$helename"/>
													<xsl:with-param name="vocstr1" select="$turl"/>
												</xsl:call-template>
											</xsl:variable>
											<xsl:choose>
												<xsl:when test="$fndata1!=''">
													<xsl:copy-of select="$fndata1"/>
												</xsl:when>
												<xsl:otherwise>
													<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
														<span style="color:#FF0000">
															<span style="font:italic">
																<xsl:value-of select="$helename"/>
															</span>
															<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
														</span>
														<xsl:call-template name="PrintAdditionalInfo">
															<xsl:with-param name="schValue" select="$hsceme"/>
															<xsl:with-param name="forValue" select="$hfoname"/>
															<xsl:with-param name="topicUrl" select="$turl"/>
														</xsl:call-template>
													</div>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:if>
									</xsl:for-each>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:for-each>
					</xsl:when>
					<xsl:when test="substring(@Vocabulary,1,1)='#'">
						<xsl:call-template name="findts">
							<xsl:with-param name="scema" select="$hsceme"/>
							<xsl:with-param name="foname" select="$hfoname"/>
							<xsl:with-param name="elename" select="$helename"/>
							<xsl:with-param name="vocstr" select="substring(@Vocabulary,2,string-length(@Vocabulary)-1)"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary Pointer </xsl:text>
								<xsl:value-of select="@Vocabulary"/>
								<xsl:text> to TopicSet invalid.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates mode="isdefault2" select="parent::*">
					<xsl:with-param name="psceme" select="@Scheme"/>
					<xsl:with-param name="pfoname" select="@FormalName"/>
					<xsl:with-param name="currentele" select="name()"/>
				</xsl:apply-templates>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="Party">
		<xsl:if test="name(.)='Language'">
			<xsl:if test="@DateAndTime">
				<xsl:call-template name="checkdate">
					<xsl:with-param name="datestr" select="@DateAndTime"/>
					<xsl:with-param name="elename" select="name()"/>
				</xsl:call-template>
			</xsl:if>
		</xsl:if>
		<xsl:choose>
			<xsl:when test="@Vocabulary">
				<xsl:variable name="hsceme" select="@Scheme"/>
				<xsl:variable name="hfoname" select="@FormalName"/>
				<xsl:variable name="helename" select="name()"/>
				<xsl:variable name="hvocstr" select="@Vocabulary"/>
				<xsl:choose>
					<xsl:when test="substring(@Vocabulary,1,7)='http://' or substring(@Vocabulary,1,1)='.'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by url.</xsl:text>
							</span>
						</div>
						<xsl:variable name="fndata">
							<xsl:call-template name="xvoc">
								<xsl:with-param name="scema1" select="$hsceme"/>
								<xsl:with-param name="foname1" select="$hfoname"/>
								<xsl:with-param name="elename1" select="$helename"/>
								<xsl:with-param name="vocstr1" select="$hvocstr"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:choose>
							<xsl:when test="$fndata!=''">
								<xsl:copy-of select="$fndata"/>
							</xsl:when>
							<xsl:otherwise>
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
									<span style="color:#FF0000">
										<span style="font:italic">
											<xsl:value-of select="$helename"/>
										</span>
										<xsl:text> FormalName not located in remote TopicSet.</xsl:text>
									</span>
									<xsl:call-template name="PrintAdditionalInfo">
										<xsl:with-param name="schValue" select="$hsceme"/>
										<xsl:with-param name="forValue" select="$hfoname"/>
										<xsl:with-param name="topicUrl" select="$hvocstr"/>
									</xsl:call-template>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="substring(@Vocabulary,1,11)='urn:newsml:'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
							<span style="color:#FFBB00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by urn.</xsl:text>
							</span>
						</div>
						<xsl:for-each select="//Catalog">
						<xsl:choose>
							<xsl:when test="@Href">
								<xsl:if test="substring(@Href,1,7)='http://' or substring(@Href,1,1)='.'">
									<xsl:variable name="caturl1" select="@Href"/>
									<xsl:for-each select="document($caturl1)//Catalog/Resource">
										<xsl:if test="Urn=$hvocstr">
											<xsl:variable name="turl" select="Url"/>
											<xsl:variable name="fndata1">
												<xsl:call-template name="xvoc">
													<xsl:with-param name="scema1" select="$hsceme"/>
													<xsl:with-param name="foname1" select="$hfoname"/>
													<xsl:with-param name="elename1" select="$helename"/>
													<xsl:with-param name="vocstr1" select="$turl"/>
												</xsl:call-template>
											</xsl:variable>
											<xsl:choose>
												<xsl:when test="$fndata1!=''">
													<xsl:copy-of select="$fndata1"/>
												</xsl:when>
												<xsl:otherwise>
													<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
														<span style="color:#FF0000">
															<span style="font:italic">
																<xsl:value-of select="$helename"/>
															</span>
															<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
														</span>
														<xsl:call-template name="PrintAdditionalInfo">
															<xsl:with-param name="schValue" select="$hsceme"/>
															<xsl:with-param name="forValue" select="$hfoname"/>
															<xsl:with-param name="topicUrl" select="$turl"/>
														</xsl:call-template>
													</div>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:if>
									</xsl:for-each>
								</xsl:if>
							</xsl:when>
							<xsl:otherwise>
							<xsl:for-each select="Resource">
										<xsl:if test="Urn=$hvocstr">
											<xsl:variable name="turl" select="Url"/>
											<xsl:variable name="fndata1">
												<xsl:call-template name="xvoc">
													<xsl:with-param name="scema1" select="$hsceme"/>
													<xsl:with-param name="foname1" select="$hfoname"/>
													<xsl:with-param name="elename1" select="$helename"/>
													<xsl:with-param name="vocstr1" select="$turl"/>
												</xsl:call-template>
											</xsl:variable>
											<xsl:choose>
												<xsl:when test="$fndata1!=''">
													<xsl:copy-of select="$fndata1"/>
												</xsl:when>
												<xsl:otherwise>
													<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
														<span style="color:#FF0000">
															<span style="font:italic">
																<xsl:value-of select="$helename"/>
															</span>
															<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
														</span>
														<xsl:call-template name="PrintAdditionalInfo">
															<xsl:with-param name="schValue" select="$hsceme"/>
															<xsl:with-param name="forValue" select="$hfoname"/>
															<xsl:with-param name="topicUrl" select="$turl"/>
														</xsl:call-template>
													</div>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:if>
									</xsl:for-each>

							</xsl:otherwise>						</xsl:choose>			
						</xsl:for-each>
					</xsl:when>
					<xsl:when test="substring(@Vocabulary,1,1)='#'">
						<xsl:call-template name="findts">
							<xsl:with-param name="scema" select="$hsceme"/>
							<xsl:with-param name="foname" select="$hfoname"/>
							<xsl:with-param name="elename" select="$helename"/>
							<xsl:with-param name="vocstr" select="substring(@Vocabulary,2,string-length(@Vocabulary)-1)"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary Pointer </xsl:text>
								<xsl:value-of select="@Vocabulary"/>
								<xsl:text> to TopicSet invalid.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates mode="isdefault2" select="parent::*">
					<xsl:with-param name="psceme" select="@Scheme"/>
					<xsl:with-param name="pfoname" select="@FormalName"/>
					<xsl:with-param name="currentele" select="name()"/>
					<xsl:with-param name="pcurrent" select="name(..)"/>
				</xsl:apply-templates>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template name="PrintAdditionalInfo">
		<xsl:param name="schValue"/>
		<xsl:param name="forValue"/>
		<xsl:param name="topicUrl"/>
		<div>
			<span>
				<xsl:text> FormalName=</xsl:text>
				<xsl:value-of select="$forValue"/>
				<xsl:text> Scheme=</xsl:text>
				<xsl:value-of select="$schValue"/>
				<xsl:text> TopicSet=</xsl:text>
				<xsl:value-of select="$topicUrl"/>
			</span>
		</div>
	</xsl:template>
	<xsl:template name="xvoc">
		<xsl:param name="scema1"/>
		<xsl:param name="foname1"/>
		<xsl:param name="elename1"/>
		<xsl:param name="vocstr1"/>
		<xsl:for-each select="document($vocstr1)//TopicSet/Topic">
			<xsl:choose>
				<xsl:when test="$scema1">
					<xsl:if test="FormalName/@Scheme=$scema1">
						<xsl:if test="FormalName=$foname1">
							<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
								<span style="color:#00FF00">
									<span style="font:italic">
										<xsl:value-of select="$elename1"/>
									</span>
									<xsl:text> FormalName found in  remote TopicSet</xsl:text>
								</span>
								<xsl:call-template name="PrintAdditionalInfo">
									<xsl:with-param name="schValue" select="$scema1"/>
									<xsl:with-param name="forValue" select="$foname1"/>
									<xsl:with-param name="topicUrl" select="$vocstr1"/>
								</xsl:call-template>
							</div>
						</xsl:if>
					</xsl:if>
				</xsl:when>
				<xsl:otherwise>
					<xsl:if test="FormalName=$foname1">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:value-of select="$elename1"/>
								</span>
								<xsl:text> FormalName found in  remote TopicSet</xsl:text>
							</span>
							<xsl:call-template name="PrintAdditionalInfo">
								<xsl:with-param name="schValue" select="$scema1"/>
								<xsl:with-param name="forValue" select="$foname1"/>
								<xsl:with-param name="topicUrl" select="$vocstr1"/>
							</xsl:call-template>
						</div>
					</xsl:if>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>
	<xsl:template match="TopicSet|TopicType">
		<xsl:variable name="elename" select="name()"/>
		<xsl:variable name="tscema" select="@Scheme"/>
		<xsl:variable name="ttype" select="@FormalName"/>
		<xsl:variable name="rdata">
			<xsl:for-each select="//Catalog">
				<xsl:if test="@Href">
					<xsl:if test="substring(@Href,1,7)='http://' or substring(@Href,1,1)='.'">
						<xsl:variable name="caturl" select="@Href"/>
						<xsl:for-each select="document($caturl)//Catalog/Resource">
							<xsl:if test="DefaultVocabularyFor/@Context='TopicType' or DefaultVocabularyFor/@Context='TopicType/@FormalName'  or DefaultVocabularyFor/@Context='TopicType|TopicSet' or DefaultVocabularyFor/@Context='TopicType/@FormalName|TopicSet/@FormalName' or DefaultVocabularyFor/@Context='TopicSet|TopicType' or DefaultVocabularyFor/@Context='TopicSet/@FormalName|TopicType/@FormalName'">
								<xsl:variable name="rvocurl" select="Url"/>
								<xsl:for-each select="document($rvocurl)//TopicSet/Topic">
									<xsl:if test="$tscema!=''">
										<xsl:if test="FormalName=$ttype and FormalName/@Scheme=$tscema">
											<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
												<span style="color:#00FF00">
													<span style="font:italic">
														<xsl:value-of select="$elename"/>
													</span>
													<xsl:text> FormalName and Scheme found in remote TopicSet through remote Catalog.</xsl:text>
												</span>
												<xsl:call-template name="PrintAdditionalInfo">
													<xsl:with-param name="schValue" select="$tscema"/>
													<xsl:with-param name="forValue" select="$ttype"/>
													<xsl:with-param name="topicUrl" select="$rvocurl"/>
												</xsl:call-template>
											</div>
										</xsl:if>
									</xsl:if>
									<xsl:if test="not($tscema)">
										<xsl:if test="FormalName=$ttype">
											<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
												<span style="color:#00FF00">
													<span style="font:italic">
														<xsl:value-of select="$elename"/>
													</span>
													<xsl:text> FormalName found in remote TopicSet through remote Catalog.</xsl:text>
												</span>
												<xsl:call-template name="PrintAdditionalInfo">
													<xsl:with-param name="schValue" select="$tscema"/>
													<xsl:with-param name="forValue" select="$ttype"/>
													<xsl:with-param name="topicUrl" select="$rvocurl"/>
												</xsl:call-template>
											</div>
										</xsl:if>
									</xsl:if>
								</xsl:for-each>
							</xsl:if>
						</xsl:for-each>
					</xsl:if>
				</xsl:if>
				<xsl:for-each select="Resource">
					<xsl:for-each select="DefaultVocabularyFor">
						<xsl:if test="@Context='TopicType' or @Context='TopicType/@FormalName'  or @Context='TopicType|TopicSet' or @Context='TopicType/@FormalName|TopicSet/@FormalName' or @Context='TopicSet|TopicType' or @Context='TopicSet/@FormalName|TopicType/@FormalName'">
							<xsl:variable name="vocurl" select="../Url"/>
							<xsl:for-each select="document($vocurl)//TopicSet/Topic">
								<xsl:if test="$tscema!=''">
									<xsl:if test="FormalName=$ttype and FormalName/@Scheme=$tscema">
										<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
											<span style="color:#00FF00">
												<span style="font:italic">
													<xsl:value-of select="$elename"/>
												</span>
												<xsl:text> FormalName and Scheme found in remote TopicSet.</xsl:text>
											</span>
											<xsl:call-template name="PrintAdditionalInfo">
												<xsl:with-param name="schValue" select="$tscema"/>
												<xsl:with-param name="forValue" select="$ttype"/>
												<xsl:with-param name="topicUrl" select="$vocurl"/>
											</xsl:call-template>
										</div>
									</xsl:if>
								</xsl:if>
								<xsl:if test="not($tscema)">
									<xsl:if test="FormalName=$ttype and FormalName/@Scheme=$tscema">
										<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
											<span style="color:#00FF00">
												<span style="font:italic">
													<xsl:value-of select="$elename"/>
												</span>
												<xsl:text> FormalName found in remote TopicSet.</xsl:text>
											</span>
											<xsl:call-template name="PrintAdditionalInfo">
												<xsl:with-param name="schValue" select="$tscema"/>
												<xsl:with-param name="forValue" select="$ttype"/>
												<xsl:with-param name="topicUrl" select="$vocurl"/>
											</xsl:call-template>
										</div>
									</xsl:if>
								</xsl:if>
							</xsl:for-each>
						</xsl:if>
					</xsl:for-each>
				</xsl:for-each>
				<xsl:for-each select="//TopicSet/Topic">
					<xsl:if test="TopicType/@FormalName='TopicType'">
						<xsl:if test="$tscema!=''">
							<xsl:if test="FormalName=$ttype and FormalName/@Scheme=$tscema">
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
									<span style="color:#00FF00">
										<span style="font:italic">
											<xsl:value-of select="$elename"/>
										</span>
										<xsl:text> FormalName and Scheme found in local TopicSet.</xsl:text>
									</span>
								</div>
							</xsl:if>
						</xsl:if>
						<xsl:if test="not($tscema)">
							<xsl:if test="FormalName=$ttype">
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
									<span style="color:#00FF00">
										<span style="font:italic">
											<xsl:value-of select="$elename"/>
										</span>
										<xsl:text> FormalName found in local TopicSet.</xsl:text>
									</span>
								</div>
							</xsl:if>
						</xsl:if>
					</xsl:if>
				</xsl:for-each>
			</xsl:for-each>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="$rdata!=''">
				<xsl:copy-of select="$rdata"/>
			</xsl:when>
			<xsl:otherwise>
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> FormalName not found in local or remoteTopicSet.</xsl:text>
					</span>
				</div>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:choose>
			<xsl:when test="@Vocabulary">
				<xsl:choose>
					<xsl:when test="substring(@Vocabulary,1,7)='http://' or substring(@Vocabulary,1,1)='.'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by url.</xsl:text>
							</span>
						</div>
					</xsl:when>
					<xsl:when test="substring(@Vocabulary,1,11)='urn:newsml:'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
							<span style="color:#FFBB00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by urn and cannot be checked.</xsl:text>
							</span>
						</div>
					</xsl:when>
					<xsl:when test="substring(@Vocabulary,1,1)='#'">
						<xsl:call-template name="findts">
							<xsl:with-param name="scema" select="@Scheme"/>
							<xsl:with-param name="foname" select="@FormalName"/>
							<xsl:with-param name="elename" select="name()"/>
							<xsl:with-param name="vocstr" select="substring(@Vocabulary,2,string-length(@Vocabulary)-1)"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary Pointer </xsl:text>
								<xsl:value-of select="@Vocabulary"/>
								<xsl:text> to TopicSet invalid.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
		</xsl:choose>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="Property">
		<xsl:choose>
			<xsl:when test="@Vocabulary">
				<xsl:variable name="hsceme" select="@Scheme"/>
				<xsl:variable name="hfoname" select="@FormalName"/>
				<xsl:variable name="helename" select="name()"/>
				<xsl:variable name="hvocstr" select="@Vocabulary"/>
				<xsl:choose>
					<xsl:when test="substring(@Vocabulary,1,7)='http://' or substring(@Vocabulary,1,1)='.'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by url.</xsl:text>
							</span>
						</div>
						<xsl:variable name="fndata">
							<xsl:call-template name="xvoc">
								<xsl:with-param name="scema1" select="$hsceme"/>
								<xsl:with-param name="foname1" select="$hfoname"/>
								<xsl:with-param name="elename1" select="$helename"/>
								<xsl:with-param name="vocstr1" select="$hvocstr"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:choose>
							<xsl:when test="$fndata!=''">
								<xsl:copy-of select="$fndata"/>
							</xsl:when>
							<xsl:otherwise>
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
									<span style="color:#FF0000">
										<span style="font:italic">
											<xsl:value-of select="$helename"/>
										</span>
										<xsl:text> FormalName not located in remote TopicSet.</xsl:text>
									</span>
									<xsl:call-template name="PrintAdditionalInfo">
										<xsl:with-param name="schValue" select="$hsceme"/>
										<xsl:with-param name="forValue" select="$hfoname"/>
										<xsl:with-param name="topicUrl" select="$hvocstr"/>
									</xsl:call-template>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="substring(@Vocabulary,1,11)='urn:newsml:'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
							<span style="color:#FFBB00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by urn.</xsl:text>
							</span>
						</div>
						<xsl:for-each select="//Catalog">
							<xsl:choose>
								<xsl:when test="@Href">
									<xsl:if test="substring(@Href,1,7)='http://' or substring(@Href,1,1)='.'">
										<xsl:variable name="caturl1" select="@Href"/>
										<xsl:for-each select="document($caturl1)//Catalog/Resource">
											<xsl:if test="Urn=$hvocstr">
												<xsl:variable name="turl" select="Url"/>
												<xsl:variable name="fndata1">
													<xsl:call-template name="xvoc">
														<xsl:with-param name="scema1" select="$hsceme"/>
														<xsl:with-param name="foname1" select="$hfoname"/>
														<xsl:with-param name="elename1" select="$helename"/>
														<xsl:with-param name="vocstr1" select="$turl"/>
													</xsl:call-template>
												</xsl:variable>
												<xsl:choose>
													<xsl:when test="$fndata1!=''">
														<xsl:copy-of select="$fndata1"/>
													</xsl:when>
													<xsl:otherwise>
														<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
															<span style="color:#FF0000">
																<span style="font:italic">
																	<xsl:value-of select="$helename"/>
																</span>
																<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
															</span>
															<xsl:call-template name="PrintAdditionalInfo">
																<xsl:with-param name="schValue" select="$hsceme"/>
																<xsl:with-param name="forValue" select="$hfoname"/>
																<xsl:with-param name="topicUrl" select="$turl"/>
															</xsl:call-template>
														</div>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:if>
										</xsl:for-each>
									</xsl:if>
								</xsl:when>
								<xsl:otherwise>
									<xsl:for-each select="Resource">
										<xsl:if test="Urn=$hvocstr">
											<xsl:variable name="turl" select="Url"/>
											<xsl:variable name="fndata1">
												<xsl:call-template name="xvoc">
													<xsl:with-param name="scema1" select="$hsceme"/>
													<xsl:with-param name="foname1" select="$hfoname"/>
													<xsl:with-param name="elename1" select="$helename"/>
													<xsl:with-param name="vocstr1" select="$turl"/>
												</xsl:call-template>
											</xsl:variable>
											<xsl:choose>
												<xsl:when test="$fndata1!=''">
													<xsl:copy-of select="$fndata1"/>
												</xsl:when>
												<xsl:otherwise>
													<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
														<span style="color:#FF0000">
															<span style="font:italic">
																<xsl:value-of select="$helename"/>
															</span>
															<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
														</span>
														<xsl:call-template name="PrintAdditionalInfo">
															<xsl:with-param name="schValue" select="$hsceme"/>
															<xsl:with-param name="forValue" select="$hfoname"/>
															<xsl:with-param name="topicUrl" select="$turl"/>
														</xsl:call-template>
													</div>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:if>
									</xsl:for-each>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:for-each>
					</xsl:when>
					<xsl:when test="substring(@Vocabulary,1,1)='#'">
						<xsl:call-template name="findts">
							<xsl:with-param name="scema" select="$hsceme"/>
							<xsl:with-param name="foname" select="$hfoname"/>
							<xsl:with-param name="elename" select="$helename"/>
							<xsl:with-param name="vocstr" select="substring(@Vocabulary,2,string-length(@Vocabulary)-1)"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary Pointer </xsl:text>
								<xsl:value-of select="@Vocabulary"/>
								<xsl:text> to TopicSet invalid.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates mode="isdefault2" select="parent::*">
					<xsl:with-param name="psceme" select="@Scheme"/>
					<xsl:with-param name="pfoname" select="@FormalName"/>
					<xsl:with-param name="currentele" select="name()"/>
					<xsl:with-param name="pcurrent" select="name(..)"/>
				</xsl:apply-templates>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:choose>
			<xsl:when test="@AllowedValues">
				<xsl:variable name="avsceme" select="''"/>
				<xsl:variable name="avfoname" select="@Value"/>
				<xsl:variable name="avelename">
					<xsl:value-of select="name(..)"/>
					<xsl:text>/</xsl:text>
					<xsl:value-of select="name()"/>
					<xsl:text>[@FormalName='</xsl:text>
					<xsl:value-of select="@FormalName"/>
					<xsl:text>']/@Value</xsl:text>
				</xsl:variable>
				<xsl:variable name="avvocstr" select="@AllowedValues"/>
				<xsl:choose>
					<xsl:when test="substring(@AllowedValues,1,7)='http://' or substring(@AllowedValues,1,1)='.'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> AllowedValues vocabulary has External reference by url.</xsl:text>
							</span>
						</div>
						<xsl:variable name="fvdata">
							<xsl:call-template name="xvoc">
								<xsl:with-param name="scema1" select="$avsceme"/>
								<xsl:with-param name="foname1" select="$avfoname"/>
								<xsl:with-param name="elename1" select="$avelename"/>
								<xsl:with-param name="vocstr1" select="$avvocstr"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:choose>
							<xsl:when test="$fvdata!=''">
								<xsl:copy-of select="$fvdata"/>
							</xsl:when>
							<xsl:otherwise>
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
									<span style="color:#FF0000">
										<span style="font:italic">
											<xsl:value-of select="$avelename"/>
										</span>
										<xsl:text> FormalName not located in remote TopicSet.</xsl:text>
									</span>
									<xsl:call-template name="PrintAdditionalInfo">
										<xsl:with-param name="schValue" select="$avsceme"/>
										<xsl:with-param name="forValue" select="$avfoname"/>
										<xsl:with-param name="topicUrl" select="$avvocstr"/>
									</xsl:call-template>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="substring(@AllowedValues,1,11)='urn:newsml:'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
							<span style="color:#FFBB00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> AllowedValues vocabulary has External reference by urn.</xsl:text>
							</span>
						</div>
						<xsl:for-each select="//Catalog">
							<xsl:choose>
								<xsl:when test="@Href">
									<xsl:if test="substring(@Href,1,7)='http://' or substring(@Href,1,1)='.'">
										<xsl:variable name="caturl2" select="@Href"/>
										<xsl:for-each select="document($caturl2)//Catalog/Resource">
											<xsl:if test="Urn=$avvocstr">
												<xsl:variable name="aturl" select="Url"/>
												<xsl:variable name="fvdata1">
													<xsl:call-template name="xvoc">
														<xsl:with-param name="scema1" select="$avsceme"/>
														<xsl:with-param name="foname1" select="$avfoname"/>
														<xsl:with-param name="elename1" select="$avelename"/>
														<xsl:with-param name="vocstr1" select="$aturl"/>
													</xsl:call-template>
												</xsl:variable>
												<xsl:choose>
													<xsl:when test="$fvdata1!=''">
														<xsl:copy-of select="$fvdata1"/>
													</xsl:when>
													<xsl:otherwise>
														<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
															<span style="color:#FF0000">
																<span style="font:italic">
																	<xsl:value-of select="$avelename"/>
																</span>
																<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
															</span>
															<xsl:call-template name="PrintAdditionalInfo">
																<xsl:with-param name="schValue" select="$avsceme"/>
																<xsl:with-param name="forValue" select="$avfoname"/>
																<xsl:with-param name="topicUrl" select="$aturl"/>
															</xsl:call-template>
														</div>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:if>
										</xsl:for-each>
									</xsl:if>
								</xsl:when>
								<xsl:otherwise>
									<xsl:for-each select="Resource">
										<xsl:if test="Urn=$avvocstr">
											<xsl:variable name="aturl" select="Url"/>
											<xsl:variable name="fvdata1">
												<xsl:call-template name="xvoc">
													<xsl:with-param name="scema1" select="$avsceme"/>
													<xsl:with-param name="foname1" select="$avfoname"/>
													<xsl:with-param name="elename1" select="$avelename"/>
													<xsl:with-param name="vocstr1" select="$aturl"/>
												</xsl:call-template>
											</xsl:variable>
											<xsl:choose>
												<xsl:when test="$fvdata1!=''">
													<xsl:copy-of select="$fvdata1"/>
												</xsl:when>
												<xsl:otherwise>
													<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
														<span style="color:#FF0000">
															<span style="font:italic">
																<xsl:value-of select="$avelename"/>
															</span>
															<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
														</span>
														<xsl:call-template name="PrintAdditionalInfo">
															<xsl:with-param name="schValue" select="$avsceme"/>
															<xsl:with-param name="forValue" select="$avfoname"/>
															<xsl:with-param name="topicUrl" select="$aturl"/>
														</xsl:call-template>
													</div>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:if>
									</xsl:for-each>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:for-each>
					</xsl:when>
					<xsl:when test="substring(@AllowedValues,1,1)='#'">
						<xsl:variable name="pchain">
							<xsl:choose>
								<xsl:when test="name(..)='Characteristics'">
									<xsl:text>ContentItem[MediaType/@FormalName=&#39;</xsl:text>
									<xsl:value-of select="../../MediaType/@FormalName"/>
									<xsl:text>&#39;]/</xsl:text>
									<xsl:value-of select="name(..)"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="name(..)"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>
						<xsl:call-template name="findps">
							<xsl:with-param name="foname" select="@FormalName"/>
							<xsl:with-param name="vaname" select="@Value"/>
							<xsl:with-param name="elename" select="name()"/>
							<xsl:with-param name="pelename" select="$pchain"/>
							<xsl:with-param name="vocstr" select="substring(@AllowedValues,2,string-length(@AllowedValues)-1)"/>
						</xsl:call-template>
					</xsl:when>
				</xsl:choose>
			</xsl:when>
			<xsl:when test="@ValueRef">
				<xsl:choose>
					<xsl:when test="substring(@ValueRef,1,7)='http://' or substring(@ValueRef,1,1)='.'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> ValueRef Pointer has External reference by url.</xsl:text>
							</span>
						</div>
					</xsl:when>
					<xsl:when test="substring(@ValueRef,1,11)='urn:newsml:'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
							<span style="color:#FFBB00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> ValueRef Pointer has External reference by urn and cannot be checked.</xsl:text>
							</span>
						</div>
					</xsl:when>
					<xsl:when test="substring(@ValueRef,1,1)='#'">
						<xsl:variable name="ofval">
							<xsl:choose>
								<xsl:when test="@Value">
									<xsl:value-of select="@Value"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="'*'"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>
						<xsl:call-template name="findp2s">
							<xsl:with-param name="vaname" select="$ofval"/>
							<xsl:with-param name="elename" select="name()"/>
							<xsl:with-param name="vocstr" select="substring(@ValueRef,2,string-length(@ValueRef)-1)"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Value Pointer </xsl:text>
								<xsl:value-of select="@ValueRef"/>
								<xsl:text> to TopicSet invalid.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="propid">
					<xsl:value-of select="name(..)"/>
					<xsl:text>/</xsl:text>
					<xsl:value-of select="name()"/>
					<xsl:text>[@FormalName='</xsl:text>
					<xsl:value-of select="@FormalName"/>
					<xsl:text>']/@Value</xsl:text>
				</xsl:variable>
				<xsl:if test="@Value!=''">
					<xsl:apply-templates mode="isdefault2" select="parent::*">
						<xsl:with-param name="psceme" select="''"/>
						<xsl:with-param name="pfoname" select="@Value"/>
						<xsl:with-param name="currentele" select="$propid"/>
					</xsl:apply-templates>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="Copyright|DescriptiveMetadata|RightsMetadata|TopicOccurrence|UsageRights">
		<xsl:if test="@DateAndTime">
			<xsl:call-template name="checkdate">
				<xsl:with-param name="datestr" select="@DateAndTime"/>
				<xsl:with-param name="elename" select="name()"/>
			</xsl:call-template>
		</xsl:if>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="EndDate|StartDate|Geography|Limitations|RightsHolder|UsageType">
		<xsl:if test="@DateAndTime">
			<xsl:call-template name="checkdate">
				<xsl:with-param name="datestr" select="@DateAndTime"/>
				<xsl:with-param name="elename" select="name()"/>
			</xsl:call-template>
		</xsl:if>
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template match="Format">
		<xsl:choose>
			<xsl:when test="@Vocabulary">
				<xsl:variable name="hsceme" select="@Scheme"/>
				<xsl:variable name="hfoname" select="@FormalName"/>
				<xsl:variable name="helename" select="name()"/>
				<xsl:variable name="hvocstr" select="@Vocabulary"/>
				<xsl:choose>
					<xsl:when test="substring(@Vocabulary,1,7)='http://' or substring(@Vocabulary,1,1)='.'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by url.</xsl:text>
							</span>
						</div>
						<xsl:variable name="fndata">
							<xsl:call-template name="xvoc">
								<xsl:with-param name="scema1" select="$hsceme"/>
								<xsl:with-param name="foname1" select="$hfoname"/>
								<xsl:with-param name="elename1" select="$helename"/>
								<xsl:with-param name="vocstr1" select="$hvocstr"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:choose>
							<xsl:when test="$fndata!=''">
								<xsl:copy-of select="$fndata"/>
							</xsl:when>
							<xsl:otherwise>
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
									<span style="color:#FF0000">
										<span style="font:italic">
											<xsl:value-of select="$helename"/>
										</span>
										<xsl:text> FormalName not located in remote TopicSet.</xsl:text>
									</span>
									<xsl:call-template name="PrintAdditionalInfo">
										<xsl:with-param name="schValue" select="$hsceme"/>
										<xsl:with-param name="forValue" select="$hfoname"/>
										<xsl:with-param name="topicUrl" select="$hvocstr"/>
									</xsl:call-template>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="substring(@Vocabulary,1,11)='urn:newsml:'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
							<span style="color:#FFBB00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by urn.</xsl:text>
							</span>
						</div>
						<xsl:for-each select="//Catalog">
							<xsl:choose>
								<xsl:when test="@Href">
									<xsl:if test="substring(@Href,1,7)='http://' or substring(@Href,1,1)='.'">
										<xsl:variable name="caturl1" select="@Href"/>
										<xsl:for-each select="document($caturl1)//Catalog/Resource">
											<xsl:if test="Urn=$hvocstr">
												<xsl:variable name="turl" select="Url"/>
												<xsl:value-of select="$hfoname"/>
												<xsl:variable name="fndata1">
													<xsl:call-template name="xvoc">
														<xsl:with-param name="scema1" select="$hsceme"/>
														<xsl:with-param name="foname1" select="$hfoname"/>
														<xsl:with-param name="elename1" select="$helename"/>
														<xsl:with-param name="vocstr1" select="$turl"/>
													</xsl:call-template>
												</xsl:variable>
												<xsl:choose>
													<xsl:when test="$fndata1!=''">
														<xsl:copy-of select="$fndata1"/>
													</xsl:when>
													<xsl:otherwise>
														<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
															<span style="color:#FF0000">
																<span style="font:italic">
																	<xsl:value-of select="$helename"/>
																</span>
																<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
															</span>
															<xsl:call-template name="PrintAdditionalInfo">
																<xsl:with-param name="schValue" select="$hsceme"/>
																<xsl:with-param name="forValue" select="$hfoname"/>
																<xsl:with-param name="topicUrl" select="$turl"/>
															</xsl:call-template>
														</div>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:if>
										</xsl:for-each>
									</xsl:if>
								</xsl:when>
								<xsl:otherwise>
									<xsl:for-each select="Resource">
										<xsl:if test="Urn=$hvocstr">
											<xsl:variable name="turl" select="Url"/>
											<xsl:value-of select="$hfoname"/>
											<xsl:variable name="fndata1">
												<xsl:call-template name="xvoc">
													<xsl:with-param name="scema1" select="$hsceme"/>
													<xsl:with-param name="foname1" select="$hfoname"/>
													<xsl:with-param name="elename1" select="$helename"/>
													<xsl:with-param name="vocstr1" select="$turl"/>
												</xsl:call-template>
											</xsl:variable>
											<xsl:choose>
												<xsl:when test="$fndata1!=''">
													<xsl:copy-of select="$fndata1"/>
												</xsl:when>
												<xsl:otherwise>
													<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
														<span style="color:#FF0000">
															<span style="font:italic">
																<xsl:value-of select="$helename"/>
															</span>
															<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
														</span>
														<xsl:call-template name="PrintAdditionalInfo">
															<xsl:with-param name="schValue" select="$hsceme"/>
															<xsl:with-param name="forValue" select="$hfoname"/>
															<xsl:with-param name="topicUrl" select="$turl"/>
														</xsl:call-template>
													</div>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:if>
									</xsl:for-each>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:for-each>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="findts">
							<xsl:with-param name="scema" select="$hsceme"/>
							<xsl:with-param name="foname" select="$hfoname"/>
							<xsl:with-param name="elename" select="$helename"/>
							<xsl:with-param name="vocstr" select="substring(@Vocabulary,2,string-length(@Vocabulary)-1)"/>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates mode="isdefault2" select="parent::*">
					<xsl:with-param name="psceme" select="@Scheme"/>
					<xsl:with-param name="pfoname" select="@FormalName"/>
					<xsl:with-param name="currentele" select="name()"/>
				</xsl:apply-templates>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="*" mode="isdefault2">
		<xsl:param name="psceme"/>
		<xsl:param name="pfoname"/>
		<xsl:param name="currentele"/>
		<xsl:param name="pcurrent"/>
		<xsl:choose>
			<xsl:when test="Catalog">
				<xsl:variable name="xdata">
					<xsl:if test="Catalog/@Href">
						<xsl:if test="substring(Catalog/@Href,1,7)='http://' or substring(Catalog/@Href,1,1)='.'">
							<xsl:variable name="caturl" select="Catalog/@Href"/>
							<xsl:variable name="contextmatch">
								<xsl:for-each select="document($caturl)//Catalog/Resource">
									<xsl:for-each select="DefaultVocabularyFor">
										<xsl:variable name="newsceme">
											<xsl:choose>
												<xsl:when test="not($psceme) and @Scheme">
													<xsl:value-of select="@Scheme"/>
												</xsl:when>
												<xsl:otherwise>
													<xsl:value-of select="$psceme"/>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:variable>
										<xsl:call-template name="subcontext">
											<xsl:with-param name="sctext" select="@Context"/>
											<xsl:with-param name="xcurrentele" select="$currentele"/>
											<xsl:with-param name="xpcurrent" select="$pcurrent"/>
											<xsl:with-param name="xpsceme" select="$newsceme"/>
											<xsl:with-param name="xpfoname" select="$pfoname"/>
											<xsl:with-param name="xposn" select="'remote'"/>
										</xsl:call-template>
									</xsl:for-each>
								</xsl:for-each>
							</xsl:variable>
							<xsl:if test="$contextmatch!=''">
								<xsl:copy-of select="$contextmatch"/>
							</xsl:if>
						</xsl:if>
					</xsl:if>
					<xsl:variable name="contextmatch">
						<xsl:for-each select="Catalog/Resource">
							<xsl:for-each select="DefaultVocabularyFor">
								<xsl:variable name="newsceme">
									<xsl:choose>
										<xsl:when test="not($psceme) and @Scheme">
											<xsl:value-of select="@Scheme"/>
										</xsl:when>
										<xsl:otherwise>
											<xsl:value-of select="$psceme"/>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:variable>
								<xsl:call-template name="subcontext">
									<xsl:with-param name="sctext" select="@Context"/>
									<xsl:with-param name="xcurrentele" select="$currentele"/>
									<xsl:with-param name="xpcurrent" select="$pcurrent"/>
									<xsl:with-param name="xpsceme" select="$newsceme"/>
									<xsl:with-param name="xpfoname" select="$pfoname"/>
									<xsl:with-param name="xposn" select="'local'"/>
								</xsl:call-template>
							</xsl:for-each>
						</xsl:for-each>
					</xsl:variable>
					<xsl:if test="$contextmatch!=''">
						<xsl:copy-of select="$contextmatch"/>
					</xsl:if>
				</xsl:variable>
				<xsl:choose>
					<xsl:when test="$xdata!=''">
						<xsl:copy-of select="$xdata"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:choose>
							<xsl:when test="not(parent::*)">
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
									<span style="color:#FFBB00">
										<span style="font:italic">
											<xsl:value-of select="$currentele"/>
										</span>
										<xsl:text> FormalName not referenced to any TopicSet.</xsl:text>
									</span>
									<xsl:call-template name="PrintAdditionalInfo">
										<xsl:with-param name="schValue" select="$psceme"/>
										<xsl:with-param name="forValue" select="$pfoname"/>
										<xsl:with-param name="topicUrl" select="''"/>
									</xsl:call-template>
								</div>
							</xsl:when>
							<xsl:otherwise>
								<xsl:apply-templates mode="isdefault2" select="parent::*">
									<xsl:with-param name="psceme" select="$psceme"/>
									<xsl:with-param name="pfoname" select="$pfoname"/>
									<xsl:with-param name="currentele" select="$currentele"/>
									<xsl:with-param name="pcurrent" select="$pcurrent"/>
								</xsl:apply-templates>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:when test="NewsML">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$currentele"/>
						</span>
						<xsl:text> No Default Catalog - TopicSet not found.</xsl:text>
					</span>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<xsl:if test="parent::*">
					<xsl:apply-templates mode="isdefault2" select="parent::*">
						<xsl:with-param name="psceme" select="$psceme"/>
						<xsl:with-param name="pfoname" select="$pfoname"/>
						<xsl:with-param name="currentele" select="$currentele"/>
						<xsl:with-param name="pcurrent" select="$pcurrent"/>
					</xsl:apply-templates>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="subcontext">
		<xsl:param name="sctext"/>
		<xsl:param name="xcurrentele"/>
		<xsl:param name="xpcurrent"/>
		<xsl:param name="xpsceme"/>
		<xsl:param name="xpfoname"/>
		<xsl:param name="xposn"/>
		<xsl:choose>
			<xsl:when test="contains($sctext,'|')">
				<xsl:call-template name="checkcontext">
					<xsl:with-param name="acttext" select="substring-before($sctext,'|')"/>
					<xsl:with-param name="scurrentele" select="$xcurrentele"/>
					<xsl:with-param name="spcurrent" select="$xpcurrent"/>
					<xsl:with-param name="spsceme" select="$xpsceme"/>
					<xsl:with-param name="spfoname" select="$xpfoname"/>
					<xsl:with-param name="xposn" select="$xposn"/>
				</xsl:call-template>
				<xsl:call-template name="subcontext">
					<xsl:with-param name="sctext" select="substring-after($sctext,'|')"/>
					<xsl:with-param name="xcurrentele" select="$xcurrentele"/>
					<xsl:with-param name="xpcurrent" select="$xpcurrent"/>
					<xsl:with-param name="xpsceme" select="$xpsceme"/>
					<xsl:with-param name="xpfoname" select="$xpfoname"/>
					<xsl:with-param name="xposn" select="$xposn"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="checkcontext">
					<xsl:with-param name="acttext" select="$sctext"/>
					<xsl:with-param name="scurrentele" select="$xcurrentele"/>
					<xsl:with-param name="spcurrent" select="$xpcurrent"/>
					<xsl:with-param name="spsceme" select="$xpsceme"/>
					<xsl:with-param name="spfoname" select="$xpfoname"/>
					<xsl:with-param name="sposn" select="$xposn"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="checkcontext">
		<xsl:param name="acttext"/>
		<xsl:param name="scurrentele"/>
		<xsl:param name="spcurrent"/>
		<xsl:param name="spsceme"/>
		<xsl:param name="spfoname"/>
		<xsl:param name="sposn"/>
		<xsl:variable name="eleformal">
			<xsl:value-of select="$scurrentele"/>
			<xsl:text>/@FormalName</xsl:text>
		</xsl:variable>
		<xsl:variable name="pcurrentele">
			<xsl:choose>
				<xsl:when test="$spcurrent">
					<xsl:value-of select="concat($spcurrent,'/',$scurrentele)"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$scurrentele"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="peleformal">
			<xsl:value-of select="$pcurrentele"/>
			<xsl:text>/@FormalName</xsl:text>
		</xsl:variable>
		<xsl:variable name="tcontext">
			<xsl:choose>
				<xsl:when test="substring($acttext,1,3)='.//'">
					<xsl:value-of select="substring($acttext,4,string-length($acttext)-3)"/>
				</xsl:when>
				<xsl:when test="substring($acttext,1,2)='./'">
					<xsl:value-of select="substring($acttext,3,string-length($acttext)-2)"/>
				</xsl:when>
				<xsl:when test="substring($acttext,1,2)='//'">
					<xsl:value-of select="substring($acttext,3,string-length($acttext)-2)"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$acttext"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:if test="$tcontext=$scurrentele or $tcontext=$eleformal or $tcontext=$pcurrentele or $tcontext=$peleformal">
			<xsl:variable name="rvocurl" select="../Url"/>
			<xsl:variable name="formalmatch">
				<xsl:for-each select="document($rvocurl)//TopicSet/Topic">
					<xsl:if test="$spsceme!=''">
						<xsl:if test="FormalName=$spfoname and FormalName/@Scheme=$spsceme">
							<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
								<span style="color:#00FF00">
									<span style="font:italic">
										<xsl:value-of select="$scurrentele"/>
									</span>
									<xsl:text> FormalName and Scheme found in remote TopicSet through </xsl:text>
									<xsl:value-of select="$sposn"/>
									<xsl:text> Catalog</xsl:text>
								</span>
								<xsl:call-template name="PrintAdditionalInfo">
									<xsl:with-param name="schValue" select="$spsceme"/>
									<xsl:with-param name="forValue" select="$spfoname"/>
									<xsl:with-param name="topicUrl" select="$rvocurl"/>
								</xsl:call-template>
							</div>
						</xsl:if>
					</xsl:if>
					<xsl:if test="FormalName=$spfoname and not(FormalName/@Scheme)">
						<xsl:if test="FormalName=$spfoname">
							<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
								<span style="color:#00FF00">
									<span style="font:italic">
										<xsl:value-of select="$scurrentele"/>
									</span>
									<xsl:text> FormalName found in remote TopicSet through </xsl:text>
									<xsl:value-of select="$sposn"/>
									<xsl:text> Catalog and Default Scheme</xsl:text>
								</span>
								<xsl:call-template name="PrintAdditionalInfo">
									<xsl:with-param name="schValue" select="$spsceme"/>
									<xsl:with-param name="forValue" select="$spfoname"/>
									<xsl:with-param name="topicUrl" select="$rvocurl"/>
								</xsl:call-template>
							</div>
						</xsl:if>
					</xsl:if>
				</xsl:for-each>
			</xsl:variable>
			<xsl:choose>
				<xsl:when test="$formalmatch!=''">
					<xsl:copy-of select="$formalmatch"/>
				</xsl:when>
				<xsl:otherwise>
					<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
						<span style="color:#FF0000">
							<span style="font:italic">
								<xsl:value-of select="$scurrentele"/>
							</span>
							<xsl:text> FormalName not found in remote TopicSet.</xsl:text>
						</span>
						<xsl:call-template name="PrintAdditionalInfo">
							<xsl:with-param name="schValue" select="$spsceme"/>
							<xsl:with-param name="forValue" select="$spfoname"/>
							<xsl:with-param name="topicUrl" select="$rvocurl"/>
						</xsl:call-template>
					</div>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>
	<xsl:template match="Genre|OfInterestTo|Relevance|Subject|SubjectMatter|SubjectDetail|SubjectQualifier">
		<xsl:choose>
			<xsl:when test="@Vocabulary">
				<xsl:variable name="hsceme" select="@Scheme"/>
				<xsl:variable name="hfoname" select="@FormalName"/>
				<xsl:variable name="helename" select="name()"/>
				<xsl:variable name="hvocstr" select="@Vocabulary"/>
				<xsl:choose>
					<xsl:when test="substring(@Vocabulary,1,7)='http://' or substring(@Vocabulary,1,1)='.'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by url.</xsl:text>
							</span>
						</div>
						<xsl:variable name="fndata">
							<xsl:call-template name="xvoc">
								<xsl:with-param name="scema1" select="$hsceme"/>
								<xsl:with-param name="foname1" select="$hfoname"/>
								<xsl:with-param name="elename1" select="$helename"/>
								<xsl:with-param name="vocstr1" select="$hvocstr"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:choose>
							<xsl:when test="$fndata!=''">
								<xsl:copy-of select="$fndata"/>
							</xsl:when>
							<xsl:otherwise>
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
									<span style="color:#FF0000">
										<span style="font:italic">
											<xsl:value-of select="$helename"/>
										</span>
										<xsl:text> FormalName not located in remote TopicSet.</xsl:text>
									</span>
									<xsl:call-template name="PrintAdditionalInfo">
										<xsl:with-param name="schValue" select="$hsceme"/>
										<xsl:with-param name="forValue" select="$hfoname"/>
										<xsl:with-param name="topicUrl" select="$hvocstr"/>
									</xsl:call-template>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="substring(@Vocabulary,1,11)='urn:newsml:'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
							<span style="color:#FFBB00">
								<span style="font:italic">
									<xsl:value-of select="name()"/>
								</span>
								<xsl:text> Vocabulary has External reference by urn.</xsl:text>
							</span>
						</div>
						<xsl:for-each select="//Catalog">
							<xsl:choose>
								<xsl:when test="@Href">
									<xsl:if test="substring(@Href,1,7)='http://' or substring(@Href,1,1)='.'">
										<xsl:variable name="caturl1" select="@Href"/>
										<xsl:for-each select="document($caturl1)//Catalog/Resource">
											<xsl:if test="Urn=$hvocstr">
												<xsl:variable name="turl" select="Url"/>
												<xsl:variable name="fndata1">
													<xsl:call-template name="xvoc">
														<xsl:with-param name="scema1" select="$hsceme"/>
														<xsl:with-param name="foname1" select="$hfoname"/>
														<xsl:with-param name="elename1" select="$helename"/>
														<xsl:with-param name="vocstr1" select="$turl"/>
													</xsl:call-template>
												</xsl:variable>
												<xsl:choose>
													<xsl:when test="$fndata1!=''">
														<xsl:copy-of select="$fndata1"/>
													</xsl:when>
													<xsl:otherwise>
														<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
															<span style="color:#FF0000">
																<span style="font:italic">
																	<xsl:value-of select="$helename"/>
																</span>
																<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
															</span>
															<xsl:call-template name="PrintAdditionalInfo">
																<xsl:with-param name="schValue" select="$hsceme"/>
																<xsl:with-param name="forValue" select="$hfoname"/>
																<xsl:with-param name="topicUrl" select="$turl"/>
															</xsl:call-template>
														</div>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:if>
										</xsl:for-each>
									</xsl:if>
								</xsl:when>
								<xsl:otherwise>
									<xsl:for-each select="Resource">
										<xsl:if test="Urn=$hvocstr">
											<xsl:variable name="turl" select="Url"/>
											<xsl:variable name="fndata1">
												<xsl:call-template name="xvoc">
													<xsl:with-param name="scema1" select="$hsceme"/>
													<xsl:with-param name="foname1" select="$hfoname"/>
													<xsl:with-param name="elename1" select="$helename"/>
													<xsl:with-param name="vocstr1" select="$turl"/>
												</xsl:call-template>
											</xsl:variable>
											<xsl:choose>
												<xsl:when test="$fndata1!=''">
													<xsl:copy-of select="$fndata1"/>
												</xsl:when>
												<xsl:otherwise>
													<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
														<span style="color:#FF0000">
															<span style="font:italic">
																<xsl:value-of select="$helename"/>
															</span>
															<xsl:text> FormalName not located in remote TopicSet found through Catalog.</xsl:text>
														</span>
														<xsl:call-template name="PrintAdditionalInfo">
															<xsl:with-param name="schValue" select="$hsceme"/>
															<xsl:with-param name="forValue" select="$hfoname"/>
															<xsl:with-param name="topicUrl" select="$turl"/>
														</xsl:call-template>
													</div>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:if>
									</xsl:for-each>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:for-each>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="findts">
							<xsl:with-param name="scema" select="$hsceme"/>
							<xsl:with-param name="foname" select="$hfoname"/>
							<xsl:with-param name="elename" select="$helename"/>
							<xsl:with-param name="vocstr" select="substring(@Vocabulary,2,string-length(@Vocabulary)-1)"/>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates mode="isdefault2" select="parent::*">
					<xsl:with-param name="psceme" select="@Scheme"/>
					<xsl:with-param name="pfoname" select="@FormalName"/>
					<xsl:with-param name="currentele" select="name()"/>
				</xsl:apply-templates>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:if test="@DateAndTime">
			<xsl:call-template name="checkdate">
				<xsl:with-param name="datestr" select="@DateAndTime"/>
				<xsl:with-param name="elename" select="name()"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	<!--
DateAndTime
===========
The date and (optionally) time at which a piece of metadata was assigned.

Uses the format CCYYMMDDTHHMMSS{+or-}HHMM (century, year, month, day, time
separator, hours, minutes, seconds, timezone separator, hours, minutes). If
only the Date is needed, then the substring from T onwards may be omitted.

This is the Basic Format defined by ISO 8601. CCYY is a 4-digit year number.
MM is a 2-digit month number. DD is a 2-digit day number. T is the letter 'T'.
HH is a 2-digit hour number (using a 24-hour clock). MM is a 2 digit minute
number. (Note that midnight may be represented as 2400 or 240000 on the date
of the day that is ending, or as 0000 or 000000 on the date of the day that is
beginning.)

{+or-} is the '+' character or the '-' character, and the following HHMM are
hours and minutes of offset from Universal Co-ordinated Time (UTC) as defined
by ISO 8601. If the time is being expressed in UTC, then the timezone offset
may be '+0000' or '-0000'. If the time is behind UTC, the timezone separator
is '-'. If the time is ahead of UTC the timezone separator is '+'.

Example: 10:27 p.m. in New York on 31 December 2000 would be expressed as
"20001231T222700-0500" as New York is five hours behind UTC in winter. At the
same moment in London, the date and time would be expressed as
"20010101T032700+0000" or as "20010101T00-0000" because in London it is now
3:27 a.m. on 1 January 2001. At the same moment in Paris,the date and time would
be expressed as "20010101T042700+0100", because Paris is one hour ahead of UTC
in winter and it is now 4:27 a.m. on 1 January 2001.
================================================================================

-->
	<xsl:template match="DateAndTime">
		<xsl:call-template name="checkdate">
			<xsl:with-param name="datestr" select="."/>
			<xsl:with-param name="elename" select="name()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="DateId">
		<xsl:call-template name="checkdate">
			<xsl:with-param name="datestr" select="."/>
			<xsl:with-param name="elename" select="name()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="FirstCreated">
		<xsl:call-template name="checkdate">
			<xsl:with-param name="datestr" select="."/>
			<xsl:with-param name="elename" select="name()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="ThisRevisionCreated">
		<xsl:call-template name="checkdate">
			<xsl:with-param name="datestr" select="."/>
			<xsl:with-param name="elename" select="name()"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="StatusWillChange">
		<xsl:for-each select="DateAndTime">
			<xsl:call-template name="checkdate">
				<xsl:with-param name="datestr" select="."/>
				<xsl:with-param name="elename" select="name()"/>
			</xsl:call-template>
		</xsl:for-each>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template name="checkdate">
		<xsl:param name="datestr"/>
		<xsl:param name="elename"/>
		<xsl:choose>
			<xsl:when test="string-length($datestr)=20"/>
			<xsl:when test="string-length($datestr)=15"/>
			<xsl:when test="string-length($datestr)=8"/>
			<xsl:otherwise>
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> date and time string incorrect length.</xsl:text>
					</span>
				</div>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:if test="string-length($datestr)=20">
			<xsl:if test="substring($datestr,19,2)>59 or 0>substring($datestr,19,2)">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> Offset minutes error.</xsl:text>
					</span>
				</div>
			</xsl:if>
			<xsl:if test="substring($datestr,17,2)>12 or 0>substring($datestr,17,2)">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> Offset hours error.</xsl:text>
					</span>
				</div>
			</xsl:if>
			<xsl:if test="substring($datestr,17,2)=12 and 0!=substring($datestr,19,2)">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> Offset minutes error.</xsl:text>
					</span>
				</div>
			</xsl:if>
			<xsl:choose>
				<xsl:when test="substring($datestr,16,1)='+'"/>
				<xsl:when test="substring($datestr,16,1)='-'"/>
				<xsl:otherwise>
					<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
						<span style="color:#FF0000">
							<span style="font:italic">
								<xsl:value-of select="$elename"/>
							</span>
							<xsl:text> Offset sign error (must be "+" or "-").</xsl:text>
						</span>
					</div>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
		<xsl:if test="string-length($datestr)>=15">
			<xsl:if test="substring($datestr,14,2)>59 or 0>substring($datestr,14,2)">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> Seconds error.</xsl:text>
					</span>
				</div>
			</xsl:if>
			<xsl:if test="substring($datestr,12,2)>59 or 0>substring($datestr,12,2)">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> Minutes error.</xsl:text>
					</span>
				</div>
			</xsl:if>
			<xsl:if test="substring($datestr,10,2)>24 or 0>substring($datestr,10,2)">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> Hours error.</xsl:text>
					</span>
				</div>
			</xsl:if>
			<xsl:if test="substring($datestr,10,2)=24 and (0!=substring($datestr,12,2) or 0!=substring($datestr,14,2))">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> Minutes and seconds error.</xsl:text>
					</span>
				</div>
			</xsl:if>
			<xsl:if test="substring($datestr,9,1)!='T'">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> Time separator is not "T".</xsl:text>
					</span>
				</div>
			</xsl:if>
		</xsl:if>
		<xsl:if test="substring($datestr,1,4)>2100 or 1900> substring($datestr,1,4)">
			<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
				<span style="color:#FF0000">
					<span style="font:italic">
						<xsl:value-of select="$elename"/>
					</span>
					<xsl:text> Century error.</xsl:text>
				</span>
			</div>
		</xsl:if>
		<xsl:if test="substring($datestr,3,2)>99 or 0> substring($datestr,3,2)">
			<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
				<span style="color:#FF0000">
					<span style="font:italic">
						<xsl:value-of select="$elename"/>
					</span>
					<xsl:text> Years error.</xsl:text>
				</span>
			</div>
		</xsl:if>
		<xsl:if test="substring($datestr,5,2)>12 or 0> substring($datestr,5,2)">
			<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
				<span style="color:#FF0000">
					<span style="font:italic">
						<xsl:value-of select="$elename"/>
					</span>
					<xsl:text> Months error.</xsl:text>
				</span>
			</div>
		</xsl:if>
		<xsl:variable name="mlength">
			<xsl:if test="substring($datestr,5,2)=1 or substring($datestr,5,2)=3 or substring($datestr,5,2)=5 or substring($datestr,5,2)=7 or substring($datestr,5,2)=8 or substring($datestr,5,2)=10 or substring($datestr,5,2)=12">
				<xsl:text>31</xsl:text>
			</xsl:if>
			<xsl:if test="substring($datestr,5,2)=4 or substring($datestr,5,2)=6 or substring($datestr,5,2)=9 or substring($datestr,5,2)=11">
				<xsl:text>30</xsl:text>
			</xsl:if>
			<xsl:if test="substring($datestr,5,2)=2">
				<xsl:choose>
					<xsl:when test="substring($datestr,1,4) mod 4=0">
						<xsl:text>29</xsl:text>
					</xsl:when>
					<xsl:when test="substring($datestr,1,4) mod 400=0">
						<xsl:text>29</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>28</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:if>
		</xsl:variable>
		<xsl:if test="substring($datestr,7,2) > $mlength or 0 > substring($datestr,7,2)">
			<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
				<span style="color:#FF0000">
					<span style="font:italic">
						<xsl:value-of select="$elename"/>
					</span>
					<xsl:text> Days error.</xsl:text>
				</span>
			</div>
		</xsl:if>
	</xsl:template>
	<!--
================================= formalname ===================================

FormalName
==========
A string of characters whose meaning is determined by a controlled vocabulary.

Vocabulary
==========
The Vocabulary attribute, if present, provides a pointer to a TopicSet which is
the controlled vocabulary that can be used to resolve the meaning of the
FormalName. The value of the Vocabulary attribute is an http URL or a NewsML
URN, or the # character followed by the value of the Duid attribute of the a
TopicSet in the current document.

If there is no Vocabulary attribute, then the controlled vocabulary to be used
is located by the following algorithm:
- Proceed to the parent of the current element.
- If it has a Catalog element as its immediate child, see whether that Catalog
  contains a Resource element whose DefaultVocabularyFor child contains an XPath
  pattern that is matched by the current element. If so, then the controlled
  vocabulary is the resource identified by that Resource element.
- If the parent does not meet the above condition, proceed to its parent and
  check the same condition.
- Continue until a vocabulary is found, or no further parent elements are
  available because the root element has been reached and it too fails to meet
  the condition.

If there is no Vocabulary attribute and the above algorithm fails to identify
a resource that serves as the controlled vocabulary, there is an error, which
the NewsML system may signal to the user.

The NewsML system may also signal an error if a vocabulary is successfully
identified, but it contains no item that matches the value of the FormalName
whose meaning is sought.

===============================================================================
-->
	<xsl:template name="findts">
		<xsl:param name="foname"/>
		<xsl:param name="elename"/>
		<xsl:param name="vocstr"/>
		<xsl:param name="scema"/>
		<xsl:choose>
			<xsl:when test="count(//TopicSet)='0'">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> Vocabulary Pointer to non existant TopicSet.</xsl:text>
					</span>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="numofsets">
					<xsl:value-of select="count(//TopicSet)"/>
				</xsl:variable>
				<xsl:variable name="tsfind">
					<xsl:for-each select="//TopicSet">
						<xsl:if test="@Duid=$vocstr">
							<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
								<span style="color:#00FF00">
									<span style="font:italic">
										<xsl:value-of select="$elename"/>
									</span>
									<xsl:text> Vocabulary Pointer to local TopicSet located.</xsl:text>
								</span>
							</div>
						</xsl:if>
					</xsl:for-each>
				</xsl:variable>
				<xsl:choose>
					<xsl:when test="$tsfind!=''">
						<xsl:copy-of select="$tsfind"/>
						<xsl:for-each select="//TopicSet">
							<xsl:if test="@Duid=$vocstr">
								<xsl:variable name="fnfind">
									<xsl:for-each select="Topic">
										<xsl:if test="$scema!=''">
											<xsl:if test="FormalName/@Scheme=$scema and FormalName=$foname">
												<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
													<span style="color:#00FF00">
														<span style="font:italic">
															<xsl:value-of select="$elename"/>
														</span>
														<xsl:text> FormalName and Scheme found in local TopicSet.</xsl:text>
													</span>
												</div>
											</xsl:if>
										</xsl:if>
										<xsl:if test="not($scema)">
											<xsl:if test="FormalName=$foname and not(FormalName/@Scheme)">
												<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
													<span style="color:#00FF00">
														<span style="font:italic">
															<xsl:value-of select="$elename"/>
														</span>
														<xsl:text> FormalName found in local TopicSet.</xsl:text>
													</span>
												</div>
											</xsl:if>
										</xsl:if>
									</xsl:for-each>
								</xsl:variable>
								<xsl:choose>
									<xsl:when test="$fnfind!=''">
										<xsl:copy-of select="$fnfind"/>
									</xsl:when>
									<xsl:otherwise>
										<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
											<span style="color:#FF0000">
												<span style="font:italic">
													<xsl:value-of select="$elename"/>
												</span>
												<xsl:text> FormalName not found in local TopicSet.</xsl:text>
											</span>
										</div>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:if>
						</xsl:for-each>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:value-of select="$elename"/>
								</span>
								<xsl:text> Vocabulary Pointer to local TopicSet invalid.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="findps">
		<xsl:param name="foname"/>
		<xsl:param name="vaname"/>
		<xsl:param name="elename"/>
		<xsl:param name="pelename"/>
		<xsl:param name="vocstr"/>
		<xsl:choose>
			<xsl:when test="count(//TopicSet)='0' and count(//Resource)='0'">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> AllowedValues vocabulary Pointer to non existant TopicSet or Resource.</xsl:text>
					</span>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="count(//Resource)!='0' or count(//TopicSet)!='0'">
						<xsl:for-each select="//Resource">
							<xsl:if test="@Duid=$vocstr">
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
									<span style="color:#00FF00">
										<span style="font:italic">
											<xsl:value-of select="$elename"/>
										</span>
										<xsl:text> AllowedValues vocabulary Pointer to Resource located.</xsl:text>
									</span>
								</div>
								<xsl:variable name="propid">
									<xsl:value-of select="$pelename"/>
									<xsl:text>/</xsl:text>
									<xsl:value-of select="$elename"/>
									<xsl:text>[@FormalName='</xsl:text>
									<xsl:value-of select="$foname"/>
									<xsl:text>']/@Value</xsl:text>
								</xsl:variable>
								<xsl:if test="DefaultVocabularyFor/@Context=$propid">
									<xsl:variable name="vocurl" select="Url"/>
									<xsl:variable name="rdata">
										<xsl:for-each select="document($vocurl)//TopicSet/Topic">
											<xsl:for-each select="FormalName">
												<xsl:choose>
													<xsl:when test="(.)=$vaname">
														<xsl:variable name="valscheme" select="@Scheme"/>
														<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
															<span style="color:#00FF00">
																<span style="font:italic">
																	<xsl:value-of select="$elename"/>
																</span>
																<xsl:text> Value found in remote TopicSet.</xsl:text>
															</span>
															<xsl:call-template name="PrintAdditionalInfo">
																<xsl:with-param name="schValue" select="$valscheme"/>
																<xsl:with-param name="forValue" select="$vaname"/>
																<xsl:with-param name="topicUrl" select="$vocurl"/>
															</xsl:call-template>
														</div>
													</xsl:when>
												</xsl:choose>
											</xsl:for-each>
										</xsl:for-each>
									</xsl:variable>
									<xsl:choose>
										<xsl:when test="$rdata!=''">
											<xsl:copy-of select="$rdata"/>
										</xsl:when>
										<xsl:otherwise>
											<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
												<span style="color:#FF0000">
													<span style="font:italic">
														<xsl:value-of select="$elename"/>
													</span>
													<xsl:text> Value not found in remoteTopicSet.</xsl:text>
												</span>
												<xsl:call-template name="PrintAdditionalInfo">
													<xsl:with-param name="schValue" select="''"/>
													<xsl:with-param name="forValue" select="$vaname"/>
													<xsl:with-param name="topicUrl" select="$vocurl"/>
												</xsl:call-template>
											</div>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
						<xsl:variable name="tsfind">
							<xsl:for-each select="//TopicSet">
								<xsl:if test="@Duid=$vocstr">
									<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
										<span style="color:#00FF00">
											<span style="font:italic">
												<xsl:value-of select="$elename"/>
											</span>
											<xsl:text> AllowedValues vocabulary Pointer to local TopicSet located.</xsl:text>
										</span>
									</div>
								</xsl:if>
							</xsl:for-each>
						</xsl:variable>
						<xsl:choose>
							<xsl:when test="$tsfind!=''">
								<xsl:copy-of select="$tsfind"/>
								<xsl:for-each select="//TopicSet">
									<xsl:if test="@Duid=$vocstr">
										<xsl:variable name="fnfind">
											<xsl:for-each select="Topic">
												<xsl:if test="FormalName=$vaname">
													<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
														<span style="color:#00FF00">
															<span style="font:italic">
																<xsl:value-of select="$elename"/>
															</span>
															<xsl:text> Value found in local TopicSet.</xsl:text>
														</span>
													</div>
												</xsl:if>
											</xsl:for-each>
										</xsl:variable>
										<xsl:choose>
											<xsl:when test="$fnfind!=''">
												<xsl:copy-of select="$fnfind"/>
											</xsl:when>
											<xsl:otherwise>
												<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
													<span style="color:#FF0000">
														<span style="font:italic">
															<xsl:value-of select="$elename"/>
														</span>
														<xsl:text> Value not found in local TopicSet.</xsl:text>
													</span>
												</div>
											</xsl:otherwise>
										</xsl:choose>
									</xsl:if>
								</xsl:for-each>
							</xsl:when>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="count(//Resource)!='0' and count(//TopicSet)!='0'">
						<xsl:variable name="notfound">
							<xsl:for-each select="//Resource">
								<xsl:if test="@Duid=$vocstr">
									<xsl:text>*</xsl:text>
								</xsl:if>
							</xsl:for-each>
							<xsl:for-each select="//TopicSet">
								<xsl:if test="@Duid=$vocstr">
									<xsl:text>*</xsl:text>
								</xsl:if>
							</xsl:for-each>
						</xsl:variable>
						<xsl:if test="$notfound=''">
							<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
								<span style="color:#FF0000">
									<span style="font:italic">
										<xsl:value-of select="$elename"/>
									</span>
									<xsl:text> AllowedValues pointer to Resource or local TopicSet not found.</xsl:text>
								</span>
							</div>
						</xsl:if>
					</xsl:when>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="findp2s">
		<xsl:param name="vaname"/>
		<xsl:param name="elename"/>
		<xsl:param name="vocstr"/>
		<xsl:choose>
			<xsl:when test="count(//TopicSet)='0'">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$elename"/>
						</span>
						<xsl:text> ValueRef Pointer to non existant TopicSet.</xsl:text>
					</span>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="tsfind">
					<xsl:for-each select="//Topic">
						<xsl:if test="@Duid=$vocstr">
							<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
								<span style="color:#00FF00">
									<span style="font:italic">
										<xsl:value-of select="$elename"/>
									</span>
									<xsl:text> ValueRef Pointer to local TopicSet located.</xsl:text>
								</span>
							</div>
							<xsl:choose>
								<xsl:when test="$vaname='*'">
									<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
										<span style="color:#FFBB00">
											<span style="font:italic">
												<xsl:value-of select="$elename"/>
											</span>
											<xsl:text> has No Value to check with pointer to local TopicSet.</xsl:text>
										</span>
									</div>
								</xsl:when>
								<xsl:otherwise>
									<xsl:choose>
										<xsl:when test="FormalName=$vaname">
											<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
												<span style="color:#00FF00">
													<span style="font:italic">
														<xsl:value-of select="$elename"/>
													</span>
													<xsl:text> Value in local TopicSet located.</xsl:text>
												</span>
											</div>
										</xsl:when>
										<xsl:otherwise>
											<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
												<span style="color:#FF0000">
													<span style="font:italic">
														<xsl:value-of select="$elename"/>
													</span>
													<xsl:text> Value and ValueRef Pointer in local TopicSet to not match.</xsl:text>
												</span>
											</div>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:if>
					</xsl:for-each>
				</xsl:variable>
				<xsl:choose>
					<xsl:when test="$tsfind!=''">
						<xsl:copy-of select="$tsfind"/>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:value-of select="$elename"/>
								</span>
								<xsl:text> ValueRef Pointer to local TopicSet invalid.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!--
==================================== Origin ====================================
A wrapper for all or part of the text of a piece of text, which provides a
pointer to an item of data corresponding formally to what is being described
here in natural language. The Href attribute identifies the relevant data, and
may be an http URL or a NewsML URN as described in the comment to
PublicIdentifier, optionally including a fragment identifier. Alternatively, it
can be a simple fragment identifier consisting of a # character followed by the
value of the Duid of an element in the current document.
================================================================================
-->
	<xsl:template match="Origin">
		<xsl:if test="@DateAndTime">
			<xsl:call-template name="checkdate">
				<xsl:with-param name="datestr" select="@DateAndTime"/>
				<xsl:with-param name="elename" select="name(parent::*)"/>
			</xsl:call-template>
		</xsl:if>
		<xsl:if test="@Href">
			<xsl:if test="substring(@Href,1,1)!='#'">
				<xsl:choose>
					<xsl:when test="substring(@Href,1,7)='http://' or substring(@Href,1,1)='.'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:value-of select="name(parent::*)"/>
								</span>
								<xsl:text> Origin has External reference by url.</xsl:text>
							</span>
						</div>
					</xsl:when>
					<xsl:when test="substring(@Href,1,11)='urn:newsml:'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
							<span style="color:#FFBB00">
								<span style="font:italic">
									<xsl:value-of select="name(parent::*)"/>
								</span>
								<xsl:text> Origin has External reference by urn and cannot be checked.</xsl:text>
							</span>
						</div>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:value-of select="name(parent::*)"/>
								</span>
								<xsl:text> reference </xsl:text>
								<xsl:value-of select="@Href"/>
								<xsl:text> is not a url!- Origin has invalid External reference.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:if>
			<xsl:if test="substring(@Href,1,1)='#'">
				<xsl:variable name="intvoc" select="substring(@Href,2,string-length(@Href)-1)"/>
				<xsl:choose>
					<xsl:when test="@Duid">
						<xsl:if test="@Duid=$intvoc">
							<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
								<span style="color:#FF0000">
									<span style="font:italic">
										<xsl:value-of select="name(parent::*)"/>
									</span>
									<xsl:text> Origin has Internal reference to Itself.</xsl:text>
								</span>
							</div>
						</xsl:if>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="findorigin">
							<xsl:with-param name="refvoc" select="substring(@Href,2,string-length(@Href)-1)"/>
							<xsl:with-param name="refname" select="name(parent::*)"/>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:if>
		</xsl:if>
		<xsl:apply-templates select="Origin"/>
	</xsl:template>
	<xsl:template name="findorigin">
		<xsl:param name="refvoc"/>
		<xsl:param name="refname"/>
		<xsl:variable name="omessage">
			<xsl:for-each select="//*">
				<xsl:if test="@Duid">
					<xsl:choose>
						<xsl:when test="@Duid=$refvoc">
							<xsl:text>found</xsl:text>
						</xsl:when>
						<xsl:otherwise/>
					</xsl:choose>
				</xsl:if>
			</xsl:for-each>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="$omessage=''">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:value-of select="$refname"/>
						</span>
						<xsl:text> Origin Valid Internal reference not found.</xsl:text>
					</span>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
					<span style="color:#00FF00">
						<span style="font:italic">
							<xsl:value-of select="$refname"/>
						</span>
						<xsl:text> Origin Valid Internal reference confirmed.</xsl:text>
					</span>
				</div>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!--
=================================== Catalog ====================================
A container for Resource and TopicUse elements. Resource elements map URNs to
URLs and indicate default vocabularies which apply to the formal names of
certain elements within the subtree that begins with the immediate parent of
the Catalog element. TopicUse elements indicate where in the NewsML document
certain Topics are used. The optional Href attribute provides a pointer to
a Catalog element elsewhere in this or another document. Its value consists of
a # character followed by the value of the Duid attribute of the referenced
Catalog element and preceded, if the referenced Catalog is not in the current
document, by an http URL or a NewsML URN identifying the document or NewsItem
in which the Catalog appears. If the Href attribute is present on a Catalog
element, then that element should be empty. If it contains subelements, the
NewsML system may signal an error.
================================================================================
-->
	<xsl:template match="Catalog">
		<xsl:if test="Resource">
			<xsl:if test="@Href">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
					<span style="color:#FFBB00">
						<span style="font:italic">
							<xsl:text>Catalog</xsl:text>
						</span>
						<xsl:text> has both Resources and External reference.</xsl:text>
					</span>
				</div>
			</xsl:if>
		</xsl:if>
		<xsl:if test="not(Resource)">
			<xsl:if test="@Href">
				<xsl:if test="substring(@Href,1,1)!='#'">
					<xsl:choose>
						<xsl:when test="substring(@Href,1,7)='http://' or substring(@Href,1,1)='.'">
							<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
								<span style="color:#00FF00">
									<span style="font:italic">
										<xsl:text>Catalog</xsl:text>
									</span>
									<xsl:text> has External reference by url.</xsl:text>
								</span>
							</div>
						</xsl:when>
						<xsl:when test="substring(@Href,1,11)='urn:newsml:'">
							<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
								<span style="color:#FFBB00">
									<span style="font:italic">
										<xsl:text>Catalog</xsl:text>
									</span>
									<xsl:text> has External reference by urn and cannot be checked (needs another Catalog!).</xsl:text>
								</span>
							</div>
						</xsl:when>
						<xsl:otherwise>
							<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
								<span style="color:#FF0000">
									<span style="font:italic">
										<xsl:value-of select="@Href"/>
									</span>
									<xsl:text> not a url! - </xsl:text>
									<span style="font:italic">
										<xsl:text>Catalog</xsl:text>
									</span>
									<xsl:text> has invalid External reference.</xsl:text>
								</span>
							</div>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:if>
				<xsl:if test="substring(@Href,1,1)='#'">
					<xsl:variable name="intvoc" select="substring(@Href,2,string-length(@Href)-1)"/>
					<xsl:choose>
						<xsl:when test="@Duid">
							<xsl:if test="@Duid=$intvoc">
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
									<span style="color:#FF0000">
										<span style="font:italic">
											<xsl:text>Catalog</xsl:text>
										</span>
										<xsl:text> has Internal reference to Itself.</xsl:text>
									</span>
								</div>
							</xsl:if>
						</xsl:when>
						<xsl:otherwise>
							<xsl:call-template name="findcats">
								<xsl:with-param name="refvoc" select="substring(@Href,2,string-length(@Href)-1)"/>
							</xsl:call-template>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:if>
			</xsl:if>
		</xsl:if>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template name="findcats">
		<xsl:param name="refvoc"/>
		<xsl:for-each select="//Catalog">
			<xsl:if test="@Duid">
				<xsl:choose>
					<xsl:when test="@Duid=$refvoc">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:text>Catalog</xsl:text>
								</span>
								<xsl:text> Valid Internal reference Confirmed.</xsl:text>
							</span>
						</div>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:text>Catalog</xsl:text>
								</span>
								<xsl:text> Valid Internal reference not found.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	<!--
=============================== PublicIdentifier ===============================
A public identifier (in the sense defined by the XML 1,0 Specification) for a
NewsItem. This is the NewsML URN, and must be constructed as follows:

The ProviderId is a domain name

urn:newsml:{ProviderId}:{DateId}:{NewsItemId}:{RevisionId}{RevisionId@Update}

where {x} means "the content of the x subelement of the NewsIdentifier" and
{x@y} means "the value of the y attribute of the x subelement of the
NewsIdentifier", with the exception that if the Update attribute of the
RevisionId element has its default value of N, it is omitted from the URN, and
that the Vocabulary attribute of the ProviderId element is stripped of the
substring "urn:" with which it begins. The Vocabulary attribute of ProviderId
necessarily begins with the characters "urn:" because, as stated in the
comment to the ProviderId element above, it must take the form of a URN
identifying a controlled vocabulary.

Note that the existence of this URN enables the NewsItem to be referenced
unambiguously by pointers from other XML elements or resources. Within such
pointers, if  the RevisionId, its preceding : character and its following Update
qualifier are omitted, then the pointer designates the most recent revision at
the time it is resolved.
================================================================================
-->
	<xsl:template match="PublicIdentifier">
		<xsl:variable name="genid">
			<xsl:text>urn:newsml:</xsl:text>
			<xsl:value-of select="//ProviderId"/>
			<xsl:text>:</xsl:text>
			<xsl:value-of select="//DateId"/>
			<xsl:text>:</xsl:text>
			<xsl:value-of select="//NewsItemId"/>
			<xsl:text>:</xsl:text>
			<xsl:value-of select="//RevisionId"/>
			<xsl:if test="//RevisionId/@Update!='N'">
				<xsl:value-of select="//RevisionId/@Update"/>
			</xsl:if>
		</xsl:variable>
		<xsl:if test="(.)!=$genid">
			<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
				<span style="color:#FF0000">
					<span style="font:italic">
						<xsl:value-of select="name()"/>
					</span>
					<xsl:text>  error, the value should be </xsl:text>
					<xsl:value-of select="$genid"/>
				</span>
			</div>
		</xsl:if>
		<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
			<span style="color:#FFBB00">
				<span style="font:italic">
					<xsl:value-of select="//ProviderId"/>
				</span>
				<xsl:text> domain name cannot be checked.</xsl:text>
			</span>
		</div>
	</xsl:template>
	<!--
================================== RevisionId ==================================
A positive integer indicating which Revision of a given NewsItem this is. Any
positive integer may be used, but it must always be the case that of two
instances of a NewsItem that have the same ProviderId, DateId and NewsItemId,
the one whose RevisionId has the larger value must be the more recent revision.
A RevisionId of 0 is not permitted. The PreviousRevision attribute must be
present, and its value must be equal to the content of the RevisionId element
of the NewsItem's previous revision, if there is one, and 0 if the NewsItem has
no previous revision. If the NewsItem contains an Update element or elements,
then the Update attribute must be set to U. If the NewsItem consists only of a
replacement set of NewsManagement data, then the Update attribute must be set
to A. If neither of these is the case, then the Update attribute must be set
to N.
================================================================================
-->
	<!--
==================================== Update ====================================
A modification to an existing NewsItem. This can be an insertion, replacement
or deletion. Note that the Update element cannot be used to modify the
NewsManagement or Identification element, or any of their descendants.
Modifications to these parts of the NewsItem can be made by issuing the
NewsItem under the current revision number, with only the Identification and
NewsManagement elements present. These will replace the previous Identification
and NewsManagement elements in their totality.
================================================================================
-->
	<xsl:template match="RevisionId">
		<xsl:choose>
			<xsl:when test="floor(.)!=ceiling(.) or '0'>(.)">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:text>RevisionId</xsl:text>
						</span>
						<xsl:text> value "</xsl:text>
						<span style="font:italic">
							<xsl:value-of select="."/>
						</span>
						<xsl:text>" is not a positive Integer.</xsl:text>
					</span>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<xsl:if test=".='0'">
					<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
						<span style="color:#FF0000">
							<span style="font:italic">
								<xsl:text>RevisionId value</xsl:text>
							</span>
							<xsl:text> "</xsl:text>
							<span style="font:italic">
								<xsl:value-of select="."/>
							</span>
							<xsl:text>" is Incorrect.</xsl:text>
						</span>
					</div>
				</xsl:if>
				<xsl:if test=".='1'">
					<xsl:if test="@PreviousRevision!='0'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:text>PreviousRevision</xsl:text>
								</span>
								<xsl:text> value "</xsl:text>
								<span style="font:italic">
									<xsl:value-of select="@PreviousRevision"/>
								</span>
								<xsl:text>" is Incorrect.</xsl:text>
							</span>
						</div>
					</xsl:if>
				</xsl:if>
				<xsl:if test=".>'1'">
					<xsl:variable name="revno" select="."/>
					<xsl:if test="@PreviousRevision >=$revno or @PreviousRevision='0' or floor(@PreviousRevision)!=@PreviousRevision">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:text>PreviousRevision</xsl:text>
								</span>
								<xsl:text> value "</xsl:text>
								<span style="font:italic">
									<xsl:value-of select="@PreviousRevision"/>
								</span>
								<xsl:text>" is Incorrect.</xsl:text>
							</span>
						</div>
					</xsl:if>
				</xsl:if>
				<xsl:choose>
					<xsl:when test="@Update='N'">
						<xsl:choose>
							<xsl:when test="/NewsML/NewsItem/NewsComponent/child::* or /NewsML/NewsItem/TopicSet">
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
									<span style="color:#00FF00">
										<span style="font:italic">
											<xsl:text>Update</xsl:text>
										</span>
										<xsl:text> attribute value "N" OK.</xsl:text>
									</span>
								</div>
							</xsl:when>
							<xsl:otherwise>
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
									<span style="color:#FF0000">
										<span style="font:italic">
											<xsl:text>Update</xsl:text>
										</span>
										<xsl:text> attribute value "N" should have NewsComponent with content or a TopicSet.</xsl:text>
									</span>
								</div>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:if test="/NewsML/NewsItem/NewsComponent">
							<xsl:if test="not(/NewsML/NewsItem/NewsComponent/@Duid)">
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
									<span style="color:#FFBB00">
										<xsl:text>Management of this News Item may be impossible because of missing </xsl:text>
										<span style="font:italic">
											<xsl:text>Duids.</xsl:text>
										</span>
									</span>
								</div>
							</xsl:if>
						</xsl:if>
					</xsl:when>
					<xsl:when test="@Update='U'">
						<xsl:choose>
							<xsl:when test="/NewsML/NewsItem/Update">
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
									<span style="color:#00FF00">
										<span style="font:italic">
											<xsl:text>Update</xsl:text>
										</span>
										<xsl:text> attribute value "U" OK.</xsl:text>
									</span>
								</div>
							</xsl:when>
							<xsl:otherwise>
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
									<span style="color:#FF0000">
										<span style="font:italic">
											<xsl:text>Update</xsl:text>
										</span>
										<xsl:text> Attribute value "U" should have an Update instruction as NewsItem content.</xsl:text>
									</span>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="@Update='A'">
						<xsl:choose>
							<xsl:when test="/NewsML/NewsItem/NewsComponent=''">
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
									<span style="color:#00FF00">
										<span style="font:italic">
											<xsl:text>Update</xsl:text>
										</span>
										<xsl:text> attribute value "A" OK.</xsl:text>
									</span>
								</div>
							</xsl:when>
							<xsl:otherwise>
								<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
									<span style="color:#FF0000">
										<span style="font:italic">
											<xsl:text>Update</xsl:text>
										</span>
										<xsl:text> Attribute value "A" should not have NewsComponent content with it.</xsl:text>
									</span>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:text>Update</xsl:text>
								</span>
								<xsl:text> Attribute value "</xsl:text>
								<span style="font:italic">
									<xsl:value-of select="@Update"/>
								</span>
								<xsl:text>" is Incorrect.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!--
================================ RevisionStatus ================================
Indicates the status that previous revisions now has as a result of the release
of the current revision. The optional Revision attribute is an integer, equal to
the RevisionId of the revision in question. If it is not present, then the
status applies to ALL previous revisions, without exception.
================================================================================
-->
	<xsl:template match="Instruction">
		<xsl:if test="@Vocabulary">
			<xsl:choose>
				<xsl:when test="substring(@Vocabulary,1,7)='http://' or substring(@Vocabulary,1,1)='.'">
					<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
						<span style="color:#00FF00">
							<span style="font:italic">
								<xsl:value-of select="name()"/>
							</span>
							<xsl:text> Vocabulary has External reference by url.</xsl:text>
						</span>
					</div>
				</xsl:when>
				<xsl:when test="substring(@Vocabulary,1,11)='urn:newsml:'">
					<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
						<span style="color:#FFBB00">
							<span style="font:italic">
								<xsl:value-of select="name()"/>
							</span>
							<xsl:text> Vocabulary has External reference by urn and cannot be checked.</xsl:text>
						</span>
					</div>
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="findts">
						<xsl:with-param name="scema" select="@Scheme"/>
						<xsl:with-param name="foname" select="@FormalName"/>
						<xsl:with-param name="elename" select="name()"/>
						<xsl:with-param name="vocstr" select="substring(@Vocabulary,2,string-length(@Vocabulary)-1)"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
		<xsl:if test="not(@Vocabulary)">
			<xsl:apply-templates mode="isdefault2" select="parent::*">
				<xsl:with-param name="psceme" select="@Scheme"/>
				<xsl:with-param name="pfoname" select="@FormalName"/>
				<xsl:with-param name="currentele" select="name()"/>
			</xsl:apply-templates>
		</xsl:if>
		<xsl:if test="RevisionStatus/@Revision">
			<xsl:if test="RevisionStatus/@Revision>=//RevisionId or '0'>RevisionStatus/@Revision">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<xsl:text>Status Change applied to Invalid </xsl:text>
						<span style="font:italic">
							<xsl:text>RevisionId.</xsl:text>
						</span>
					</span>
				</div>
			</xsl:if>
		</xsl:if>
		<xsl:if test="RevisionStatus/Status">
			<xsl:apply-templates select="RevisionStatus/Status"/>
			<xsl:if test="RevisionStatus/Status/@FormalName=../Status/@FormalName">
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:text>Status</xsl:text>
						</span>
						<xsl:text> of earlier Revisions not Changed.</xsl:text>
						<xsl:text> (Status=</xsl:text>
						<xsl:value-of select="../Status/@FormalName"/>
						<xsl:text>, RevisionStatus/Status=</xsl:text>
						<xsl:value-of select="RevisionStatus/Status/@FormalName"/>
						<xsl:text>)</xsl:text>
					</span>
				</div>
			</xsl:if>
		</xsl:if>
	</xsl:template>
	<!--
================================= TopicSetRef ==================================
A pointer to a TopicSet that is to be merged with the current one. The TopicSet
attribute is a pointer to the relevant TopicSet. Its value can be an http URL,
or a NewsML URN as described in the comment to PublicIdentifier, or a fragment
identifier consisting of a # character followed by the Duid of a TopicSet in the
current document. The presence of a TopicSetRef child in a TopicSet has the
effect that all the Topics in the referenced TopicSet are included by reference
within the current TopicSet. When this merging results in there exising two
FormalName grandchildren of the same TopicSet that have the same content and
the same Scheme attribute value, then the Topics whose children are in fact the
same topic, and are deemed to be merged. The merging of Topics need not be
performed physically by the system, but the meaning of the data is
exactly the same as if the merging were actually performed. Merging two
Topcis consists of creating a single Topic that contains all the children of
both, and eliminating duplicates.
================================================================================
-->
	<xsl:template match="TopicSetRef">
		<xsl:if test="@TopicSet">
			<xsl:if test="substring(@TopicSet,1,1)!='#'">
				<xsl:choose>
					<xsl:when test="substring(@TopicSet,1,7)='http://' or substring(@TopicSet,1,1)='.'">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:text>TopicSetRef</xsl:text>
								</span>
								<xsl:text> has External reference by url.</xsl:text>
							</span>
						</div>
					</xsl:when>
					<xsl:when test="substring(@TopicSet,1,11)='urn:newsml:'">
						<xsl:variable name="tsref" select="@TopicSet"/>
						<xsl:for-each select="//Catalog">
							<xsl:for-each select="Resource">
								<xsl:if test="Urn=$tsref">
									<xsl:choose>
										<xsl:when test="Url">
											<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
												<span style="color:#00FF00">
													<span style="font:italic">
														<xsl:text>TopicSetRef</xsl:text>
													</span>
													<xsl:text> has External reference by url through a Catalog Resource element.</xsl:text>
												</span>
											</div>
										</xsl:when>
										<xsl:otherwise>
											<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FFBB00;padding:0.2em">
												<span style="color:#FFBB00">
													<span style="font:italic">
														<xsl:text>TopicSetRef</xsl:text>
													</span>
													<xsl:text> has External reference by urn and cannot be checked.</xsl:text>
												</span>
											</div>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:if>
							</xsl:for-each>
						</xsl:for-each>
					</xsl:when>
					<xsl:otherwise>
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:value-of select="@TopicSet"/>
								</span>
								<xsl:text> is not a url! </xsl:text>
								<span style="font:italic">
									<xsl:text>TopicSetRef</xsl:text>
								</span>
								<xsl:text> has invalid External reference.</xsl:text>
							</span>
						</div>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:if>
			<xsl:if test="substring(@TopicSet,1,1)='#'">
				<xsl:variable name="intvoc" select="substring(@TopicSet,2,string-length(@TopicSet)-1)"/>
				<xsl:choose>
					<xsl:when test="../@Duid=$intvoc">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
							<span style="color:#FF0000">
								<span style="font:italic">
									<xsl:text>TopicSetRef</xsl:text>
								</span>
								<xsl:text> has Internal reference to Itself.</xsl:text>
							</span>
						</div>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="findtops">
							<xsl:with-param name="refvoc" select="substring(@TopicSet,2,string-length(@TopicSet)-1)"/>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:if>
		</xsl:if>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template name="findtops">
		<xsl:param name="refvoc"/>
		<xsl:variable name="tsref">
			<xsl:for-each select="//TopicSet">
				<xsl:choose>
					<xsl:when test="@Duid=$refvoc">
						<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#00FF00;padding:0.2em">
							<span style="color:#00FF00">
								<span style="font:italic">
									<xsl:text>TopicSetRef</xsl:text>
								</span>
								<xsl:text> Valid Internal reference Confirmed.</xsl:text>
							</span>
						</div>
					</xsl:when>
					<xsl:otherwise/>
				</xsl:choose>
			</xsl:for-each>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="$tsref!=''">
				<xsl:copy-of select="$tsref"/>
			</xsl:when>
			<xsl:otherwise>
				<div style="margin:1em;border-style:solid double;border-width:thick;border-color:#FF0000;padding:0.2em">
					<span style="color:#FF0000">
						<span style="font:italic">
							<xsl:text>TopicSetRef</xsl:text>
						</span>
						<xsl:text> Valid Internal reference not found.</xsl:text>
					</span>
				</div>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
