<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xslout="bla"
	version="1.0">

<xsl:output method="html" indent="yes"/>

<xsl:variable name="maintainerName" select="'David A. Clunie'"/>
<xsl:variable name="maintainerEMail" select="'dclunie@dclunie.com'"/>
<xsl:variable name="modificationDate" select="document('date.txt')/date"/>

<xsl:variable name="odtIconURL" select="'../myicons/images/odt.png'"/>
<xsl:variable name="htmlIconURL" select="'../myicons/images/html.png'"/>
<xsl:variable name="chtmlIconURL" select="'../myicons/images/chtml.png'"/>
<xsl:variable name="pdfIconURL" select="'../myicons/images/pdf.png'"/>
<xsl:variable name="wordIconURL" select="'../myicons/images/doc.png'"/>
<xsl:variable name="xmlIconURL" select="'../myicons/images/xml.png'"/>
<xsl:variable name="zipIconURL" select="'../myicons/images/zip.png'"/>
<xsl:variable name="noWayIconURL" select="'../myicons/images/noway_small.png'"/>

<xsl:variable name="slideIconURL" select="'../myicons/images/ppt.png'"/>

<xsl:variable name="currentYear" select="/dicomStatus/editions/edition/yearCurrent"/>

<xsl:template match="dicomStatus">

<HTML>
<HEAD>
<TITLE>DICOM Standard Status</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#ff0000" TEXT="#000000" ALINK="#000000" VLINK="#52188c">
<CENTER><H1>DICOM Standard Status</H1></CENTER>
<HR/>
<P>
Maintained by <xsl:value-of select="$maintainerName"/><xsl:text> </xsl:text><A HREF="mailto:{$maintainerEMail}"><xsl:value-of select="$maintainerEMail"/></A>.
</P>
<P>
Last Updated: <xsl:value-of select="$modificationDate"/>
</P>
<HR/>
<CENTER><H2><A NAME="TableOfContents">Table Of Contents</A></H2></CENTER>
<UL>
<LI> <A HREF="#FinalSupplementsSince{$currentYear}">Final Text Supplements additional to <xsl:value-of select="$currentYear"/> Base Standard</A></LI>
<LI> <A HREF="#SupplementsWaitingForCodesSince{$currentYear}">Supplements additional to <xsl:value-of select="$currentYear"/> Base Standard Waiting for Codes</A></LI>
<LI> <A HREF="#FinalCPsSince{$currentYear}">Final Text Correction Proposals additional to <xsl:value-of select="$currentYear"/> Base Standard</A></LI>
<LI> <A HREF="#CPsWaitingForCodesSince{$currentYear}">Correction Proposals additional to <xsl:value-of select="$currentYear"/> Base Standard Waiting for Codes</A></LI>
<xsl:apply-templates select="editions" mode="tableOfContents"/>
<LI> <A HREF="#SupplementsByNumber">Supplements - By Number</A></LI>
<LI> <A HREF="#CPsByNumber">Correction Proposals - By Number</A></LI>
</UL>
<HR/>
<P>At any point in time the official standard consists of the most recently dated edition of the base
standard (currently <A HREF="#BaseStandard{$currentYear}"><xsl:value-of select="$currentYear"/></A>) PLUS
all the <A HREF="#FinalSupplementsSince{$currentYear}">supplements</A>
and <A HREF="#FinalCPsSince{$currentYear}">correction items</A> that
have been approved as Final Text.</P>
<P>The PDF versions are the official documents; other formats (such as DocBook, HTML, Word and ODT) are also made
available for the convenience of implementors who may need to extract machine-readable content, or copy tables and sections of text, but when
a discrepancy exists, the PDF form is authoritative.</P>
<HR/>
<xsl:apply-templates select="supplements" mode="changesToCurrent"/>
<HR/>
<xsl:apply-templates select="supplements" mode="waitForCodes"/>
<HR/>
<xsl:apply-templates select="cps" mode="changesToCurrent"/>
<HR/>
<xsl:apply-templates select="cps" mode="waitForCodes"/>
<HR/>
<xsl:apply-templates select="editions" mode="body"/>

