Posted By

mustam on 08/27/09


Tagged

stylesheet twitter logging


Versions (?)

Stylesheet for twitter-log file


 / Published in: XSLT
 

This is xslt file for twitter-logged xml file.

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- vim: ts=2 sw=2 expandtab
  3. -->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  5. <xsl:output method="html" encoding="UTF-8"/>
  6. <xsl:template match="/">
  7. <html>
  8. <head><title>busata log (size: <xsl:value-of select="count(statuses/status)"/>)</title></head>
  9. <body>
  10. <table><tr style="background: gray; color: white;"><th>ID</th><th>TEXT</th><th>DATE</th></tr>
  11. <xsl:for-each select="statuses/status">
  12. <xsl:sort select="created_at.epoch" order="ascending" data-type="number"/>
  13. <tr>
  14. <td style="color: #333; font-size: x-small;"><xsl:value-of select="id"/></td>
  15. <xsl:apply-templates select="text" />
  16. <td style="color: #333; font-size: small;"><xsl:value-of select="created_at"/></td>
  17. </tr>
  18. </xsl:for-each>
  19. </table>
  20. </body></html>
  21. </xsl:template>
  22.  
  23. <xsl:template match="text">
  24. <xsl:choose>
  25. <xsl:when test="contains(., 'http://')">
  26. <td>
  27. <xsl:value-of select="substring-before(., 'http://')"/>
  28. <a><xsl:attribute name="href">http://<xsl:value-of select="substring-after(., 'http://')"/></xsl:attribute>http://<xsl:value-of select="substring-after(., 'http://')"/></a>
  29. </td>
  30. </xsl:when>
  31. <xsl:otherwise>
  32. <td><xsl:value-of select="."/></td>
  33. </xsl:otherwise>
  34. </xsl:choose>
  35. </xsl:template>
  36. </xsl:stylesheet>

Report this snippet  

You need to login to post a comment.