<?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="operation"/>
  <xsl:param name="subscriptionname"/>
  <xsl:param name="notificationtext"/>
  <xsl:param name="eventid"/>
  <xsl:param name="eventname"/>
  <xsl:param name="deleteurl"/>
  <xsl:param name="administrationurl"/>
  <xsl:param name="mailto"/>
  <xsl:param name="isowner"/>

  <xsl:template match="/">
  <xsl:output encoding="UTF-8" />

    <html>
      <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=$operation]"/>
		  
        <p/>
        <pre><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="subscriptionname|notificationtext|isowner|eventid|eventname|deleteurl|administrationurl|mailto|subscriptionlink|deletelink|administerlink|mailtolink|text()"><xsl:with-param name="outputFormat" select="$outputFormat"/></xsl:apply-templates>
  </xsl:template>

  <xsl:template match="isowner">
	 <xsl:value-of select="$isowner"/>
  </xsl:template>
  
  <xsl:template match="subscriptionname">
	 <xsl:value-of select="$subscriptionname"/>
  </xsl:template>

  <xsl:template match="notificationtext">
	 <xsl:value-of select="$notificationtext"/>
  </xsl:template>

  <xsl:template match="eventid">
	 <xsl:value-of select="$eventid"/>
  </xsl:template>

  <xsl:template match="eventname">
	 <xsl:value-of select="$eventname"/>
  </xsl:template>

  <xsl:template match="deleteurl">
	 <xsl:value-of select="$deleteurl"/>
  </xsl:template>

  <xsl:template match="administrationurl">
	 <xsl:value-of select="$administrationurl"/>
  </xsl:template>

  <xsl:template match="mailto">
	 <xsl:value-of select="$mailto"/>
  </xsl:template>
  
  <xsl:template match="subscriptionlink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$administrationurl}"><xsl:value-of select="$subscriptionname"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:value-of select="$subscriptionname"/> (<xsl:value-of select="$administrationurl"/>)</xsl:if>
    <xsl:if test="$outputFormat='plaintextsms'"><xsl:value-of select="$subscriptionname"/></xsl:if>
  </xsl:template>
  
  <xsl:template match="deletelink">
    <xsl:param name="outputFormat" select="'HTML'"/>
    <xsl:if test="$outputFormat='HTML'"><a href="{$deleteurl}"><xsl:apply-templates select="text()"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:apply-templates 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:apply-templates select="text()"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:apply-templates 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:apply-templates select="text()"/></a></xsl:if>
    <xsl:if test="$outputFormat='plaintext'"><xsl:apply-templates select="text()"/> (<xsl:value-of select="$mailto"/>)</xsl:if>
  </xsl:template>
  
</xsl:stylesheet>
