| 1 |
<?xml version="1.0"?> |
|---|
| 2 |
|
|---|
| 3 |
<!-- |
|---|
| 4 |
XSLT transform for making a colour HTML file out of a devtodo XML database. |
|---|
| 5 |
|
|---|
| 6 |
This was half derived from the XSLT transform from Daniel Patterson and |
|---|
| 7 |
half from the transform by Mark Eichin. |
|---|
| 8 |
|
|---|
| 9 |
It will output the todo database as colourised HTML, with done items struck |
|---|
| 10 |
out. |
|---|
| 11 |
|
|---|
| 12 |
If anybody has ANY enhancements to this file, PLEASE send them to me, as I |
|---|
| 13 |
have very little clue WRT XSLT and this file is just a hack. |
|---|
| 14 |
|
|---|
| 15 |
I generate HTML output with the following line (via libxslt): |
|---|
| 16 |
|
|---|
| 17 |
xsltproc todo-html.xslt .todo > ../todo.html |
|---|
| 18 |
--> |
|---|
| 19 |
|
|---|
| 20 |
<xsl:stylesheet xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
|---|
| 21 |
|
|---|
| 22 |
<xsl:output xsl:method="xml" xsl:indent="yes"/> |
|---|
| 23 |
<xsl:strip-space xsl:elements="item bulletlist"/> |
|---|
| 24 |
<xsl:preserve-space xsl:elements="preformatted"/> |
|---|
| 25 |
|
|---|
| 26 |
<!-- body --> |
|---|
| 27 |
<xsl:template xsl:match="/"> |
|---|
| 28 |
<html> |
|---|
| 29 |
<title> |
|---|
| 30 |
<xsl:variable xsl:name="title" select="todo/title"/> |
|---|
| 31 |
<xsl:choose> |
|---|
| 32 |
<xsl:when xsl:test = '$title=""'> |
|---|
| 33 |
Todo list |
|---|
| 34 |
</xsl:when> |
|---|
| 35 |
<xsl:otherwise> |
|---|
| 36 |
<xsl:value-of xsl:select="todo/title"/> |
|---|
| 37 |
</xsl:otherwise> |
|---|
| 38 |
</xsl:choose> |
|---|
| 39 |
</title> |
|---|
| 40 |
<body bgcolor="white" color="black"> |
|---|
| 41 |
<font color="black"> |
|---|
| 42 |
<center> |
|---|
| 43 |
<h1> |
|---|
| 44 |
<xsl:variable xsl:name="title" select="todo/title"/> |
|---|
| 45 |
<xsl:choose> |
|---|
| 46 |
<xsl:when xsl:test = '$title=""'> |
|---|
| 47 |
Todo list |
|---|
| 48 |
</xsl:when> |
|---|
| 49 |
<xsl:otherwise> |
|---|
| 50 |
<xsl:value-of xsl:select="todo/title"/> |
|---|
| 51 |
</xsl:otherwise> |
|---|
| 52 |
</xsl:choose> |
|---|
| 53 |
</h1> |
|---|
| 54 |
</center> |
|---|
| 55 |
<ul> |
|---|
| 56 |
<xsl:call-template xsl:name="noteList"/> |
|---|
| 57 |
</ul> |
|---|
| 58 |
</font> |
|---|
| 59 |
</body> |
|---|
| 60 |
</html> |
|---|
| 61 |
</xsl:template> |
|---|
| 62 |
|
|---|
| 63 |
<xsl:template xsl:name="noteList"> |
|---|
| 64 |
<xsl:for-each xsl:select="todo/note"> |
|---|
| 65 |
<xsl:call-template xsl:name="noteItem"/> |
|---|
| 66 |
</xsl:for-each> |
|---|
| 67 |
</xsl:template> |
|---|
| 68 |
|
|---|
| 69 |
<xsl:template xsl:name="noteItem"> |
|---|
| 70 |
<!-- Uncomment this to NOT display completed items --> |
|---|
| 71 |
<!-- <xsl:if not(@done)">--> |
|---|
| 72 |
<li type="disc"> |
|---|
| 73 |
<xsl:apply-templates xsl:select="."/> |
|---|
| 74 |
</li> |
|---|
| 75 |
<!-- </xsl:if>--> |
|---|
| 76 |
</xsl:template> |
|---|
| 77 |
|
|---|
| 78 |
<xsl:template xsl:match="note"> |
|---|
| 79 |
<xsl:call-template xsl:name="baseNote"/> |
|---|
| 80 |
<xsl:for-each xsl:select="./note"> |
|---|
| 81 |
<ul> |
|---|
| 82 |
<xsl:call-template xsl:name="noteItem"/> |
|---|
| 83 |
</ul> |
|---|
| 84 |
</xsl:for-each> |
|---|
| 85 |
</xsl:template> |
|---|
| 86 |
|
|---|
| 87 |
<xsl:template xsl:name="baseNote"> |
|---|
| 88 |
<xsl:variable xsl:name="priorityColor"> |
|---|
| 89 |
<xsl:choose> |
|---|
| 90 |
<xsl:when xsl:test="@priority = 'veryhigh'">red</xsl:when> |
|---|
| 91 |
<xsl:when xsl:test="@priority = 'high'">orange</xsl:when> |
|---|
| 92 |
<xsl:when xsl:test="@priority = 'medium'">black</xsl:when> |
|---|
| 93 |
<xsl:when xsl:test="@priority = 'low'">blue</xsl:when> |
|---|
| 94 |
<xsl:when xsl:test="@priority = 'verylow'">darkblue</xsl:when> |
|---|
| 95 |
<xsl:otherwise>black</xsl:otherwise> |
|---|
| 96 |
</xsl:choose> |
|---|
| 97 |
</xsl:variable> |
|---|
| 98 |
|
|---|
| 99 |
<!-- Done --> |
|---|
| 100 |
<xsl:if xsl:test="@done"> |
|---|
| 101 |
<s> |
|---|
| 102 |
<font color="{$priorityColor}"> |
|---|
| 103 |
<xsl:value-of xsl:select="child::text()"/> |
|---|
| 104 |
</font> |
|---|
| 105 |
</s> |
|---|
| 106 |
</xsl:if> |
|---|
| 107 |
|
|---|
| 108 |
<!-- Not done --> |
|---|
| 109 |
<xsl:if xsl:test="not(@done)"> |
|---|
| 110 |
<font color="{$priorityColor}"> |
|---|
| 111 |
<xsl:value-of xsl:select="child::text()"/> |
|---|
| 112 |
</font> |
|---|
| 113 |
</xsl:if> |
|---|
| 114 |
</xsl:template> |
|---|
| 115 |
|
|---|
| 116 |
</xsl:stylesheet> |
|---|