File: todo-nodone-html.xslt

package info (click to toggle)
devtodo 0.1.20%2Bgit20200830.0ad52b0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 964 kB
  • sloc: ansic: 5,307; cpp: 3,908; perl: 112; sh: 106; makefile: 45; csh: 2
file content (108 lines) | stat: -rw-r--r-- 3,074 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?xml version="1.0"?>

<!--
	XSLT transform for making a colour HTML file out of a devtodo XML database.

	This was half derived from the XSLT transform from Daniel Patterson and
	half from the transform by Mark Eichin.

	It will output the todo database as colourised HTML, with done items struck
	out.

	If anybody has ANY enhancements to this file, PLEASE send them to me, as I
	have very little clue WRT XSLT and this file is just a hack.

	I generate HTML output with the following line (via libxslt):

		xsltproc todo-html.xslt .todo > ../todo.html
-->

<xsl:stylesheet xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output xsl:method="html" xsl:indent="yes"/>
	<xsl:strip-space xsl:elements="item bulletlist"/>

	<!-- body -->
	<xsl:template xsl:match="/">
  <!-- <xsl:apply-templates xsl:select="todo/title"/> -->
		<xsl:for-each xsl:select="todo/note|todo/link">
			<xsl:call-template xsl:name="noteItem"/>
		</xsl:for-each>
	</xsl:template>

 <xsl:template xsl:match="todo">
  <xsl:apply-templates xsl:select="title"/>
  <blockquote>
   <xsl:for-each xsl:select="note|link">
    <xsl:call-template xsl:name="noteItem"/>
   </xsl:for-each>
  </blockquote>
 </xsl:template>

 <xsl:template xsl:match="title">
  <p><b><xsl:value-of select="normalize-space(.)"/>:</b></p>
 </xsl:template>

	<xsl:template xsl:name="noteItem">
		<xsl:if test="not(@done)">
   <xsl:apply-templates xsl:select="."/>
		</xsl:if>
	</xsl:template>

	<xsl:template xsl:match="note">
  <xsl:choose>
   <xsl:when test="count(./note|link) > 0">
    <b>
     <xsl:call-template xsl:name="baseNote">
      <xsl:with-param name="append">:</xsl:with-param>
     </xsl:call-template>
    </b>
   </xsl:when>
   <xsl:otherwise>
    -- <xsl:call-template xsl:name="baseNote"/>
   </xsl:otherwise>
  </xsl:choose>
  <blockquote>
		<xsl:for-each xsl:select="note|link">
			<xsl:call-template xsl:name="noteItem"/>
		</xsl:for-each>
  </blockquote>
	</xsl:template>

 <xsl:template xsl:match="link">
  <xsl:apply-templates select="document(@filename)/todo"/>
 </xsl:template>

	<xsl:template xsl:name="baseNote">
  <xsl:param name="append"/>
		<xsl:variable xsl:name="priorityColor">
			<xsl:choose>
				<xsl:when xsl:test="@priority = 'veryhigh'">#FF0000</xsl:when>
				<xsl:when xsl:test="@priority = 'high'">#660000</xsl:when>
				<xsl:when xsl:test="@priority = 'medium'">#000000</xsl:when>
				<xsl:when xsl:test="@priority = 'low'">#0000F0</xsl:when>
				<xsl:when xsl:test="@priority = 'verylow'">#000066</xsl:when>
				<xsl:otherwise>#000000</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<!-- Done -->
		<xsl:if xsl:test="@done">
			<s>
			<font color="{$priorityColor}">
				<xsl:value-of xsl:select="normalize-space(child::text())"/>
    <xsl:value-of xsl:select="$append"/>
			</font>
			</s>
		</xsl:if>

		<!-- Not done -->
		<xsl:if xsl:test="not(@done)">
			<font color="{$priorityColor}">
				<xsl:value-of xsl:select="normalize-space(child::text())"/>
    <xsl:value-of xsl:select="$append"/>
			</font>
		</xsl:if>
	</xsl:template>

</xsl:stylesheet>