<?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="headline"/>
  <xsl:param name="righttoleft"/>
  <xsl:param name="isroom"/>
  
  <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:value-of select="notification/title/textspan"/></title>
      </head>
      <body style="font-family:Arial,sans-serif;">
        <span style="font-size:medium; font-weight:bold;"><xsl:apply-templates select="notification/title/textspan"/></span>
        <table style="font-size:small">
        <tr><td colspan="3"><hr/></td></tr>
           <xsl:apply-templates select="notification/bundlednotificationdata/resource"/>
        <tr><td colspan="3"><br/><hr/></td></tr>
        </table>
        <span style="font-size:small"><xsl:apply-templates select="notification/deletion-warning/textspan"/></span><br/>
        <span style="font-size:xx-small"><xsl:apply-templates select="notification/warning/textspan"/></span>
        <p/>
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="resource">
     <xsl:if test="not(@subscriptionname=preceding-sibling::*/@subscriptionname)">
       <tr>
         <td colspan="2" style="font-weight:bold;"><br/>
           <xsl:apply-templates select="/notification/greeting/textspan">
             <xsl:with-param name="thisResource" select="position()" /> 
           </xsl:apply-templates>
         </td>       
         <td align="right" valign="bottom" style="font-size:xx-small"><br/>
           <xsl:if test="not(@eventid='delete') and not(@eventid='archive')">
             <xsl:apply-templates select="/notification/actioninfo/textspan[@isowner=current()/@isowner]">
                <xsl:with-param name="thisResource" select="position()" /> 
             </xsl:apply-templates>
           </xsl:if>                              
         </td>
       </tr>
       <tr>
         <td colspan="3">
           <pre style="font-style:italic;"><xsl:apply-templates select="text()"/></pre>
         </td>
       </tr>
     </xsl:if>
     <tr>
       <td colspan="3">
          <xsl:apply-templates select="/notification/eventinfo/textspan[@pEventid=current()/@eventid and @isCollection=current()/@isCollection]">
            <xsl:with-param name="thisResource" select="position()" /> 
          </xsl:apply-templates>
       </td>
     </tr>
  </xsl:template>
  
  <xsl:template match="textspan">
    <xsl:param name="outputFormat" select="'HTML'"/>
      <xsl:param name="thisResource" />
        <xsl:apply-templates select="resourcename|parentname|parentpath|subscriptionname|resourceDescription|subscriptiondetailslink|subscriptiondetailsurl|notificationtext|eventid|eventname|parenturl|contentaccessurl|folderaccessurl|deleteurl|administrationurl|mailto|lastmodifieduser|lastmodified|headline|pollingid|subscriptionlink|resourcelink|parentlink|deletelink|administerlink|mailtolink|detailsurl|detailslink|roomname|roomlink|resourcePathInRoom|resourcePathInRoomLink|text()">
          <xsl:with-param name="outputFormat" select="$outputFormat"/>
          <xsl:with-param name="thisResource" select="$thisResource"/>
        </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:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcename"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcename"/></xsl:if>
  </xsl:template>

  <xsl:template match="parentname">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentname"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentname"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="parentpath">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentpath"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentpath"/></xsl:if>
  </xsl:template>  

  <xsl:template match="resourceDescription">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourceDescription"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourceDescription"/></xsl:if>
  </xsl:template>

  <xsl:template match="subscriptionname">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@subscriptionname"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@subscriptionname"/></xsl:if>
  </xsl:template>

  <xsl:template match="notificationtext">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@notificationtext"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@notificationtext"/></xsl:if>
  </xsl:template>

  <xsl:template match="eventid">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@eventid"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@eventid"/></xsl:if>
  </xsl:template>

  <xsl:template match="eventname">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@eventname"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@eventname"/></xsl:if>
  </xsl:template>

  <xsl:template match="resourceurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourceRID"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourceRID"/></xsl:if>
  </xsl:template>

  <xsl:template match="parenturl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentRID"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentRID"/></xsl:if>
  </xsl:template>

  <xsl:template match="contentaccessurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@contentAccess"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@contentAccess"/></xsl:if>
  </xsl:template>

  <xsl:template match="folderaccessurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
   <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentAccess"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentAccess"/></xsl:if>
  </xsl:template>

  <xsl:template match="deleteurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@deleteURL"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@deleteURL"/></xsl:if>
  </xsl:template>

  <xsl:template match="administrationurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@administrationURL"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@administrationURL"/></xsl:if>
  </xsl:template>

  <xsl:template match="mailto">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@mailToOwner"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@mailToOwner"/></xsl:if>
  </xsl:template>

  <xsl:template match="lastmodifieduser">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@lastmodifieduser"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@lastmodifieduser"/></xsl:if>
  </xsl:template>

  <xsl:template match="lastmodified">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@lastmodified"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@lastmodified"/></xsl:if>
  </xsl:template>

  <xsl:template match="pollingid">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@pollingID"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@pollingID"/></xsl:if>
  </xsl:template>

 <xsl:template match="headline">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="$headline"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="$headline"/></xsl:if>
  </xsl:template>

  <xsl:template match="subscriptiondetailsurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@subscriptiondetailsurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@subscriptiondetailsurl"/></xsl:if>
  </xsl:template>

  <xsl:template match="detailsurl">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@detailsurl"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@detailsurl"/></xsl:if>
  </xsl:template>

  
  
  <xsl:template match="subscriptionlink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{/notification/bundlednotificationdata/resource[$thisResource]/@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="/notification/bundlednotificationdata/resource[$thisResource]/@administrationURL"/>)</xsl:if>
    <xsl:if test="$outputFormat='plaintextsms'"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@subscriptionname"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="resourcelink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{/notification/bundlednotificationdata/resource[$thisResource]/@contentAccess}"><xsl:attribute name="title"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcename"/></xsl:attribute><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcename"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcename"/> (<xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@contentAccess"/>)</xsl:if>
    <xsl:if test="$outputFormat='plaintextsms'"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcename"/></xsl:if>
  </xsl:template>

  <xsl:template match="parentlink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{/notification/bundlednotificationdata/resource[$thisResource]/@parentAccess}"><xsl:attribute name="title"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentpath"/></xsl:attribute><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentpath"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentname"/> (<xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentpath"/>)</xsl:if>
    <xsl:if test="$outputFormat='plaintextsms'"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@parentpath"/></xsl:if>
  </xsl:template>

  <xsl:template match="deletelink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{/notification/bundlednotificationdata/resource[$thisResource]/@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="/notification/bundlednotificationdata/resource[$thisResource]/@deleteURL"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="administerlink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{/notification/bundlednotificationdata/resource[$thisResource]/@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="/notification/bundlednotificationdata/resource[$thisResource]/@administrationURL"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="mailtolink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{/notification/bundlednotificationdata/resource[$thisResource]/@mailToOwner}"><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="/notification/bundlednotificationdata/resource[$thisResource]/@mailToOwner"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="detailslink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{/notification/bundlednotificationdata/resource[$thisResource]/@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="/notification/bundlednotificationdata/resource[$thisResource]/@detailsurl"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="subscriptiondetailslink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{/notification/bundlednotificationdata/resource[$thisResource]/@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="/notification/bundlednotificationdata/resource[$thisResource]/@subscriptiondetailsurl"/>)</xsl:if>
  </xsl:template>
  
  <xsl:template match="roomname">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@roomname"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@roomname"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="roomlink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{/notification/bundlednotificationdata/resource[$thisResource]/@roompath}"><xsl:attribute name="title"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@roomname"/></xsl:attribute><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@roomname"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="text()"/> - <xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@roompath"/></xsl:if>
  </xsl:template>  
  
  <xsl:template match="resourcePathInRoom">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><span tabindex="0"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcePathInRoom"/></span></xsl:if>
    <xsl:if test="not($outputFormat='HTML')"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcePathInRoom"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="resourcePathInRoomLink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:param name="thisResource"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{/notification/bundlednotificationdata/resource[$thisResource]/@parentAccess}"><xsl:attribute name="title"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcePathInRoom"/></xsl:attribute><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcePathInRoom"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcePathInRoom"/> (<xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcePathInRoom"/>)</xsl:if>
    <xsl:if test="$outputFormat='plaintextsms'"><xsl:value-of select="/notification/bundlednotificationdata/resource[$thisResource]/@resourcePathInRoom"/></xsl:if>
  </xsl:template>
  
</xsl:stylesheet>