<xsl:apply-templates select="supplements" mode="all"/>
<HR/>
<xsl:apply-templates select="cps" mode="all"/>
<HR/>
<CENTER><P>File icons from the <A HREF="http://www.splitbrain.org/projects/file_icons">splitbrain.org file icon community project</A>.</P></CENTER>
<HR/>
<CENTER><P><A HREF="mailto:{$maintainerEMail}">Feedback</A></P></CENTER>
</BODY>
</HTML>
</xsl:template>



<xsl:template match="editions" mode="tableOfContents">
	<xsl:apply-templates select="edition" mode="tableOfContents"/>

</xsl:template>

<xsl:template match="editions" mode="body">
	<xsl:apply-templates select="edition" mode="body"/>

</xsl:template>


<xsl:template match="edition" mode="tableOfContents">
	<xsl:choose>
		<xsl:when test="count(yearCurrent) &gt; 0">
			<LI> <A HREF="#BaseStandard{$currentYear}">Base Standard - <xsl:value-of select="$currentYear"/></A></LI>
		</xsl:when>
		<xsl:when test="count(yearFrom) &gt; 0">
			<LI> <A HREF="#DiffsStandard{yearFrom}{yearTo}">Differences in Base Standard - <xsl:value-of select="yearFrom"/> to <xsl:value-of select="yearTo"/></A></LI>
		</xsl:when>
		<xsl:when test="count(yearAcrNema) &gt; 0">
			<LI> <A HREF="#AcrNema{yearAcrNema}">ACR-NEMA - <xsl:value-of select="yearAcrNema"/></A></LI>
		</xsl:when>
	</xsl:choose>
</xsl:template>


<xsl:template match="edition" mode="body">
	<xsl:choose>
		<xsl:when test="count(yearCurrent) &gt; 0">
			<CENTER><H2><A NAME="BaseStandard{yearCurrent}">Base Standard - <xsl:value-of select="yearCurrent"/></A></H2></CENTER>
		</xsl:when>
		<xsl:when test="count(yearFrom) &gt; 0">
			<CENTER><H2><A NAME="DiffsStandard{yearFrom}{yearTo}">Differences in Base Standard - <xsl:value-of select="yearFrom"/> to <xsl:value-of select="yearTo"/></A></H2></CENTER>
		</xsl:when>
		<xsl:when test="count(yearAcrNema) &gt; 0">
			<CENTER><H2><A NAME="AcrNema{yearAcrNema}">ACR-NEMA - <xsl:value-of select="yearAcrNema"/></A></H2></CENTER>
		</xsl:when>
	</xsl:choose>
	
	<xsl:if test="count(readMeLink)">
		<CENTER>
		<TABLE BORDER="0">
		<TR><TD><A HREF="{readMeLink}.pdf"><IMG SRC="{$pdfIconURL}" ALT="PDF" BORDER="0"/></A></TD><TD>Release Notes</TD></TR>
		</TABLE>
		</CENTER>
	</xsl:if>
	<xsl:apply-templates select="parts"/>
	<HR/>
</xsl:template>


<xsl:template match="parts">
<CENTER>
<TABLE BORDER="0">
<TR><TH ALIGN="CENTER">Part</TH><TH>Title</TH><TH ALIGN="CENTER">Document</TH></TR>
<xsl:apply-templates select="part"/>
</TABLE>
</CENTER>
</xsl:template>


<xsl:template match="supplements" mode="changesToCurrent">
<CENTER><H2><A NAME="FinalSupplementsSince{$currentYear}">Final Text Supplements additional to <xsl:value-of select="$currentYear"/> Base Standard</A></H2></CENTER>
<CENTER>
<TABLE BORDER="0">
<TR><TH ALIGN="LEFT">Supplement</TH><TH ALIGN="LEFT">Affected</TH><TH ALIGN="LEFT">Title</TH><TH ALIGN="CENTER">Status</TH><TH ALIGN="CENTER">Applies To</TH><TH ALIGN="CENTER">Document</TH></TR>
<xsl:apply-templates select="supplement" mode="changesToCurrent"/>
</TABLE>
</CENTER>
</xsl:template>


