Gentoo Archives: gentoo-commits

From: "Xavier Neys (neysx)" <neysx@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo commit in xml/htdocs/xsl: doc-struct.xsl
Date: Tue, 01 Jan 2008 21:29:52
Message-Id: E1J9ogE-00072g-TL@stork.gentoo.org
1 neysx 08/01/01 21:29:46
2
3 Added: doc-struct.xsl
4 Log:
5 Added support for included bits
6
7 Revision Changes Path
8 1.1 xml/htdocs/xsl/doc-struct.xsl
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/doc-struct.xsl?rev=1.1&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/doc-struct.xsl?rev=1.1&content-type=text/plain
12
13 Index: doc-struct.xsl
14 ===================================================================
15 <?xml version="1.0" encoding="UTF-8"?>
16 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
17 xmlns:func="http://exslt.org/functions"
18 xmlns:exslt="http://exslt.org/common"
19 xmlns:date="http://exslt.org/dates-and-times"
20 xmlns:str="http://exslt.org/strings"
21 xmlns:dyn="http://exslt.org/dynamic"
22 extension-element-prefixes="exslt func date str dyn">
23
24 <!-- Go through doc, parse tests & includes to build
25 result doc structure with all chapters/sections/bodies -->
26
27 <xsl:variable name="doc-struct" xmlns="">
28 <xsl:call-template name="build-doc-struct">
29 <xsl:with-param name="doc" select="/"/>
30 </xsl:call-template>
31 </xsl:variable>
32
33 <xsl:template name="build-doc-struct" xmlns="">
34 <xsl:param name="doc"/>
35 <doc-struct>
36 <xsl:attribute name="type"><xsl:value-of select="name($doc/*[1])"/></xsl:attribute>
37 <xsl:if test="$doc/*[1]/date">
38 <date><xsl:value-of select="$doc/*[1]/date"/></date>
39 </xsl:if>
40 <xsl:if test="$doc/*[1]/version">
41 <version><xsl:value-of select="$doc/*[1]/version"/></version>
42 </xsl:if>
43 <xsl:choose>
44 <xsl:when test="$doc/book">
45 <xsl:for-each select="$doc/book/part">
46 <xsl:variable name="curpart" select="position()"/>
47 <bookpart pos="{$curpart}">
48 <xsl:for-each select="chapter">
49 <xsl:variable name="curchap" select="position()"/>
50 <bookchap pos="{$curchap}">
51 <xsl:if test="$full='1' or ($curpart=$part and $curchap=$chap)">
52 <xsl:variable name="inc" select="document(include/@href)"/>
53 <xsl:if test="$inc/sections/date">
54 <date><xsl:value-of select="$inc/sections/date"/></date>
55 </xsl:if>
56 <xsl:if test="$inc/sections/version">
57 <version><xsl:value-of select="$inc/sections/version"/></version>
58 </xsl:if>
59 <xsl:for-each select="$inc/sections/section[not(@test) or dyn:evaluate(@test)]">
60 <xsl:call-template name="doc-struct-chapters">
61 <xsl:with-param name="chapter" select="."/>
62 </xsl:call-template>
63 </xsl:for-each>
64 </xsl:if>
65 </bookchap>
66 </xsl:for-each>
67 </bookpart>
68 </xsl:for-each>
69 </xsl:when>
70 <xsl:otherwise>
71 <xsl:for-each select="$doc//faqindex | $doc/*[1]/chapter[not(@test) or dyn:evaluate(@test)]">
72 <xsl:call-template name="doc-struct-chapters">
73 <xsl:with-param name="chapter" select="."/>
74 </xsl:call-template>
75 </xsl:for-each>
76 </xsl:otherwise>
77 </xsl:choose>
78 </doc-struct>
79 </xsl:template>
80
81 <xsl:template name="doc-struct-chapters" xmlns="">
82 <xsl:param name="chapter"/>
83 <xsl:choose>
84 <xsl:when test="$chapter/include">
85 <xsl:variable name="inc" select="document($chapter/include/@href)"/>
86 <xsl:if test="$inc//date">
87 <date><xsl:value-of select="$inc//date"/></date>
88 </xsl:if>
89 <xsl:if test="$inc//version">
90 <version><xsl:value-of select="$inc//version"/></version>
91 </xsl:if>
92 <xsl:for-each select="$inc//chapter[not(@test) or dyn:evaluate(@test)]">
93 <xsl:call-template name="doc-struct-chapters">
94 <xsl:with-param name="chapter" select="."/>
95 </xsl:call-template>
96 </xsl:for-each>
97 </xsl:when>
98 <xsl:otherwise>
99 <chapter uid="{generate-id($chapter)}" title="{$chapter/title}">
100 <xsl:if test="$chapter/@id"><xsl:attribute name="id"><xsl:value-of select="$chapter/@id"/></xsl:attribute></xsl:if>
101 <xsl:choose>
102 <xsl:when test="body">
103 <!-- Handbook section without subsection(s), bodies only -->
104 <xsl:for-each select="$chapter/body[not(@test) or dyn:evaluate(@test)]">
105 <xsl:call-template name="doc-struct-bodies">
106 <xsl:with-param name="body" select="."/>
107 </xsl:call-template>
108 </xsl:for-each>
109 </xsl:when>
110 <xsl:otherwise>
111 <xsl:for-each select="$chapter/section[not(@test) or dyn:evaluate(@test)] | $chapter/subsection[not(@test) or dyn:evaluate(@test)]">
112 <xsl:call-template name="doc-struct-sections">
113 <xsl:with-param name="section" select="."/>
114 </xsl:call-template>
115 </xsl:for-each>
116 </xsl:otherwise>
117 </xsl:choose>
118 </chapter>
119 </xsl:otherwise>
120 </xsl:choose>
121 </xsl:template>
122
123 <xsl:template name="doc-struct-sections" xmlns="">
124 <xsl:param name="section"/>
125 <xsl:choose>
126 <xsl:when test="$section/include">
127 <xsl:variable name="inc" select="document($section/include/@href)"/>
128 <xsl:if test="$inc//date">
129 <date><xsl:value-of select="$inc//date"/></date>
130 </xsl:if>
131 <xsl:if test="$inc//version">
132 <version><xsl:value-of select="$inc//version"/></version>
133 </xsl:if>
134 <xsl:for-each select="$inc//section[not(@test) or dyn:evaluate(@test)]">
135 <xsl:call-template name="doc-struct-sections">
136 <xsl:with-param name="section" select="."/>
137 </xsl:call-template>
138 </xsl:for-each>
139 </xsl:when>
140 <xsl:when test="$section/body">
141 <section uid="{generate-id($section)}" title="{$section/title}">
142 <xsl:if test="$section/@id"><xsl:attribute name="id"><xsl:value-of select="$section/@id"/></xsl:attribute></xsl:if>
143 <xsl:for-each select="$section/body[not(@test) or dyn:evaluate(@test)]">
144 <xsl:call-template name="doc-struct-bodies">
145 <xsl:with-param name="body" select="."/>
146 </xsl:call-template>
147 </xsl:for-each>
148 </section>
149 </xsl:when>
150 <xsl:otherwise>
151 <section uid="{generate-id($section)}" title="{$section/title}">
152 <!-- bodyless section in old invalid files -->
153 <xsl:call-template name="doc-struct-bodies">
154 <xsl:with-param name="body" select="$section"/>
155 </xsl:call-template>
156 </section>
157 </xsl:otherwise>
158 </xsl:choose>
159 </xsl:template>
160
161 <xsl:template name="doc-struct-bodies" xmlns="">
162 <xsl:param name="body"/>
163 <xsl:choose>
164 <xsl:when test="$body/include">
165 <xsl:variable name="inc" select="document($body/include/@href)"/>
166 <xsl:if test="$inc//date">
167 <date><xsl:value-of select="$inc//date"/></date>
168 </xsl:if>
169 <xsl:if test="$inc//version">
170 <version><xsl:value-of select="$inc//version"/></version>
171 </xsl:if>
172 <xsl:for-each select="$inc//body[not(@test) or dyn:evaluate(@test)]">
173 <xsl:call-template name="doc-struct-bodies">
174 <xsl:with-param name="body" select="."/>
175 </xsl:call-template>
176 </xsl:for-each>
177 </xsl:when>
178 <xsl:otherwise>
179 <body uid="{generate-id($body)}">
180
181 <xsl:for-each select="$body/pre[not(@test) or dyn:evaluate(@test)] | $body/figure[not(@test) or dyn:evaluate(@test)]">
182 <xsl:element name="{name()}">
183 <xsl:attribute name="uid">
184 <xsl:value-of select="generate-id(.)"/>
185 </xsl:attribute>
186 </xsl:element>
187 </xsl:for-each>
188
189 </body>
190 </xsl:otherwise>
191 </xsl:choose>
192 </xsl:template>
193
194 </xsl:stylesheet>
195
196
197
198 --
199 gentoo-commits@g.o mailing list