<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="DAV:" xmlns:y="SAP:">
  <xsl:output method='html'/>
  
  <xsl:param name="resourceurl"/>
  <xsl:param name="resourcename"/>
  <xsl:param name="propertiesurl"/>    
  <xsl:param name="feedbackurl"/>    
  <xsl:param name="approveurl"/>  
  <xsl:param name="rejecturl"/>  
  <xsl:param name="stepname"/>  
  <xsl:param name="righttoleft"/>

  <xsl:template match="/">
  <xsl:output encoding="UTF-8" />

<xsl:comment xml:space="preserve">

<xsl:apply-templates select="notification/greeting/textspan"><xsl:with-param name="outputFormat" select="'plaintext'"/></xsl:apply-templates>

<xsl:apply-templates select="notification/eventinfo/textspan[@pEventid='span1']"><xsl:with-param name="outputFormat" select="'plaintext'"/></xsl:apply-templates>

<xsl:apply-templates select="notification/eventinfo/textspan[@pEventid='span2']"><xsl:with-param name="outputFormat" select="'plaintext'"/></xsl:apply-templates>

<xsl:apply-templates select="notification/eventinfo/textspan[@pEventid='span3']"><xsl:with-param name="outputFormat" select="'plaintext'"/></xsl:apply-templates>

   1. <xsl:apply-templates select="notification/eventinfo/textspan[@pEventid='span4']"><xsl:with-param name="outputFormat" select="'plaintext'"/></xsl:apply-templates> 
   2. <xsl:apply-templates select="notification/eventinfo/textspan[@pEventid='span5']"><xsl:with-param name="outputFormat" select="'plaintext'"/></xsl:apply-templates>

<xsl:apply-templates select="notification/warning/textspan"><xsl:with-param name="outputFormat" select="'plaintext'"/></xsl:apply-templates>
<xsl:apply-templates select="notification/txtwarning/textspan"><xsl:with-param name="outputFormat" select="'plaintext'"/></xsl:apply-templates>

</xsl:comment>

  <html><xsl:if test="$righttoleft='true'"><xsl:attribute name="dir">rtl</xsl:attribute></xsl:if>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
      <title><xsl:apply-templates select="notification/title/textspan"/></title>
    </head>
    <body style="font-family:Arial,sans-serif; font-size:small">
      <b><xsl:apply-templates select="notification/greeting/textspan"/></b><hr/>
      <xsl:apply-templates select="notification/eventinfo/textspan[@pEventid='span1']"/><p/>
      <xsl:apply-templates select="notification/eventinfo/textspan[@pEventid='span2']"/><p/>
      <xsl:apply-templates select="notification/eventinfo/textspan[@pEventid='span3']"/><br/>
	  <ol type="1">
	  	  <li><xsl:apply-templates select="notification/eventinfo/textspan[@pEventid='span4']"/><br/></li>
      	  <li><xsl:apply-templates select="notification/eventinfo/textspan[@pEventid='span5']"/></li>
	  </ol>
	  <p/><hr/><small><xsl:apply-templates select="notification/warning/textspan"/></small><p/>
    </body>
  </html>
  </xsl:template>

 
  <xsl:template match="textspan">
    <xsl:param name="outputFormat" select="'HTML'"/>
	<xsl:apply-templates select="resourcename|resourceurl|propertiesurl|feedbackurl|approveurl|rejecturl|stepname|resourcelink|propertieslink|feedbacklink|approvelink|rejectlink|text()"><xsl:with-param name="outputFormat" select="$outputFormat"/></xsl:apply-templates>
  </xsl:template>
  
  <xsl:template match="text()">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="."/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="."/></xsl:if>
  </xsl:template>

  <xsl:template match="resourcename">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$resourcename"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$resourcename"/></xsl:if>
  </xsl:template>

  <xsl:template match="resourceurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$resourceurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$resourceurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="propertiesurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$propertiesurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$propertiesurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="feedbackurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$feedbackurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$feedbackurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="approveurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$approveurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$approveurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="rejecturl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$rejecturl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$rejecturl"/></xsl:if>
  </xsl:template>

  <xsl:template match="resourcelink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$resourceurl}"><xsl:attribute name="title"><xsl:value-of select="$resourcename"/></xsl:attribute><xsl:value-of select="$resourcename"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="$resourcename"/> (<xsl:value-of select="$resourceurl"/>)</xsl:if>
    <xsl:if test="$outputFormat='plaintextsms'"><xsl:value-of select="$resourcename"/></xsl:if>
  </xsl:template>

  <xsl:template match="stepname">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><b><xsl:value-of select="$stepname"/></b></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$stepname"/></xsl:if>
  </xsl:template>

  <xsl:template match="propertieslink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$propertiesurl}"><xsl:attribute name="title"><xsl:value-of select="text()"/></xsl:attribute><xsl:value-of select="text()"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="text()"/> - <xsl:value-of select="$propertiesurl"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="feedbacklink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$feedbackurl}"><xsl:attribute name="title"><xsl:value-of select="text()"/></xsl:attribute><xsl:value-of select="text()"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="text()"/> - <xsl:value-of select="$feedbackurl"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="approvelink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$approveurl}"><xsl:attribute name="title"><xsl:value-of select="text()"/></xsl:attribute><xsl:value-of select="text()"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="text()"/> (<xsl:value-of select="$approveurl"/>)</xsl:if>
  </xsl:template>
  
  <xsl:template match="rejectlink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$rejecturl}"><xsl:attribute name="title"><xsl:value-of select="text()"/></xsl:attribute><xsl:value-of select="text()"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="text()"/> (<xsl:value-of select="$rejecturl"/>)</xsl:if>
  </xsl:template>
  
</xsl:stylesheet>