<xsl:template match="supplements" mode="waitForCodes">
<CENTER><H2><A NAME="SupplementsWaitingForCodesSince{$currentYear}">Supplements additional to <xsl:value-of select="$currentYear"/> Base Standard Waiting for Codes</A></H2></CENTER>
<CENTER>
<TABLE BORDER="0">
<TR><TH ALIGN="LEFT">Supplement</TH><TH ALIGN="LEFT">Affected</TH><TH ALIGN="LEFT">Title</TH><TH ALIGN="CENTER">Status</TH><TH ALIGN="CENTER">Applies To</TH><TH ALIGN="CENTER">Document</TH></TR>
<xsl:apply-templates select="supplement" mode="waitForCodes"/>
</TABLE>
</CENTER>
</xsl:template>


<xsl:template match="supplements" mode="all">
<CENTER><H2><A NAME="SupplementsByNumber">Supplements - By Number</A></H2></CENTER>
<CENTER>
<TABLE BORDER="0">
<TR><TH ALIGN="LEFT">Supplement</TH><TH ALIGN="LEFT">Affected</TH><TH ALIGN="LEFT">Title</TH><TH ALIGN="CENTER">Status</TH><TH ALIGN="CENTER">Applies To</TH><TH ALIGN="CENTER">Document</TH></TR>
<xsl:apply-templates select="supplement" mode="all"/>
</TABLE>
</CENTER>
</xsl:template>


<xsl:template match="cps" mode="changesToCurrent">
<CENTER><H2><A NAME="FinalCPsSince{$currentYear}">Final Text Correction Proposals additional to <xsl:value-of select="$currentYear"/> Base Standard</A></H2></CENTER>
<CENTER>
<TABLE BORDER="0">
<TR><TH ALIGN="LEFT">Correction</TH><TH ALIGN="LEFT">Affected</TH><TH>Title</TH><TH ALIGN="CENTER">Status</TH><TH ALIGN="CENTER">Applies To</TH><TH ALIGN="CENTER">Document</TH></TR>
<xsl:apply-templates select="cp" mode="changesToCurrent"/>
</TABLE>
</CENTER>
</xsl:template>


<xsl:template match="cps" mode="waitForCodes">
<CENTER><H2><A NAME="CPsWaitingForCodesSince{$currentYear}">Correction Proposals additional to <xsl:value-of select="$currentYear"/> Base Standard Waiting for Codes</A></H2></CENTER>
<CENTER>
<TABLE BORDER="0">
<TR><TH ALIGN="LEFT">Correction</TH><TH ALIGN="LEFT">Affected</TH><TH>Title</TH><TH ALIGN="CENTER">Status</TH><TH ALIGN="CENTER">Applies To</TH><TH ALIGN="CENTER">Document</TH></TR>
<xsl:apply-templates select="cp" mode="waitForCodes"/>
</TABLE>
</CENTER>
</xsl:template>


<xsl:template match="cps" mode="all">
<CENTER><H2><A NAME="CPsByNumber">Correction Proposals - By Number</A></H2></CENTER>
<CENTER>
<TABLE BORDER="0">
<TR><TH ALIGN="LEFT">Correction</TH><TH ALIGN="LEFT">Affected</TH><TH>Title</TH><TH ALIGN="CENTER">Status</TH><TH ALIGN="CENTER">Applies To</TH><TH ALIGN="CENTER">Document</TH></TR>
<xsl:apply-templates select="cp" mode="all"/>
</TABLE>
</CENTER>
</xsl:template>


