1 | <?xml version="1.0"?>
|
---|
2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
3 | version="1.0">
|
---|
4 |
|
---|
5 | <xsl:param name="filename-prefix" select="''"/>
|
---|
6 | <xsl:param name="depends-file" select="''"/>
|
---|
7 | <xsl:param name="output-root" select="''"/>
|
---|
8 | <!-- Additional dependencies for target website -->
|
---|
9 | <xsl:param name="add-website-depends" select="''"/>
|
---|
10 | <!-- Remove output root dir instead removing each html output file.
|
---|
11 | Useful for removing subdirs and none html files: images, css etc. -->
|
---|
12 | <xsl:param name="remove-output-root" select="0"/>
|
---|
13 |
|
---|
14 | <xsl:output method="text"/>
|
---|
15 |
|
---|
16 | <xsl:template match="autolayout">
|
---|
17 | <xsl:text>website: </xsl:text>
|
---|
18 | <xsl:value-of select="$add-website-depends"/>
|
---|
19 | <xsl:text> </xsl:text>
|
---|
20 | <xsl:apply-templates select="toc" mode="all"/>
|
---|
21 | <xsl:apply-templates select="notoc" mode="all"/>
|
---|
22 | <xsl:text> </xsl:text>
|
---|
23 | <xsl:apply-templates select="toc"/>
|
---|
24 | <xsl:apply-templates select="notoc"/>
|
---|
25 | <xsl:text> </xsl:text>
|
---|
26 | <xsl:text>distclean: clean
|
---|
27 | 	-rm -f </xsl:text>
|
---|
28 | <xsl:text>autolayout.xml website.database.xml </xsl:text>
|
---|
29 | <xsl:text> </xsl:text>
|
---|
30 | <xsl:value-of select="$depends-file"/>
|
---|
31 | <xsl:text> </xsl:text>
|
---|
32 | <xsl:text>clean: </xsl:text>
|
---|
33 | <xsl:choose>
|
---|
34 | <xsl:when test="$remove-output-root and not($output-root='')">
|
---|
35 | <xsl:text>	-rm -rf </xsl:text>
|
---|
36 | <xsl:call-template name="output-root"/>
|
---|
37 | </xsl:when>
|
---|
38 | <xsl:otherwise>
|
---|
39 | <xsl:text>	-rm -f </xsl:text>
|
---|
40 | <xsl:apply-templates select="toc" mode="all"/>
|
---|
41 | <xsl:apply-templates select="notoc" mode="all"/>
|
---|
42 | </xsl:otherwise>
|
---|
43 | </xsl:choose>
|
---|
44 | <xsl:text> </xsl:text>
|
---|
45 | </xsl:template>
|
---|
46 |
|
---|
47 | <xsl:template match="toc">
|
---|
48 | <!--
|
---|
49 | <xsl:apply-templates select="." mode="calculate-dir"/>
|
---|
50 | -->
|
---|
51 | <xsl:call-template name="output-root"/>
|
---|
52 | <xsl:value-of select="@dir"/>
|
---|
53 | <xsl:value-of select="$filename-prefix"/>
|
---|
54 | <xsl:value-of select="@filename"/>
|
---|
55 | <xsl:text>: </xsl:text>
|
---|
56 | <xsl:value-of select="@page"/>
|
---|
57 | <xsl:text> </xsl:text>
|
---|
58 | <xsl:apply-templates select=".//tocentry"/>
|
---|
59 | </xsl:template>
|
---|
60 |
|
---|
61 | <xsl:template match="tocentry|notoc">
|
---|
62 | <!--
|
---|
63 | <xsl:apply-templates select="." mode="calculate-dir"/>
|
---|
64 | -->
|
---|
65 | <xsl:if test="@filename">
|
---|
66 | <xsl:call-template name="output-root"/>
|
---|
67 | <xsl:value-of select="@dir"/>
|
---|
68 | <xsl:value-of select="$filename-prefix"/>
|
---|
69 | <xsl:value-of select="@filename"/>
|
---|
70 | <xsl:text>: </xsl:text>
|
---|
71 | <xsl:value-of select="@page"/>
|
---|
72 | <xsl:text> </xsl:text>
|
---|
73 | </xsl:if>
|
---|
74 | </xsl:template>
|
---|
75 |
|
---|
76 | <xsl:template match="toc" mode="all">
|
---|
77 | <xsl:apply-templates select=".//tocentry" mode="all"/>
|
---|
78 | <!--
|
---|
79 | <xsl:apply-templates select="." mode="calculate-dir"/>
|
---|
80 | -->
|
---|
81 | <xsl:call-template name="output-root"/>
|
---|
82 | <xsl:value-of select="@dir"/>
|
---|
83 | <xsl:value-of select="$filename-prefix"/>
|
---|
84 | <xsl:value-of select="@filename"/>
|
---|
85 | <xsl:text> </xsl:text>
|
---|
86 | </xsl:template>
|
---|
87 |
|
---|
88 | <xsl:template match="tocentry|notoc" mode="all">
|
---|
89 | <!--
|
---|
90 | <xsl:apply-templates select="." mode="calculate-dir"/>
|
---|
91 | -->
|
---|
92 | <xsl:if test="@filename">
|
---|
93 | <xsl:call-template name="output-root"/>
|
---|
94 | <xsl:value-of select="@dir"/>
|
---|
95 | <xsl:value-of select="$filename-prefix"/>
|
---|
96 | <xsl:value-of select="@filename"/>
|
---|
97 | <xsl:text> </xsl:text>
|
---|
98 | </xsl:if>
|
---|
99 | </xsl:template>
|
---|
100 |
|
---|
101 | <xsl:template match="*" mode="calculate-dir">
|
---|
102 | <xsl:choose>
|
---|
103 | <xsl:when test="starts-with(@dir, '/')">
|
---|
104 | <!-- if the directory on this begins with a "/", we're done... -->
|
---|
105 | <xsl:value-of select="substring-after(@dir, '/')"/>
|
---|
106 | <!--
|
---|
107 | <xsl:if test="@dir != '/'">
|
---|
108 | <xsl:text>/</xsl:text>
|
---|
109 | </xsl:if>
|
---|
110 | -->
|
---|
111 | </xsl:when>
|
---|
112 |
|
---|
113 | <xsl:when test="parent::*">
|
---|
114 | <!-- if there's a parent, try it -->
|
---|
115 | <xsl:apply-templates select="parent::*" mode="calculate-dir"/>
|
---|
116 | <xsl:if test="@dir">
|
---|
117 | <xsl:value-of select="@dir"/>
|
---|
118 | <!--
|
---|
119 | <xsl:text>/</xsl:text>
|
---|
120 | -->
|
---|
121 | </xsl:if>
|
---|
122 | </xsl:when>
|
---|
123 |
|
---|
124 | <xsl:otherwise>
|
---|
125 | <xsl:if test="@dir">
|
---|
126 | <xsl:value-of select="@dir"/>
|
---|
127 | <!--
|
---|
128 | <xsl:text>/</xsl:text>
|
---|
129 | -->
|
---|
130 | </xsl:if>
|
---|
131 | </xsl:otherwise>
|
---|
132 | </xsl:choose>
|
---|
133 | </xsl:template>
|
---|
134 |
|
---|
135 | <xsl:template name="output-root">
|
---|
136 | <xsl:if test="$output-root != ''">
|
---|
137 | <xsl:value-of select="$output-root"/>
|
---|
138 | <xsl:text>/</xsl:text>
|
---|
139 | </xsl:if>
|
---|
140 | </xsl:template>
|
---|
141 |
|
---|
142 |
|
---|
143 | </xsl:stylesheet>
|
---|