<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template name="replace" match="text()" mode="replace">
		<xsl:param name="str" select="."/>
		<xsl:param name="search-for" select="'&#xA;'"/>
		<xsl:param name="replace-with">
			<xsl:element name="BR"/>
			<xsl:text>&#xA;</xsl:text>
		</xsl:param>
		<xsl:choose>
			<xsl:when test="contains($str, $search-for)">
				<xsl:value-of select="substring-before($str, $search-for)"/>
				<xsl:copy-of select="$replace-with"/>
				<xsl:call-template name="replace">
					<xsl:with-param name="str"
						select="substring-after($str, $search-for)"/>
					<xsl:with-param name="search-for" select="$search-for"/>
					<xsl:with-param name="replace-with" select="$replace-with"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$str"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="/">
		<html>
			<head>
				<link rel="stylesheet" type="text/css" href="%ServerUrl%/StorageServer/Fetch.aspx?BaseName=%BaseName%&amp;TransformID=464D8B6E-5A2F-4BFD-A293-631C813DDF56"/>
				<title><xsl:value-of select="Data/ProcessInstanceWWF[1]/MainInfo/@Name"/></title>
			</head>
			<body>
				<span class="header">
					<xsl:value-of select="Data/ProcessInstanceWWF[1]/MainInfo/@Name"/>
				</span>
				<br/>				
				<span class="header2">WWF process instance information</span>
				<table border="0" width="100%">
					<tr>
						<td class="fieldheader" width="25%">Name:</td>
						<td colspan="3"><xsl:value-of select="Data/ProcessInstanceWWF[1]/MainInfo/@Name"/></td>
					</tr>
					<tr>
						<td class="fieldheader" width="25%">Description:</td>
						<td colspan="3">
							<xsl:call-template name="replace">
								<xsl:with-param name="str" select="Data/ProcessInstanceWWF[1]/MainInfo/@Description"/>
							</xsl:call-template>
						</td>
					</tr>
					<tr>
						<td class="fieldheader" width="25%">Creation date:</td>
						<td width="25%"><xsl:value-of select="translate(Data/ProcessInstanceWWF[1]/@CreationDateTime, 'T', ' ')"/></td>
						<td class="fieldheader" width="25%">Modification date:</td>
						<td width="25%"><xsl:value-of select="translate(Data/ProcessInstanceWWF[1]/@ChangeDateTime, 'T', ' ')"/></td>
					</tr>
					<tr>
						<td class="fieldheader" width="25%">Author:</td>
						<td width="25%"><xsl:value-of select="Data/ProcessSettings[1]/MainInfo/@AuthorLastName"/><xsl:if test="string-length(Data/ProcessSettings[1]/MainInfo/@AuthorLastName)!=0"> </xsl:if><xsl:value-of select="Data/ProcessSettings[1]/MainInfo/@AuthorFirstName"/><xsl:if test="string-length(Data/ProcessSettings[1]/MainInfo/@AuthorFirstName)!=0"> </xsl:if><xsl:value-of select="Data/ProcessSettings[1]/MainInfo/@AuthorMiddleName"/></td>
						<td class="fieldheader" width="25%">Responsible:</td>
						<td width="25%"><xsl:value-of select="Data/ProcessSettings[1]/MainInfo/@ResponsibleDisplayValue"/></td>
					</tr>
					<tr>
						<td class="fieldheader" width="25%">Instance folder:</td>
						<td width="25%"><xsl:value-of select="Data/ProcessSettings[1]/MainInfo/@InstanceFolderName"/></td>
						<td class="fieldheader" width="25%">After finish behavior:</td>
						<td width="25%">
							<xsl:choose>
								<xsl:when test="Data/ProcessSettings[1]/MainInfo/@AfterFinishBehavior=1">Delete process</xsl:when>
								<xsl:when test="Data/ProcessSettings[1]/MainInfo/@AfterFinishBehavior=3">Delete process permanent</xsl:when>
								<xsl:when test="Data/ProcessSettings[1]/MainInfo/@AfterFinishBehavior=4">Archive process</xsl:when>
								<xsl:when test="Data/ProcessSettings[1]/MainInfo/@AfterFinishBehavior=36">Archive process with delay</xsl:when>
								<xsl:otherwise>Do nothing</xsl:otherwise>
							</xsl:choose>
						</td>
					</tr>
				</table>
				<br/>												
				<xsl:for-each select="Data/ProcessInstanceWWF[1]/Variables/VariablesRow">
					<xsl:sort select="@DisplayName"/>
					<xsl:if test="position()=1">
						<xsl:text disable-output-escaping="yes">
							&lt;span class="header2"&gt;WWF process instance variables&lt;/span&gt;
							&lt;table border="0" cellpadding="0" cellspacing="0" style="BORDER-COLLAPSE: collapse" bordercolor="black" width="100%"&gt;
								&lt;tr&gt;
									&lt;th class="tableheader" align="left"&gt;Name&lt;/th&gt;
									&lt;th class="tableheader" align="left"&gt;Value&lt;/th&gt;
								&lt;/tr&gt;
						</xsl:text>
					</xsl:if>
					<tr>
						<td class="field" width="50%"><xsl:value-of select="@DisplayName"/></td>
						<td class="field" width="50%"><xsl:value-of select="@DisplayValue"/></td>
					</tr>
					<xsl:if test="position()=last()">
						<xsl:text disable-output-escaping="yes">
							&lt;/table&gt;
							&lt;br/&gt;
						</xsl:text>
					</xsl:if>
				</xsl:for-each>
				<br/>												

				<p class="smalltext">
				In order to change the printing template, edit Print Template for the WWF Process instance card type or create a new one based on this template.
				<br>DocsVision © 2002-2009. All rights reserved.</br>
				</p>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>