<xsl:template match="part">
	<TR>
		<TD ALIGN="LEFT"><A NAME="{number}"><xsl:value-of select="number"/></A></TD>
		<TD><xsl:value-of select="title"/></TD>
		<TD ALIGN="CENTER">
			<xsl:choose>
				<xsl:when test="count(../../baseLink) &gt; 0">
					<A HREF="{../../baseLink}/output/pdf/{basename}.pdf"><IMG SRC="{$pdfIconURL}" ALT="PDF" BORDER="0"/></A>
					<A HREF="{../../baseLink}/output/html/{basename}.html"><IMG SRC="{$htmlIconURL}" ALT="HTML" BORDER="0"/></A>
					<A HREF="{../../baseLink}/output/chtml/{basename}/{number}.html"><IMG SRC="{$chtmlIconURL}" ALT="CHTML" BORDER="0"/></A>
					<A HREF="{../../baseLink}/output/docx/{basename}.docx"><IMG SRC="{$wordIconURL}" ALT="DOCX" BORDER="0"/></A>
					<A HREF="{../../baseLink}/output/odt/{basename}.odt"><IMG SRC="{$odtIconURL}" ALT="DOCX" BORDER="0"/></A>
					<A HREF="{../../baseLink}/source/docbook/{basename}/"><IMG SRC="{$xmlIconURL}" ALT="XML" BORDER="0"/></A>
					
				</xsl:when>
				<xsl:when test="count(link) &gt; 0">
					<A HREF="{link}.pdf"><IMG SRC="{$pdfIconURL}" ALT="PDF" BORDER="0"/></A>
				</xsl:when>
			</xsl:choose>
		</TD>
	</TR>
</xsl:template>


<xsl:template match="supplement" mode="changesToCurrent">
	<xsl:variable name="applyto" select="applyto"/>
	<xsl:if test="$applyto=$currentYear">
		<xsl:call-template name="doSupplement"/>
	</xsl:if>
</xsl:template>

<xsl:template match="supplement" mode="waitForCodes">
	<xsl:variable name="status" select="status"/>
	<xsl:if test="$status='Wait for Codes'">
		<xsl:call-template name="doSupplement"/>
	</xsl:if>
</xsl:template>

<xsl:template match="supplement" mode="all">
	<xsl:call-template name="doSupplement"/>
</xsl:template>

<xsl:template name="doSupplement">
	<TR>
		<TD ALIGN="LEFT"><A NAME="Supplement{number}">Supp <xsl:value-of select="number"/></A></TD>
		<TD ALIGN="LEFT"><xsl:apply-templates select="partsref"/></TD>
		<TD><xsl:value-of select="title"/></TD>
		<TD ALIGN="CENTER">
			<xsl:value-of select="status"/>
			<xsl:call-template name="doAlternateReference"/>
		</TD>
		<TD ALIGN="CENTER"><xsl:value-of select="applyto"/></TD>
		<TD ALIGN="CENTER">
		<xsl:choose>
			<xsl:when test="count(link) &gt; 0">
				<A HREF="{link}.pdf"><IMG SRC="{$pdfIconURL}" ALT="PDF" BORDER="0"/></A>
				<xsl:if test="count(hasWord) &gt; 0">
					<A HREF="{link}.doc"><IMG SRC="{$wordIconURL}" ALT="DOC" BORDER="0"/></A>
				</xsl:if>
				<xsl:if test="count(hasWordX) &gt; 0">
					<A HREF="{link}.docx"><IMG SRC="{$wordIconURL}" ALT="DOCX" BORDER="0"/></A>
				</xsl:if>
				<xsl:if test="count(hasZip) &gt; 0">
					<A HREF="{link}.zip"><IMG SRC="{$zipIconURL}" ALT="ZIP" BORDER="0"/></A>
				</xsl:if>
				<xsl:if test="count(hasDocBook) &gt; 0">
					<A HREF="{link}.xml"><IMG SRC="{$xmlIconURL}" ALT="XML" BORDER="0"/></A>
				</xsl:if>
			</xsl:when>
			<xsl:otherwise>
				<IMG SRC="{$noWayIconURL}" ALT="PDF" BORDER="0"/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:choose>
			<xsl:when test="count(slidelink) &gt; 0">
				<A HREF="{slidelink}"><IMG SRC="{$slideIconURL}" ALT="SLIDE" BORDER="0"/></A>
			</xsl:when>
		</xsl:choose>
		</TD>
	</TR>

