<?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="subscriptionname"/>
  <xsl:param name="notificationtext"/>
  <xsl:param name="eventid"/>
  <xsl:param name="eventname"/>
  <xsl:param name="resourcename"/>
  <xsl:param name="resourceiscollection"/>
  <xsl:param name="resourceurl"/>
  <xsl:param name="parenturl"/>
  <xsl:param name="contentaccessurl"/>
  <xsl:param name="folderaccessurl"/>
  <xsl:param name="deleteurl"/>
  <xsl:param name="administrationurl"/>
  <xsl:param name="mailto"/>
  <xsl:param name="newresourcelink"/>  
  <xsl:param name="isowner"/>
  <xsl:param name="detailsurl"/>  
  <xsl:param name="lastmodified"/>  
  <xsl:param name="lastmodifieduser"/>
  <xsl:param name="subscriptiondetailsurl"/> 
  <xsl:param name="resourceDescription"/> 
  <xsl:param name="righttoleft"/> 

  <xsl:template match="/">
  <xsl:output encoding="UTF-8" />

    <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>
        <b><xsl:apply-templates select="notification/greeting/textspan"/></b><hr/>
		  <xsl:apply-templates select="notification/eventinfo/textspan[@pEventid=$eventid and @isCollection=$resourceiscollection]"/>
		  
        <p/>
        <pre tabindex="0"><xsl:value-of select="$notificationtext"/></pre>
		<xsl:apply-templates select="notification/actioninfo/textspan[@isowner=$isowner]"/>
	    <hr/><p/>
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="textspan">
    <xsl:param name="outputFormat" select="'HTML'"/>
	<xsl:apply-templates select="notificationtext|resourcename|resourceDescription|lastmodified|lastmodifieduser|subscriptiondetailsurl|subscriptiondetailslink|newresourcelink|subscriptionname|notificationtext|eventid|eventname|parenturl|contentaccessurl|folderaccessurl|deleteurl|administrationurl|mailto|subscriptionlink|resourcelink|parentlink|deletelink|administerlink|mailtolink|detailsurl|detailslink|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="notificationtext">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$notificationtext"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$notificationtext"/></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="resourceDescription">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$resourceDescription"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$resourceDescription"/></xsl:if>
  </xsl:template>

  <xsl:template match="lastmodified">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$lastmodified"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$lastmodified"/></xsl:if>
  </xsl:template>

  <xsl:template match="lastmodifieduser">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$lastmodifieduser"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$lastmodifieduser"/></xsl:if>
  </xsl:template>

  <xsl:template match="subscriptiondetailsurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$subscriptiondetailsurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$subscriptiondetailsurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="subscriptionname">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$subscriptionname"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$subscriptionname"/></xsl:if>
  </xsl:template>

  <xsl:template match="notificationtext">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$notificationtext"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$notificationtext"/></xsl:if>
  </xsl:template>

  <xsl:template match="eventid">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$eventid"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$eventid"/></xsl:if>
  </xsl:template>

  <xsl:template match="eventname">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$eventname"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$eventname"/></xsl:if>
  </xsl:template>

  <xsl:template match="mailto">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$mailto"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$mailto"/></xsl:if>
  </xsl:template>

  <xsl:template match="parenturl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$parenturl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$parenturl"/></xsl:if>
  </xsl:template>

  <xsl:template match="contentaccessurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$contentaccessurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$contentaccessurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="folderaccessurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$folderaccessurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$folderaccessurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="deleteurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$deleteurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$deleteurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="administrationurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$administrationurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$administrationurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="detailsurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$detailsurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$detailsurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="subscriptiondetailslink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$subscriptiondetailsurl}"><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="$subscriptiondetailsurl"/>)</xsl:if>
  </xsl:template>
  
  <xsl:template match="newresourcelink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$contentaccessurl}"><xsl:attribute name="title"><xsl:value-of select="$newresourcelink"/></xsl:attribute><xsl:value-of select="$newresourcelink"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="text()"/> (<xsl:value-of select="$contentaccessurl"/>)</xsl:if>
  </xsl:template>
  
  <xsl:template match="subscriptionlink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$subscriptiondetailsurl}"><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="$subscriptiondetailsurl"/>)</xsl:if>
  </xsl:template>
  
  <xsl:template match="resourcelink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$contentaccessurl}"><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="$contentaccessurl"/>)</xsl:if>
    <xsl:if test="$outputFormat='plaintextsms'"><xsl:value-of select="$resourcename"/></xsl:if>
  </xsl:template>

  <xsl:template match="parentlink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$folderaccessurl}"><xsl:attribute name="title"><xsl:value-of select="$parenturl"/></xsl:attribute><xsl:value-of select="$parenturl"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="$parenturl"/> (<xsl:value-of select="$folderaccessurl"/>)</xsl:if>
    <xsl:if test="$outputFormat='plaintextsms'"><xsl:value-of select="$parenturl"/></xsl:if>
  </xsl:template>

  <xsl:template match="deletelink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$deleteurl}"><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="$deleteurl"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="administerlink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$administrationurl}"><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="$administrationurl"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="mailtolink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$mailto}"><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="$mailto"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="detailslink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$detailsurl}"><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="$detailsurl"/></xsl:if>
  </xsl:template>
  
</xsl:stylesheet>
