Difference between revisions of "User:Dyrcona/Colloquy"

From Apache OpenOffice Wiki
Jump to: navigation, search
(New page: Here is the script, just copy and paste and run it like the official one with xsltproc: <pre> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/...)
 
m
 
Line 23: Line 23:
 
                 <xsl:value-of select="../sender" /><xsl:text>: </xsl:text>
 
                 <xsl:value-of select="../sender" /><xsl:text>: </xsl:text>
 
                 <xsl:value-of select="normalize-space()" />
 
                 <xsl:value-of select="normalize-space()" />
  <xsl:text>
+
<xsl:text>
  </xsl:text>
+
</xsl:text>
 
                 </xsl:for-each>
 
                 </xsl:for-each>
 
             </xsl:when>
 
             </xsl:when>
Line 49: Line 49:
  
 
</xsl:stylesheet>
 
</xsl:stylesheet>
</pre>
 

Latest revision as of 00:39, 31 March 2008

Here is the script, just copy and paste and run it like the official one with xsltproc:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:output method="text" />

    <xsl:template match="/log/event | /log/envelope">
        <xsl:choose>
            <xsl:when test="local-name() = 'event'">
                <xsl:call-template name="timestamp">
                    <xsl:with-param name="date" select="@occurred" />
                </xsl:call-template>
                <xsl:text>» </xsl:text>
                <xsl:value-of select="normalize-space(message)" />
            </xsl:when>
            <xsl:when test="local-name() = 'envelope'">
              <xsl:for-each select="message">
                <xsl:call-template name="timestamp">
                    <xsl:with-param name="date" select="@received" />
                </xsl:call-template>
                <xsl:value-of select="../sender" /><xsl:text>: </xsl:text>
                <xsl:value-of select="normalize-space()" />
<xsl:text>
</xsl:text>
                </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>ERROR: can't handle "</xsl:text><xsl:value-of select="local-name()" /><xsl:text>"</xsl:text>
            </xsl:otherwise>
        </xsl:choose>
<xsl:text>
</xsl:text>
    </xsl:template>

    
    
    <xsl:template name="timestamp">
        <xsl:param name="date" /> <!-- YYYY-MM-DD HH:MM:SS +/-HHMM -->
    
        <xsl:text>[</xsl:text>
        <xsl:variable name='hour' select='substring($date, 1, 14)' />
        <xsl:variable name='minute' select='substring($date, 15, 5)' />
        <!-- 24hr format -->
        <xsl:value-of select="concat($hour,':',$minute)" />
        <xsl:text>] </xsl:text>
    </xsl:template>

</xsl:stylesheet>
Personal tools