</xsl:template>

<xsl:template match="cp" mode="changesToCurrent">
	<xsl:variable name="applyto" select="applyto"/>
	<xsl:variable name="status" select="status"/>
	<xsl:if test="$applyto=$currentYear">
		<xsl:call-template name="doCP"/>
	</xsl:if>
</xsl:template>

<xsl:template match="cp" mode="waitForCodes">
	<xsl:variable name="status" select="status"/>
	<xsl:if test="$status='Wait for Codes'">
		<xsl:call-template name="doCP"/>
	</xsl:if>
</xsl:template>

<xsl:template match="cp" mode="all">
	<xsl:call-template name="doCP"/>
</xsl:template>

<xsl:template name="doCP">
	<TR>
		<TD ALIGN="LEFT"><A NAME="CP{number}">CP <xsl:value-of select="number"/></A></TD>
		<TD ALIGN="LEFT"><xsl:apply-templates select="partsref"/></TD>
		<TD><xsl:value-of select="title"/></TD>
		<TD ALIGN="CENTER">
			<xsl:value-of select="status"/>
			<xsl:call-template name="doAlternateReference"/>
		</TD>
		<TD ALIGN="CENTER"><xsl:value-of select="applyto"/></TD>
		<TD ALIGN="CENTER">
		<xsl:choose>
			<xsl:when test="count(link) &gt; 0">
				<A HREF="{link}.pdf"><IMG SRC="{$pdfIconURL}" ALT="PDF" BORDER="0"/></A>
				<xsl:if test="count(hasWord) &gt; 0">
					<A HREF="{link}.doc"><IMG SRC="{$wordIconURL}" ALT="DOC" BORDER="0"/></A>
				</xsl:if>
				<xsl:if test="count(hasWordX) &gt; 0">
					<A HREF="{link}.docx"><IMG SRC="{$wordIconURL}" ALT="DOCX" BORDER="0"/></A>
				</xsl:if>
				<xsl:if test="count(hasDocBook) &gt; 0">
					<A HREF="{link}.xml"><IMG SRC="{$xmlIconURL}" ALT="XML" BORDER="0"/></A>
				</xsl:if>
			</xsl:when>
			<xsl:otherwise>
				<IMG SRC="{$noWayIconURL}" ALT="PDF" BORDER="0"/>
			</xsl:otherwise>
		</xsl:choose>
		</TD>
	</TR>

</xsl:template>

<xsl:template name="doAlternateReference">
			<xsl:if test="count(seeCP) &gt; 0">
				<BR/><A HREF="#CP{seeCP}">See CP <xsl:value-of select="seeCP"/></A>
			</xsl:if>
			<xsl:if test="count(seeSupplement) &gt; 0">
				<BR/><A HREF="#Supplement{seeSupplement}">See Supp <xsl:value-of select="seeSupplement"/></A>
			</xsl:if>
</xsl:template>


<xsl:template match="partsref">
	<xsl:choose>
	<xsl:when test="count(part)=1">
		Part <xsl:value-of select="partref"/>
	</xsl:when>
	<xsl:otherwise>
		Parts<xsl:for-each select="partref">
			<xsl:choose>
			<xsl:when test="position()=1">
				<xsl:call-template name="doPartref"><xsl:with-param name="delimiter" select="' '"/></xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="doPartref"><xsl:with-param name="delimiter" select="','"/></xsl:call-template>
			</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template name="doPartref">
	<xsl:param name="delimiter"/>
	<xsl:value-of select="$delimiter"/><xsl:value-of select="."/>
</xsl:template>




</xsl:stylesheet>
