2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 <xsl:output method="xml" indent="no"
6 doctype-public="-//Norman Walsh//DTD Website Autolayout V2.5.0//EN"
7 doctype-system="http://docbook.sourceforge.net/release/website/2.5.0/schema/dtd/autolayout.dtd"
10 <xsl:strip-space elements="toc tocentry layout copyright"/>
12 <xsl:template match="layout">
14 <xsl:text> </xsl:text>
15 <xsl:apply-templates/>
17 <xsl:text> </xsl:text>
20 <xsl:template match="style|script|headlink|copyright|config">
21 <xsl:apply-templates select="." mode="copy"/>
24 <xsl:template match="*" mode="copy">
25 <xsl:element name="{name(.)}">
26 <xsl:copy-of select="@*"/>
27 <xsl:apply-templates mode="copy"/>
31 <xsl:template match="toc">
32 <xsl:if test="not(@page)">
33 <xsl:message terminate="yes">
34 <xsl:text>All toc entries must have a page attribute.</xsl:text>
38 <xsl:variable name="page" select="document(@page,.)"/>
41 <xsl:call-template name="tocentry"/>
43 <xsl:text> </xsl:text>
46 <xsl:template match="tocentry">
48 <xsl:call-template name="tocentry"/>
50 <xsl:text> </xsl:text>
53 <xsl:template match="notoc">
55 <xsl:call-template name="tocentry"/>
57 <xsl:text> </xsl:text>
60 <xsl:template name="tocentry">
61 <xsl:if test="@revisionflag">
62 <xsl:attribute name="revisionflag">
63 <xsl:value-of select="@revisionflag"/>
67 <xsl:when test="@href">
68 <xsl:call-template name="tocentry.href"/>
71 <xsl:call-template name="tocentry.page"/>
76 <xsl:template name="tocentry.href">
77 <xsl:if test="not(@href)">
78 <xsl:message terminate="yes">
79 <xsl:text>All toc entries must have an href attribute.</xsl:text>
83 <xsl:if test="not(@id)">
84 <xsl:message terminate="yes">
85 <xsl:text>All href toc entries must have an id attribute.</xsl:text>
90 <xsl:text>off site: </xsl:text>
91 <xsl:value-of select="@href"/>
94 <xsl:attribute name="id">
95 <xsl:value-of select="@id"/>
97 <xsl:attribute name="href">
98 <xsl:value-of select="@href"/>
100 <xsl:if test="@tocskip = '1'">
101 <xsl:attribute name="tocskip">
102 <xsl:value-of select="@tocskip"/>
106 <xsl:if test="not(title)">
107 <xsl:message terminate="yes">
108 <xsl:text>Off-site links must provide a title.</xsl:text>
112 <xsl:text> </xsl:text>
113 <xsl:apply-templates select="title|titleabbrev|summary" mode="copy"/>
114 <xsl:text> </xsl:text>
115 <xsl:apply-templates select="tocentry"/>
118 <xsl:template name="tocentry.page">
119 <xsl:if test="not(@page)">
120 <xsl:message terminate="yes">
121 <xsl:text>All toc entries must have a page attribute.</xsl:text>
125 <xsl:variable name="page" select="document(@page,.)"/>
127 <xsl:if test="not($page/*[1]/@id)">
128 <xsl:message terminate="yes">
129 <xsl:value-of select="@page"/>
130 <xsl:text>: missing ID.</xsl:text>
134 <xsl:variable name="id" select="$page/*[1]/@id"/>
136 <xsl:variable name="filename">
138 <xsl:when test="@filename">
139 <xsl:value-of select="@filename"/>
141 <xsl:when test="/layout/config[@param='default-filename']">
142 <xsl:value-of select="(/layout/config[@param='default-filename'])[1]/@value"/>
144 <xsl:otherwise>index.html</xsl:otherwise>
148 <xsl:variable name="dir">
149 <xsl:apply-templates select="." mode="calculate-dir"/>
152 <xsl:if test="$filename = ''">
153 <xsl:message terminate="yes">
154 <xsl:value-of select="@page"/>
155 <xsl:text>: missing filename.</xsl:text>
160 <xsl:value-of select="@page"/>
161 <xsl:text>: </xsl:text>
162 <xsl:if test="$dir != ''">
163 <xsl:value-of select="$dir"/>
165 <xsl:value-of select="$filename"/>
168 <xsl:attribute name="page">
169 <xsl:value-of select="@page"/>
171 <xsl:attribute name="id">
172 <xsl:value-of select="$id"/>
174 <xsl:if test="$dir != ''">
175 <xsl:attribute name="dir">
176 <xsl:value-of select="$dir"/>
179 <xsl:attribute name="filename">
180 <xsl:value-of select="$filename"/>
182 <xsl:if test="@tocskip = '1'">
183 <xsl:attribute name="tocskip">
184 <xsl:value-of select="@tocskip"/>
188 <xsl:text> </xsl:text>
190 <xsl:when test="title">
191 <xsl:apply-templates select="title" mode="copy"/>
195 <xsl:apply-templates select="$page/*[1]/head/title"/>
199 <xsl:text> </xsl:text>
201 <xsl:if test="titleabbrev or $page/*[1]/head/titleabbrev">
203 <xsl:when test="titleabbrev">
204 <xsl:apply-templates select="titleabbrev" mode="copy"/>
208 <xsl:apply-templates select="$page/*[1]/head/titleabbrev"/>
212 <xsl:text> </xsl:text>
215 <xsl:if test="summary or $page/*[1]/head/summary">
217 <xsl:when test="summary">
218 <xsl:apply-templates select="summary" mode="copy"/>
222 <xsl:apply-templates select="$page/*[1]/head/summary"/>
226 <xsl:text> </xsl:text>
229 <xsl:apply-templates select="tocentry"/>
232 <xsl:template match="*" mode="calculate-dir">
234 <xsl:when test="starts-with(@dir, '/')">
235 <!-- if the directory on this begins with a "/", we're done... -->
236 <xsl:value-of select="substring-after(@dir, '/')"/>
237 <xsl:text>/</xsl:text>
240 <xsl:when test="parent::*">
241 <!-- if there's a parent, try it -->
242 <xsl:apply-templates select="parent::*" mode="calculate-dir"/>
244 <xsl:value-of select="@dir"/>
245 <xsl:text>/</xsl:text>
251 <xsl:value-of select="@dir"/>
252 <xsl:text>/</xsl:text>