| 1 |
<?xml version='1.0' encoding='iso-8859-1'?> |
|---|
| 2 |
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> |
|---|
| 3 |
<xsl:output omit-xml-declaration="yes" indent="no" /> |
|---|
| 4 |
<xsl:param name="bulkTransform" /> |
|---|
| 5 |
<xsl:param name="timeFormat" /> |
|---|
| 6 |
|
|---|
| 7 |
<xsl:template match="/"> |
|---|
| 8 |
<xsl:choose> |
|---|
| 9 |
<xsl:when test="count( /envelope/message ) > 1"> |
|---|
| 10 |
<xsl:apply-templates select="/envelope/message[last()]" /> |
|---|
| 11 |
</xsl:when> |
|---|
| 12 |
<xsl:otherwise> |
|---|
| 13 |
<xsl:apply-templates /> |
|---|
| 14 |
</xsl:otherwise> |
|---|
| 15 |
</xsl:choose> |
|---|
| 16 |
</xsl:template> |
|---|
| 17 |
|
|---|
| 18 |
<xsl:template match="envelope | message"> |
|---|
| 19 |
<xsl:variable name="envelopeClasses"> |
|---|
| 20 |
<xsl:choose> |
|---|
| 21 |
<xsl:when test="(message[1]/@highlight = 'yes' and message[1]/@action = 'yes') or (@highlight = 'yes' and @action = 'yes')"> |
|---|
| 22 |
<xsl:text>envelope highlight action</xsl:text> |
|---|
| 23 |
</xsl:when> |
|---|
| 24 |
<xsl:when test="message[1]/@action = 'yes' or @action = 'yes'"> |
|---|
| 25 |
<xsl:text>envelope action</xsl:text> |
|---|
| 26 |
</xsl:when> |
|---|
| 27 |
<xsl:when test="message[1]/@highlight = 'yes' or @highlight = 'yes'"> |
|---|
| 28 |
<xsl:text>envelope highlight</xsl:text> |
|---|
| 29 |
</xsl:when> |
|---|
| 30 |
<xsl:otherwise> |
|---|
| 31 |
<xsl:text>envelope</xsl:text> |
|---|
| 32 |
</xsl:otherwise> |
|---|
| 33 |
</xsl:choose> |
|---|
| 34 |
</xsl:variable> |
|---|
| 35 |
|
|---|
| 36 |
<xsl:variable name="allClasses"> |
|---|
| 37 |
<xsl:choose> |
|---|
| 38 |
<xsl:when test="(message[1]/@ignored = 'yes' or ../@ignored = 'yes') or (@ignored = 'yes')"> |
|---|
| 39 |
<xsl:value-of select="$envelopeClasses" /> |
|---|
| 40 |
<xsl:text> ignore</xsl:text> |
|---|
| 41 |
</xsl:when> |
|---|
| 42 |
<xsl:otherwise> |
|---|
| 43 |
<xsl:value-of select="$envelopeClasses" /> |
|---|
| 44 |
</xsl:otherwise> |
|---|
| 45 |
</xsl:choose> |
|---|
| 46 |
</xsl:variable> |
|---|
| 47 |
|
|---|
| 48 |
<xsl:variable name="senderClasses"> |
|---|
| 49 |
<xsl:choose> |
|---|
| 50 |
<xsl:when test="sender/@self = 'yes' or ../sender/@self = 'yes'"> |
|---|
| 51 |
<xsl:text>member self</xsl:text> |
|---|
| 52 |
</xsl:when> |
|---|
| 53 |
<xsl:otherwise> |
|---|
| 54 |
<xsl:text>member</xsl:text> |
|---|
| 55 |
</xsl:otherwise> |
|---|
| 56 |
</xsl:choose> |
|---|
| 57 |
</xsl:variable> |
|---|
| 58 |
|
|---|
| 59 |
<xsl:variable name="properIdentifier"> |
|---|
| 60 |
<xsl:choose> |
|---|
| 61 |
<xsl:when test="@id"> |
|---|
| 62 |
<xsl:value-of select="@id" /> |
|---|
| 63 |
</xsl:when> |
|---|
| 64 |
<xsl:otherwise> |
|---|
| 65 |
<xsl:value-of select="../@id" /> |
|---|
| 66 |
<xsl:text>.</xsl:text> |
|---|
| 67 |
<xsl:value-of select="position()" /> |
|---|
| 68 |
</xsl:otherwise> |
|---|
| 69 |
</xsl:choose> |
|---|
| 70 |
</xsl:variable> |
|---|
| 71 |
|
|---|
| 72 |
<div id="{$properIdentifier}" class="{$allClasses}"> |
|---|
| 73 |
<span class="timestamp hidden">[</span> |
|---|
| 74 |
<span class="timestamp"> |
|---|
| 75 |
<xsl:call-template name="short-time"> |
|---|
| 76 |
<xsl:with-param name="date" select="message[1]/@received | @received" /> |
|---|
| 77 |
</xsl:call-template> |
|---|
| 78 |
</span> |
|---|
| 79 |
<span class="timestamp hidden">] </span> |
|---|
| 80 |
<a href="member:{sender | ../sender}" class="{$senderClasses}"><xsl:value-of select="sender | ../sender" /></a> |
|---|
| 81 |
<span class="hidden">: </span> |
|---|
| 82 |
<span class="message"> |
|---|
| 83 |
<xsl:choose> |
|---|
| 84 |
<xsl:when test="message[1]"> |
|---|
| 85 |
<xsl:apply-templates select="message[1]/child::node()" mode="copy" /> |
|---|
| 86 |
</xsl:when> |
|---|
| 87 |
<xsl:otherwise> |
|---|
| 88 |
<xsl:apply-templates select="child::node()" mode="copy" /> |
|---|
| 89 |
</xsl:otherwise> |
|---|
| 90 |
</xsl:choose> |
|---|
| 91 |
</span> |
|---|
| 92 |
</div> |
|---|
| 93 |
|
|---|
| 94 |
<xsl:apply-templates select="message[position() > 1]" /> |
|---|
| 95 |
</xsl:template> |
|---|
| 96 |
|
|---|
| 97 |
<xsl:template match="event"> |
|---|
| 98 |
<div class="event"> |
|---|
| 99 |
<span class="timestamp hidden">[</span> |
|---|
| 100 |
<span class="timestamp"> |
|---|
| 101 |
<xsl:call-template name="short-time"> |
|---|
| 102 |
<xsl:with-param name="date" select="@occurred" /> |
|---|
| 103 |
</xsl:call-template> |
|---|
| 104 |
</span> |
|---|
| 105 |
<span class="timestamp hidden">] </span> |
|---|
| 106 |
<xsl:apply-templates select="message/child::node()" mode="copy" /> |
|---|
| 107 |
<xsl:if test="string-length( reason )"> |
|---|
| 108 |
<span class="reason"> |
|---|
| 109 |
<xsl:text> (</xsl:text> |
|---|
| 110 |
<xsl:apply-templates select="reason/child::node()" mode="copy"/> |
|---|
| 111 |
<xsl:text>)</xsl:text> |
|---|
| 112 |
</span> |
|---|
| 113 |
</xsl:if> |
|---|
| 114 |
</div> |
|---|
| 115 |
</xsl:template> |
|---|
| 116 |
|
|---|
| 117 |
<xsl:template match="span[contains(@class,'member')]" mode="copy"> |
|---|
| 118 |
<a href="member:{current()}" class="member"><xsl:value-of select="current()" /></a> |
|---|
| 119 |
</xsl:template> |
|---|
| 120 |
|
|---|
| 121 |
<xsl:template match="@*|*" mode="copy"> |
|---|
| 122 |
<xsl:copy><xsl:apply-templates select="@*|node()" mode="copy" /></xsl:copy> |
|---|
| 123 |
</xsl:template> |
|---|
| 124 |
|
|---|
| 125 |
<xsl:template name="short-time"> |
|---|
| 126 |
<xsl:param name="date" /> <!-- YYYY-MM-DD HH:MM:SS +/-HHMM --> |
|---|
| 127 |
<xsl:variable name='hour' select='substring($date, 12, 2)' /> |
|---|
| 128 |
<xsl:variable name='minute' select='substring($date, 15, 2)' /> |
|---|
| 129 |
<xsl:choose> |
|---|
| 130 |
<xsl:when test="contains($timeFormat,'H')"> |
|---|
| 131 |
<!-- 24hr format --> |
|---|
| 132 |
<xsl:value-of select="concat($hour,':',$minute)" /> |
|---|
| 133 |
</xsl:when> |
|---|
| 134 |
<xsl:otherwise> |
|---|
| 135 |
<!-- am/pm format --> |
|---|
| 136 |
<xsl:choose> |
|---|
| 137 |
<xsl:when test="number($hour) > 12"> |
|---|
| 138 |
<xsl:value-of select="number($hour) - 12" /> |
|---|
| 139 |
</xsl:when> |
|---|
| 140 |
<xsl:when test="number($hour) = 0"> |
|---|
| 141 |
<xsl:text>12</xsl:text> |
|---|
| 142 |
</xsl:when> |
|---|
| 143 |
<xsl:otherwise> |
|---|
| 144 |
<xsl:value-of select="$hour" /> |
|---|
| 145 |
</xsl:otherwise> |
|---|
| 146 |
</xsl:choose> |
|---|
| 147 |
<xsl:text>:</xsl:text> |
|---|
| 148 |
<xsl:value-of select="$minute" /> |
|---|
| 149 |
<xsl:choose> |
|---|
| 150 |
<xsl:when test="number($hour) >= 12"> |
|---|
| 151 |
<xsl:text>pm</xsl:text> |
|---|
| 152 |
</xsl:when> |
|---|
| 153 |
<xsl:otherwise> |
|---|
| 154 |
<xsl:text>am</xsl:text> |
|---|
| 155 |
</xsl:otherwise> |
|---|
| 156 |
</xsl:choose> |
|---|
| 157 |
</xsl:otherwise> |
|---|
| 158 |
</xsl:choose> |
|---|
| 159 |
</xsl:template> |
|---|
| 160 |
</xsl:stylesheet> |
|---|