要么孵化 要么臭掉
自定义MSN的日志显示风格
对我来说,MSN Messenger自带的聊天记录保存在我需要查看聊天历史记录的时候,那个聊天历史列表无法让我满意。第一,他会显示完整的用户昵称。当用户的昵称写的非常长的时候,你会看到满屏的都是那些长长的昵称,这让我很不爽;第二,对于多行的消息会合并成一行,当我要查找一些源代码之类的历史记录的时候会发现拷贝下来的东西变成了一行,不得不重新整理;第三,我喜欢聊天记录按照时间倒序排列。
既然这么多让我不爽的地方,我就要看看有没有可能按照自己的喜好来设置历史记录的显示风格了。还好,微软的这个功能蛮Open,在你的聊天历史记录保存文件夹下面可以看到很多xml文件,那都是你和每个联系人的聊天记录内容。还有一个MessageLog.xsl文件,正是这个文件定义了如何读取和显示所有的聊天记录xml文件。
对于知道xsl语法的朋友来说,找到了这个定义聊天记录xml文件如何显示的定义文件所在,就完全按照自己的喜好来显示聊天记录了。
以下是我自己修改以后的MessageLog.xsl版本,有兴趣的朋友可以拷贝下来替换原来的MessageLog.xsl看看效果(不过请做好备份先):
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- localized strings -->
<xsl:variable name='ColumnHeader_Date'>日期</xsl:variable>
<xsl:variable name='ColumnHeader_Time'>时间</xsl:variable>
<xsl:variable name='ColumnHeader_From'>发送者</xsl:variable>
<xsl:variable name='ColumnHeader_To'>接收者</xsl:variable>
<xsl:variable name='ColumnHeader_Message'>消息</xsl:variable>
<!-- variables --><xsl:variable name='Debug'>0</xsl:variable>
<xsl:variable name='TableStyle'>font-family:Courier New; font-size:12px; text-align:left; vertical-align:top; </xsl:variable>
<xsl:variable name='GutterStyle'>width:2ex</xsl:variable>
<xsl:variable name='HeaderStyle'>border-bottom:1 solid black</xsl:variable>
<xsl:variable name='UseZebraStripe'>1</xsl:variable>
<xsl:variable name='ZebraStripeStyle'>background-color:#e0edff</xsl:variable>
<xsl:variable name='MostRecentSessionFirst'>1</xsl:variable>
<xsl:template match="Log">
<html dir='ltr'>
<head>
<title>
Message Log for <xsl:value-of select="@LogonName"/>
<xsl:if test="$Debug = 1"> (Debug)</xsl:if>
</title>
<xsl:if test="$Debug = 1">
<span style="font-family:trebuchet ms; font-size:120%">
Debug Version
</span>
<hr/>
</xsl:if>
</head>
<body style='margin:0'>
<table id='BodyTable' style="{$TableStyle}" cellspacing='0'>
<xsl:if test="$Debug = 1">
<col style="vertical-align:top; width:100%;"/>
</xsl:if>
<col style="width:100%;padding-left:2px;padding-top:2px;padding-right:2px;padding-bottom:2px;"/>
<thead>
<tr>
<th style="{$HeaderStyle}">
<xsl:if test="$Debug = 1">
SID =>
</xsl:if>
<xsl:value-of select="$ColumnHeader_Date"/> <xsl:value-of select="$ColumnHeader_Time"/> <xsl:value-of select="$ColumnHeader_From"/> <xsl:value-of select="$ColumnHeader_To"/> <xsl:value-of select="$ColumnHeader_Message"/>
</th>
</tr>
</thead>
<tbody style='vertical-align:top'>
<xsl:choose>
<!-- newest session first -->
<xsl:when test="$MostRecentSessionFirst = 1">
<xsl:apply-templates>
<xsl:sort select='@SessionID' order='descending' data-type='number'/>
<xsl:sort select='@DateTime' order='descending' />
</xsl:apply-templates>
</xsl:when>
<!-- oldest session first -->
<xsl:otherwise>
<xsl:apply-templates>
<xsl:sort select='@SessionID' order='ascending' data-type='number'/>
<xsl:sort select='@DateTime' order='ascending'/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="Message">
<tr>
<td>
<xsl:call-template name="CommonMessageProcessing" />
<font color="blue"><xsl:apply-templates select="From/User"/></font> 对
<font color="green"><xsl:apply-templates select="To/User"/></font> 说:<br />
<span>
<xsl:attribute name="style">
<xsl:value-of select="Text/@Style"/>
</xsl:attribute>
<pre><xsl:value-of select="Text"/></pre>
</span>
</td>
</tr>
</xsl:template>
<xsl:template match="Invitation|InvitationResponse|Join|Leave">
<tr>
<td>
<xsl:call-template name="CommonMessageProcessing" />
<!-- From --> <!-- To --> : <br />
<span>
<xsl:attribute name="style">
<xsl:value-of select="Text/@Style"/>
</xsl:attribute>
<xsl:value-of select="Text"/>
</span>
</td>
</tr>
</xsl:template>
<xsl:template match="User">
<!-- add a comma before all but the first user -->
<xsl:if test="position() != 1">, </xsl:if>
<xsl:value-of select="substring(@FriendlyName,1,10)"/>
</xsl:template>
<xsl:template name="CommonMessageProcessing">
<!-- zebra-stripe the sessions -->
<xsl:if test="$UseZebraStripe = 1">
<xsl:if test="(position() mod 2) = 1">
<xsl:attribute name="style">
<xsl:value-of select="$ZebraStripeStyle"/>
</xsl:attribute>
</xsl:if>
</xsl:if>
<xsl:if test="$Debug = 1">
<b><i>
<xsl:value-of select="@SessionID"/> =>
</i></b>
</xsl:if>
<b><xsl:value-of select="@Date"/> <xsl:value-of select="@Time"/></b>
</xsl:template>
</xsl:stylesheet>
其中<xsl:variable name='MostRecentSessionFirst'>1</xsl:variable>设置了按时间排序是倒序还是升序。
