<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
                       xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                       xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                       xmlns:ole="http://www.mindjet.com/OutlookLinker/Extensions"
                       xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003"
                       xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003"
                       extension-element-prefixes="msxsl ole">
                       
    <!-- Whitspace Handling -->
    <!-- ============== -->

    <xsl:preserve-space elements="BodyText p"/>

    <!--General Templates -->
    <!-- ============= -->

    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>

    <!-- localization -->
    <!-- ======== -->

    <xsl:include href="language.xslt"/>
    
    <!-- global variables -->
    <!-- =========== -->

    <xsl:variable name="tableWidth" select="95"/>

    <!-- named templates (helper functions) -->
    <!-- ========================= -->
        
    <xsl:template name="boundary">
        <ap:OneBoundary xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003">
            <ap:Boundary>
                <ap:BoundaryViewGroup ViewIndex="0"/>
                <ap:Color FillColor="b3d6d6d6" LineColor="ff999999"/>
                <ap:LineStyle LineWidth="0.5"/>
                <ap:BoundaryShape BoundaryShape="urn:mindjet:CurvedLine"/>
            </ap:Boundary>
        </ap:OneBoundary>
    </xsl:template>

    <xsl:template name="task"  xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003">
        <xsl:param name="prio"/>
        <xsl:param name="perc"/>
        <xsl:param name="sd"/>
        <xsl:param name="dd"/>
        <ap:Task TaskPercentage="{$perc}"  TaskPriority="urn:mindjet:Prio{3-$prio}">
              <xsl:if test="string-length($sd)>0">
                  <xsl:attribute name="StartDate">
                       <xsl:value-of select="$sd"/>
                  </xsl:attribute>
              </xsl:if>
              <xsl:if test="string-length($dd)>0">
                  <xsl:attribute name="DeadlineDate">
                       <xsl:value-of select="$dd"/>
                  </xsl:attribute>
             </xsl:if>
        </ap:Task>
    </xsl:template>

    <xsl:template name="custom-property">
        <xsl:param name="type"/>
        <xsl:param name="id"/>
        <xsl:param name="guid"/>
        <cor:Custom Uri="http://schemas.mindjet.com/MindManager/MsOutlookLinker/2003" 
                            xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003" 
                            Index="0" 
                            custom0:Type="{normalize-space($type)}" 
                            custom0:EntryID="{normalize-space($id)}" 
                            custom0:Guid="{normalize-space($guid)}" 
                            custom0:Active="true" 
                            xmlns:custom0="http://schemas.mindjet.com/MindManager/MsOutlookLinker/2003"/>
    </xsl:template>
    
    <xsl:template name="image">
        <xsl:param name="base64"/>
        <ap:OneImage xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <ap:Image>
                <ap:ImageData ImageType="urn:mindjet:MetafileImage">
                    <cor:Base64>
                        <xsl:value-of select="normalize-space($base64)"/>
                    </cor:Base64>
                </ap:ImageData>
                <ap:ImageSize Width="8.0" Height="8.0"/>
            </ap:Image>
        </ap:OneImage>
    </xsl:template>
        
    <xsl:template name="common-header">
        <xsl:param name="type"/>
        <xsl:param name="id"/>
        <xsl:param name="guid"/>
        <xsl:param name="base64"/>
        <xsl:param name="Topic"/>
        <xsl:call-template name="custom-property">
            <xsl:with-param name="type" select="$type"/>
            <xsl:with-param name="id" select="$id"/>
            <xsl:with-param name="guid" select="$guid"/>
        </xsl:call-template>
        <xsl:choose>
            <xsl:when test="$Topic/cor:Custom[@Uri='http://schemas.mindjet.com/MindManager/MsOutlookLinker/2003']">
                <xsl:copy-of select="$Topic/ap:SubTopics"/>
                <xsl:copy-of select="$Topic/ap:FloatingTopics"/>
                <xsl:copy-of select="$Topic/ap:OneBoundary"/>     
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="boundary"/>
            </xsl:otherwise>
        </xsl:choose>  
        
        <xsl:call-template name="image">
            <xsl:with-param name="base64" select="$base64"/>
        </xsl:call-template>
        <ap:TopicViewGroup ViewIndex="0" xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <ap:Collapsed Collapsed="false"/>
        </ap:TopicViewGroup>
    </xsl:template>
    
    <xsl:template name="common-footer">
        <xsl:param name="Topic"/>
        <xsl:choose>
            <xsl:when test="$Topic/cor:Custom[@Uri='http://schemas.mindjet.com/MindManager/MsOutlookLinker/2003']">
		     <xsl:copy-of select="$Topic/ap:IconsGroup"/>
		     <xsl:copy-of select="$Topic/ap:SubTopicShape"/>
			<xsl:copy-of select="$Topic/ap:TopicLayout"/>
			<xsl:copy-of select="$Topic/ap:SubTopicsShape"/>
			<xsl:copy-of select="$Topic/ap:Hyperlink"/>
			<xsl:copy-of select="$Topic/ap:Task"/>
			<xsl:copy-of select="$Topic/ap:Bookmark"/>
			<xsl:copy-of select="$Topic/ap:Comments"/>
            </xsl:when>
            <xsl:otherwise>
               <ap:SubTopicShape SubTopicShape="urn:mindjet:RoundedRectangle"/>
            </xsl:otherwise>
         </xsl:choose>
         <ap:SpellingOptions SpellText="false" SpellNotes="false"/>
     </xsl:template>
   
    <xsl:template name="topic-text">
        <xsl:param name="subject"/>
        <xsl:param name="rest"/>
        <xsl:param name="sl"/>
        <xsl:param name="rl"/>
        <xsl:param name="fontSize"/>
        <ap:Text TextAlignment="urn:mindjet:Left" xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <xsl:attribute name="PlainText"><xsl:value-of select="$subject"/><xsl:text>&#xA;</xsl:text><xsl:value-of select="$rest"/></xsl:attribute>
            <ap:Font Size="{$fontSize}" Color="ff000000"/>
            <ap:FontRange From="0" To="{$sl}" Size="{$fontSize}" Color="ff000000"/>
            <ap:FontRange From="{$sl + 1}" To="{$sl + $rl}" Size="{$fontSize - 2} " Color="ff3c3c3c"/>
        </ap:Text>
        <ap:Color FillColor="ffffffff" xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003"/>
    </xsl:template>
    <xsl:template name="date">
        <xsl:param name="date"/>
        <xsl:variable name="year" select="substring($date, 1, 4)"/>
        <xsl:variable name="month" select="substring($date, 6, 2)"/>
        <xsl:variable name="day" select="substring($date, 9, 4)"/>
        <xsl:value-of select="concat($month, '/', $day, '/' , $year)"/>
    </xsl:template>
    <xsl:template name="date-time">
        <xsl:param name="date"/>
        <xsl:variable name="year" select="substring($date, 1, 4)"/>
        <xsl:variable name="month" select="substring($date, 6, 2)"/>
        <xsl:variable name="day" select="substring($date, 9, 2)"/>
        <xsl:variable name="hours" select="substring($date, 12, 2)"/>
        <xsl:variable name="minutes" select="substring($date, 15, 2)"/>
        <xsl:choose>
            <xsl:when test="$hours >= 12">
                <xsl:value-of select="concat($month, '/', $day, '/' , $year, ' ', $hours, ':', $minutes, ' PM')"/>
            </xsl:when>
            <xsl:when test="12 > $hours">
                <xsl:value-of select="concat($month, '/', $day, '/' , $year, ' ', $hours, ':', $minutes, ' AM')"/>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="task-status">
        <xsl:param name="status"/>
        <xsl:choose>
            <xsl:when test="$status = 0">
                <xsl:value-of select="$locNotStarted"/>
            </xsl:when>
            <xsl:when test="$status = 1">
                <xsl:value-of select="$locInProgress"/>
            </xsl:when>
            <xsl:when test="$status = 2">
                <xsl:value-of select="$locComplete"/>
            </xsl:when>
            <xsl:when test="$status = 3">
                <xsl:value-of select="$locWaiting"/>
            </xsl:when>
            <xsl:when test="$status = 4">
                <xsl:value-of select="$locDeffered"/>
            </xsl:when>
            <xsl:otherwise>---</xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="recurrence">
        <xsl:param name="rec"/>
        <xsl:choose>
            <xsl:when test="$rec= 0">
                <xsl:value-of select="$locDaily"/>
            </xsl:when>
            <xsl:when test="$rec= 1">
                <xsl:value-of select="$locWeekly"/>
            </xsl:when>
            <xsl:when test="$rec= 2">
                <xsl:value-of select="$locMonthly"/>
            </xsl:when>
            <xsl:when test="$rec= 3">
                <xsl:value-of select="$locMonthlyNth"/>
            </xsl:when>
            <xsl:when test="$rec= 4">
                <xsl:value-of select="$locYearly"/>
            </xsl:when>
            <xsl:when test="$rec= 5">
                <xsl:value-of select="$locYearlyNth"/>
            </xsl:when>
            <xsl:otherwise/>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="prio">
        <xsl:param name="prio"/>
        <xsl:choose>
            <xsl:when test="$prio= 0">Low</xsl:when>
            <xsl:when test="$prio= 1">Normal</xsl:when>
            <xsl:when test="$prio= 2">High</xsl:when>
            <xsl:otherwise/>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="table-row-with-two-cells">
        <xsl:param name="cell1"/>
        <xsl:param name="cell2"/>
        <xsl:if test="string-length(normalize-space($cell2)) > 0">
            <tr>
                <td valign="top" width="50%" style="border: solid black 0.50pt;">
                    <div align="left">
                        <font size="3">
                            <span style="font-size:10pt">
                                <xsl:value-of select="$cell1"/>
                            </span>
                        </font>
                    </div>
                </td>
                <td valign="top" width="50%" style="border: solid black 0.50pt;">
                    <div align="left">
                        <font size="3">
                            <span style="font-size:10pt">
                                <xsl:value-of select="normalize-space($cell2)"/>
                            </span>
                        </font>
                    </div>
                </td>
            </tr>
        </xsl:if>
    </xsl:template>
    <!-- matching templates -->
    <!-- ============== -->
    <xsl:template match="Attachment">
        <ap:Topic xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <xsl:call-template name="custom-property">
                <xsl:with-param name="type" select="'Attachment'"/>
                <xsl:with-param name="id" select="'---'"/>
                <xsl:with-param name="guid" select="'---'"/>
            </xsl:call-template>
            <ap:Text>
                <xsl:attribute name="PlainText"><xsl:value-of select="normalize-space(AttachmentFileName)"/></xsl:attribute>
                <ap:Font/>
            </ap:Text>            
            <ap:Hyperlink Absolute="false" Hidden="false" HyperlinkType="urn:mindjet:DocumentHyperlink" HyperlinkSourceHandling="urn:mindjet:KeepLink">
                <xsl:attribute name="Url"><xsl:value-of select="normalize-space(AttachmentFilePath)"/></xsl:attribute>
                <xsl:attribute name="Name"><xsl:value-of select="normalize-space(AttachmentFileName)"/></xsl:attribute>
                <xsl:attribute name="CachedName"><xsl:value-of select="normalize-space(AttachmentFileName)"/></xsl:attribute>
            </ap:Hyperlink>            
        </ap:Topic>
    </xsl:template>
    <xsl:template match="Appointment">
        <ap:Topic xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <xsl:call-template name="common-header">
                <xsl:with-param name="type" select="'Appointment'"/>
                <xsl:with-param name="id" select="EntryID"/>
                <xsl:with-param name="guid" select="Guid"/>
                <xsl:with-param name="base64" select="Image"/>
                <xsl:with-param name="Topic" select="TopicXml/ap:Topic"/>
            </xsl:call-template>
            <xsl:variable name="subject" select="normalize-space(Subject)"/>
            <xsl:variable name="rest">
                <xsl:choose>
                    <xsl:when test="contains(AllDayEvent,'yes')">
                        <xsl:value-of select="normalize-space(StartDate)"/> (all day)
				     </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="normalize-space(StartDate)"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:call-template name="topic-text">
                <xsl:with-param name="subject" select="$subject"/>
                <xsl:with-param name="rest" select="normalize-space($rest)"/>
                <xsl:with-param name="sl" select="string-length($subject)"/>
                <xsl:with-param name="rl" select="string-length(normalize-space($rest))"/>
                <xsl:with-param name="fontSize" select="FontSize"/>
            </xsl:call-template>
            <ap:NotesGroup>
                <ap:NotesXhtmlData>
                    <html xmlns="http://www.w3.org/1999/xhtml">
                        <table border="1" width="{$tableWidth}%" cellpadding="6" style="border-collapse: collapse; border: none">
                            <xsl:variable name="endDate">
                                <xsl:value-of select="normalize-space(EndDate)"/>
                            </xsl:variable>
                            <xsl:variable name="recurrence">
                                <xsl:call-template name="recurrence">
                                    <xsl:with-param name="rec" select="normalize-space(Recurrence)"/>
                                </xsl:call-template>
                            </xsl:variable>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locEndTime"/>
                                <xsl:with-param name="cell2" select="$endDate"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locRecurrence"/>
                                <xsl:with-param name="cell2" select="$recurrence"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locParticipants"/>
                                <xsl:with-param name="cell2" select="Participants"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locLocation"/>
                                <xsl:with-param name="cell2" select="Location"/>
                            </xsl:call-template>
                        </table>
                        <xsl:text>&#xA;</xsl:text>
                        <xsl:text>&#xA;</xsl:text>
                        <xsl:copy-of select="BodyText/node()"/>
                        <p/>
                    </html>
                </ap:NotesXhtmlData>
            </ap:NotesGroup>
            <xsl:call-template name="common-footer">
                <xsl:with-param name="Topic" select="TopicXml/ap:Topic"/>
            </xsl:call-template>
        </ap:Topic>
    </xsl:template>
    <xsl:template match="Appointments">
        <ap:Topic xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <xsl:call-template name="custom-property">
                <xsl:with-param name="type" select="'TodaysAppointments'"/>
                <xsl:with-param name="id" select="'---'"/>
                <xsl:with-param name="guid" select="'---'"/>
            </xsl:call-template>
            <ap:SubTopics>
                <xsl:apply-templates select="Apps/Appointment"/>
            </ap:SubTopics>
            <xsl:call-template name="boundary"/>
            <xsl:call-template name="image">
                <xsl:with-param name="base64" select="Image"/>
            </xsl:call-template>
            <ap:TopicViewGroup ViewIndex="0">
                <ap:Collapsed Collapsed="true"/>
            </ap:TopicViewGroup>
            <ap:Text>
                <xsl:attribute name="PlainText"><xsl:text>Today&apos;s Appointments</xsl:text></xsl:attribute>
                <xsl:variable name="fontSize" select="FontSize"/>
                <ap:Font Size="{$fontSize}" Color="ff000000"/>
            </ap:Text>
            <ap:Color FillColor="ffffffff" xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003"/>
            <ap:SubTopicShape SubTopicShape="urn:mindjet:RoundedRectangle"/>
            <ap:SpellingOptions SpellText="false" SpellNotes="false"/>
        </ap:Topic>
    </xsl:template>
    <xsl:template match="Contact">
        <ap:Topic xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <xsl:call-template name="common-header">
                <xsl:with-param name="type" select="'Contact'"/>
                <xsl:with-param name="id" select="EntryID"/>
                <xsl:with-param name="guid" select="Guid"/>
                <xsl:with-param name="base64" select="Image"/>
                <xsl:with-param name="Topic" select="TopicXml/ap:Topic"/>
            </xsl:call-template>
            <xsl:variable name="subject" select="normalize-space(Fullname)"/>
            <xsl:variable name="rest" select="normalize-space(Email)"/>
            <xsl:call-template name="topic-text">
                <xsl:with-param name="subject" select="$subject"/>
                <xsl:with-param name="rest" select="$rest"/>
                <xsl:with-param name="sl" select="string-length($subject)"/>
                <xsl:with-param name="rl" select="string-length(normalize-space($rest))"/>
                <xsl:with-param name="fontSize" select="FontSize"/>
            </xsl:call-template>
            <ap:NotesGroup>
                <ap:NotesXhtmlData>
                    <html xmlns="http://www.w3.org/1999/xhtml">
                        <table border="1" width="{$tableWidth}%" cellpadding="6" style="border-collapse: collapse; border: none">
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locCompany"/>
                                <xsl:with-param name="cell2" select="Company"/>
                            </xsl:call-template>
                            <tr>
                                <td valign="top" width="50%" style="border: solid black 0.50pt;">
                                    <div align="left">
                                        <font size="3">
                                            <span style="font-size:10pt">
                                                <xsl:value-of select="$locWWW"/>
                                            </span>
                                        </font>
                                    </div>
                                </td>
                                <td valign="top" width="50%" style="border: solid black 0.50pt;">
                                    <div align="left">
                                        <font size="3">
                                            <span style="font-size:10pt">
                                                <a>
                                                    <xsl:attribute name="href"><xsl:value-of select="normalize-space(WebPage)"/></xsl:attribute>
                                                    <xsl:value-of select="normalize-space(WebPage)"/>
                                                </a>
                                            </span>
                                        </font>
                                    </div>
                                </td>
                            </tr>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locBusinessPhone"/>
                                <xsl:with-param name="cell2" select="BusinessPhoneNumber"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locHomePhone"/>
                                <xsl:with-param name="cell2" select="HomePhoneNumber"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locMobilePhone"/>
                                <xsl:with-param name="cell2" select="MobilePhoneNumber"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locBusinessFax"/>
                                <xsl:with-param name="cell2" select="FaxNumber"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locBusinessAddress"/>
                                <xsl:with-param name="cell2" select="BusinessAddress"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locHomeAddress"/>
                                <xsl:with-param name="cell2" select="HomeAddress"/>
                            </xsl:call-template>
                        </table>
                        <p/>
                    </html>
                </ap:NotesXhtmlData>
            </ap:NotesGroup>
            <xsl:call-template name="common-footer">
                <xsl:with-param name="Topic" select="TopicXml/ap:Topic"/>
            </xsl:call-template>
        </ap:Topic>
    </xsl:template>
    <xsl:template match="Folder">
        <ap:Topic xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <xsl:call-template name="common-header">
                <xsl:with-param name="type" select="'Folder'"/>
                <xsl:with-param name="id" select="EntryID"/>
                <xsl:with-param name="guid" select="Guid"/>
                <xsl:with-param name="base64" select="Image"/>
                <xsl:with-param name="Topic" select="TopicXml/ap:Topic"/>
            </xsl:call-template>
            <xsl:variable name="subject" select="$locOutlookFolder"/>
            <xsl:variable name="rest" select="normalize-space(Name)"/>
            <xsl:call-template name="topic-text">
                <xsl:with-param name="subject" select="$subject"/>
                <xsl:with-param name="rest" select="$rest"/>
                <xsl:with-param name="sl" select="string-length($subject)"/>
                <xsl:with-param name="rl" select="string-length(normalize-space($rest))"/>
                <xsl:with-param name="fontSize" select="FontSize"/>
            </xsl:call-template>
            <xsl:call-template name="common-footer">
                <xsl:with-param name="Topic" select="TopicXml/ap:Topic"/>
            </xsl:call-template>
        </ap:Topic>
    </xsl:template>
    <xsl:template match="Message">
        <ap:Topic xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
			<xsl:call-template name="custom-property">
                <xsl:with-param name="type" select="'Message'"/>
                <xsl:with-param name="id" select="EntryID"/>
                <xsl:with-param name="guid" select="Guid"/>
			</xsl:call-template>
            <ap:SubTopics>
                <xsl:apply-templates select="Attachments"/>
            </ap:SubTopics>
			<xsl:call-template name="boundary"/>
			<xsl:call-template name="image">
                <xsl:with-param name="base64" select="Image"/>
			</xsl:call-template>
			<ap:TopicViewGroup ViewIndex="0">
				<ap:Collapsed Collapsed="true"/>
			</ap:TopicViewGroup>
            <xsl:variable name="subject" select="normalize-space(Subject)"/>
            <xsl:variable name="rest">
                <xsl:if test="string-length(normalize-space(From)) > 0">
                    <xsl:value-of select="concat($locFrom, ' ', normalize-space(From))"/>
                </xsl:if>
                <xsl:if test="string-length(normalize-space(FollowUp)) > 0">
                    <xsl:value-of select="concat('&#xA;', $locFollowUp, ' ', normalize-space(FollowUp))"/>
                </xsl:if>
                <xsl:if test="string-length(normalize-space(SendDateAndTime)) > 0">
                    <xsl:value-of select="concat('&#xA;', $locSent, ' ', normalize-space(SendDateAndTime))"/>
                </xsl:if>
            </xsl:variable>
            <xsl:call-template name="topic-text">
                <xsl:with-param name="subject" select="$subject"/>
                <xsl:with-param name="rest" select="$rest"/>
                <xsl:with-param name="sl" select="string-length($subject)"/>
                <xsl:with-param name="rl" select="string-length(normalize-space($rest))"/>
                <xsl:with-param name="fontSize" select="FontSize"/>
            </xsl:call-template>
            <ap:NotesGroup>
                <ap:NotesXhtmlData>
                    <html xmlns="http://www.w3.org/1999/xhtml">
                        <table border="1" width="{$tableWidth}%" cellpadding="6" style="border-collapse: collapse; border: none">
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locTo"/>
                                <xsl:with-param name="cell2" select="To"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locCc"/>
                                <xsl:with-param name="cell2" select="Cc"/>
                            </xsl:call-template>
                            <xsl:variable name="sendDate">
                                <xsl:value-of select="normalize-space(SendDateAndTime)"/>
                            </xsl:variable>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locSent"/>
                                <xsl:with-param name="cell2" select="$sendDate"/>
                            </xsl:call-template>
                        </table>
                        <xsl:text>&#xA;</xsl:text>
                        <xsl:text>&#xA;</xsl:text>
                        <xsl:copy-of select="BodyText/node()"/>
                        <p/>
                    </html>
                </ap:NotesXhtmlData>
            </ap:NotesGroup>
            <xsl:call-template name="common-footer">
                <xsl:with-param name="Topic" select="TopicXml/ap:Topic"/>
            </xsl:call-template>
        </ap:Topic>
    </xsl:template>
    <xsl:template match="Note">
        <ap:Topic xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <xsl:call-template name="common-header">
                <xsl:with-param name="type" select="'Note'"/>
                <xsl:with-param name="id" select="EntryID"/>
                <xsl:with-param name="guid" select="Guid"/>
                <xsl:with-param name="base64" select="Image"/>
                 <xsl:with-param name="Topic" select="TopicXml/ap:Topic"/>
           </xsl:call-template>
            <xsl:variable name="subject" select="normalize-space(Subject)"/>
            <xsl:variable name="date" select="normalize-space(ModifiedDateAndTime)"/>
            <xsl:variable name="rest" select="concat($locModified, ' ', normalize-space($date))"/>
            <xsl:call-template name="topic-text">
                <xsl:with-param name="subject" select="$subject"/>
                <xsl:with-param name="rest" select="$rest"/>
                <xsl:with-param name="sl" select="string-length($subject)"/>
                <xsl:with-param name="rl" select="string-length(normalize-space($rest))"/>
                <xsl:with-param name="fontSize" select="FontSize"/>
            </xsl:call-template>
            <ap:NotesGroup>
                <ap:NotesXhtmlData>
                    <html xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:text>&#xA;</xsl:text>
                        <xsl:copy-of select="BodyText/node()"/>
                        <p/>
                    </html>
                </ap:NotesXhtmlData>
            </ap:NotesGroup>
            <xsl:call-template name="common-footer">
                <xsl:with-param name="Topic" select="TopicXml/ap:Topic"/>
            </xsl:call-template>
        </ap:Topic>
    </xsl:template>
    <xsl:template match="Task">
        <ap:Topic xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <xsl:call-template name="common-header">
                <xsl:with-param name="type" select="'Task'"/>
                <xsl:with-param name="id" select="EntryID"/>
                <xsl:with-param name="guid" select="Guid"/>
                <xsl:with-param name="base64" select="Image"/>
                <xsl:with-param name="Topic" select="TopicXml/ap:Topic"/>
            </xsl:call-template>
            <xsl:variable name="subject" select="normalize-space(Subject)"/>
            <xsl:variable name="duedate" select="normalize-space(DueDate)"/>
            <xsl:variable name="status">
                <xsl:call-template name="task-status">
                    <xsl:with-param name="status" select="normalize-space(Status)"/>
                </xsl:call-template>
            </xsl:variable>
            <xsl:variable name="rest" select="concat($locDueDate, ' ', normalize-space($duedate))"/>
            <xsl:call-template name="topic-text">
                <xsl:with-param name="subject" select="$subject"/>
                <xsl:with-param name="rest" select="$rest"/>
                <xsl:with-param name="sl" select="string-length($subject)"/>
                <xsl:with-param name="rl" select="string-length($rest)"/>
                <xsl:with-param name="fontSize" select="FontSize"/>
            </xsl:call-template>
            <ap:NotesGroup>
                <ap:NotesXhtmlData>
                    <html xmlns="http://www.w3.org/1999/xhtml">
                        <table border="1" width="{$tableWidth}%" cellpadding="6" style="border-collapse: collapse; border: none">
                            <xsl:variable name="prio">
                                <xsl:call-template name="prio">
                                    <xsl:with-param name="prio" select="normalize-space(Priority)"/>
                                </xsl:call-template>
                            </xsl:variable>
                            <xsl:variable name="startDate" select="normalize-space(StartDate)"/>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locStartDate"/>
                                <xsl:with-param name="cell2" select="$startDate"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locPriority"/>
                                <xsl:with-param name="cell2" select="$prio"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locComplete"/>
                                <xsl:with-param name="cell2" select="concat(normalize-space(PercentComplete), '%')"/>
                            </xsl:call-template>
                            <xsl:call-template name="table-row-with-two-cells">
                                <xsl:with-param name="cell1" select="$locStatus"/>
                                <xsl:with-param name="cell2" select="normalize-space($status)"/>
                            </xsl:call-template>
                        </table>
                        <xsl:text>&#xA;</xsl:text>
                        <xsl:text>&#xA;</xsl:text>
                        <xsl:copy-of select="BodyText/node()"/>
                        <p/>
                    </html>
                </ap:NotesXhtmlData>
           </ap:NotesGroup>
           <xsl:variable name="Topic" select="TopicXml/ap:Topic"/>
		 <xsl:copy-of select="$Topic/ap:IconsGroup"/>
           <xsl:copy-of select="$Topic/ap:SubTopicShape"/>
		 <xsl:copy-of select="$Topic/ap:TopicLayout"/>
		 <xsl:copy-of select="$Topic/ap:SubTopicsShape"/>
		 <xsl:copy-of select="$Topic/ap:Hyperlink"/>
           <xsl:call-template name="task">
                <xsl:with-param name="prio" select="normalize-space(Priority)"/>
                <xsl:with-param name="perc" select="normalize-space(PercentComplete)"/>
                <xsl:with-param name="sd" select="normalize-space(StartDate/@CanonicalStartDate)"/>
                <xsl:with-param name="dd" select="normalize-space(DueDate/@CanonicalDueDate)"/>
           </xsl:call-template>
		 <xsl:copy-of select="$Topic/ap:Bookmark"/>
 		 <xsl:copy-of select="$Topic/ap:Comments"/>
           <ap:SpellingOptions SpellText="false" SpellNotes="false"/>
        </ap:Topic>
    </xsl:template>
    <xsl:template match="Deleted">
        <ap:Topic xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
            <xsl:call-template name="custom-property">
                <xsl:with-param name="type" select="'Deleted'"/>
                <xsl:with-param name="id" select="'---'"/>
                <xsl:with-param name="guid" select="'---'"/>
            </xsl:call-template>
            <xsl:call-template name="boundary"/>
            <ap:TopicViewGroup ViewIndex="0" xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
                <ap:Collapsed Collapsed="true"/>
            </ap:TopicViewGroup>
            <ap:Text xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003" xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003">
                <xsl:attribute name="PlainText">Deleted</xsl:attribute>
                <ap:Font Size="12" Color="ff000000"/>
            </ap:Text>
            <xsl:call-template name="common-footer"/>
        </ap:Topic>
    </xsl:template>
</xsl:stylesheet>
