/[gentoo]/xml/htdocs/xsl/guidexml2wiki.xsl
Gentoo

Contents of /xml/htdocs/xsl/guidexml2wiki.xsl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download) (as text)
Sat Aug 3 16:35:01 2013 UTC (7 years ago) by swift
Branch: MAIN
Changes since 1.7: +14 -0 lines
File MIME type: application/xml
Support include directive as used by gentoo-x86-quickinstall.xml

1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
3 xmlns:exslt="http://exslt.org/common"
4 xmlns:func="http://exslt.org/functions"
5 xmlns:dyn="http://exslt.org/dynamic"
6 xmlns:str="http://exslt.org/strings"
7
8 xmlns:feed="http://www.w3.org/2005/Atom"
9
10 xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
11 exclude-result-prefixes="opensearch feed"
12
13 extension-element-prefixes="exslt func dyn str" >
14
15 <xsl:output encoding="UTF-8" method="text" indent="no" />
16 <xsl:preserve-space elements="pre" />
17 <!-- <xsl:preserve-space elements="li p pre" /> -->
18
19 <xsl:template match="guide"><xsl:value-of select="normalize-space(abstract)" />
20 <xsl:apply-templates />
21 <xsl:if test="//guide/author[not(@title='script generated')]">
22 == Acknowledgements ==
23
24 We would like to thank the following authors and editors for their contributions to this guide:
25 <xsl:for-each select="//guide/author">
26 * <xsl:choose><xsl:when test="mail/text()"><xsl:value-of select="mail" /></xsl:when><xsl:when test="mail"><xsl:value-of select="mail/@link" /></xsl:when><xsl:otherwise><xsl:value-of select="normalize-space()" /></xsl:otherwise></xsl:choose>
27 </xsl:for-each>
28 </xsl:if>
29
30 [[Category:Server and Security]]
31 </xsl:template>
32
33 <xsl:template match="author" />
34
35 <xsl:template match="abstract" />
36
37 <xsl:template match="chapter">
38 <!-- Ignore developers and subprojects as these will be provided by the wiki itself. -->
39 <xsl:if test="not(title='Developers') and not(title='Subprojects')">
40 == <xsl:value-of select="title" /> ==<xsl:text>
41
42 </xsl:text>
43 <xsl:apply-templates />
44 </xsl:if>
45 </xsl:template>
46
47 <xsl:template match="section">
48 <xsl:if test="preceding-sibling::section"><xsl:text>
49 </xsl:text>
50 </xsl:if>
51 <xsl:if test="title">
52 === <xsl:value-of select="title" /> ===<xsl:text>
53
54 </xsl:text>
55 </xsl:if>
56 <xsl:choose>
57 <xsl:when test="include">
58 <xsl:variable name="doc" select="include/@href" />
59 <xsl:for-each select="document($doc)/included/section">
60 <xsl:if test="title">
61 === <xsl:value-of select="title" /> ===<xsl:text>
62
63 </xsl:text>
64 </xsl:if>
65 <xsl:apply-templates />
66 </xsl:for-each>
67 </xsl:when>
68 <xsl:otherwise>
69 <xsl:apply-templates />
70 </xsl:otherwise>
71 </xsl:choose>
72 </xsl:template>
73
74 <xsl:template match="body"><xsl:apply-templates /></xsl:template>
75
76 <!--
77 i is for in-pre commands, we cannot support that easily as we have no
78 knowledge of what needs to be RootCmd, UserCmd, what is output, etc.
79 -->
80 <xsl:template match="i"><xsl:apply-templates /></xsl:template>
81
82 <xsl:template match="mail"><xsl:if test="string-length(preceding-sibling::text()) &gt; 1"><xsl:text> </xsl:text></xsl:if><xsl:choose><xsl:when test="link">{{Mail|<xsl:value-of select="@link" />|<xsl:value-of select="normalize-space()" />}}</xsl:when><xsl:otherwise>{{Mail|<xsl:value-of select="normalize-space()" />}}</xsl:otherwise></xsl:choose></xsl:template>
83
84 <xsl:template match="p"><xsl:apply-templates /><xsl:text>
85
86 </xsl:text>
87 </xsl:template>
88
89 <xsl:template match="br" />
90 <xsl:template match="license" />
91
92 <!--
93 var is formatting in pre, difficult to handle this
94 -->
95 <xsl:template match="var"><xsl:apply-templates /></xsl:template>
96
97 <!--
98 stmt is formatting in pre, difficult to handle this
99 -->
100 <xsl:template match="stmt"><xsl:apply-templates /></xsl:template>
101
102 <!--
103 const is formatting in pre, difficult to handle this
104 -->
105 <xsl:template match="const"><xsl:apply-templates /></xsl:template>
106
107 <xsl:template match="uri"><xsl:if test="string-length(preceding-sibling::text()) &gt; 1"><xsl:text> </xsl:text></xsl:if><xsl:choose><xsl:when test="starts-with(@link, 'http')">[<xsl:value-of select="@link" /><xsl:text> </xsl:text><xsl:value-of select="normalize-space(text())" />]</xsl:when><xsl:when test="not(starts-with(@link, '#'))">[http://www.gentoo.org/<xsl:value-of select="@link"/><xsl:text> </xsl:text><xsl:value-of select="normalize-space(text())" />]</xsl:when><xsl:when test="starts-with(@link, '#')">[[<xsl:value-of select="@link" />]]</xsl:when></xsl:choose><xsl:if test="string-length(following-sibling::text()) &gt; 1"><xsl:text> </xsl:text></xsl:if></xsl:template>
108
109 <xsl:template match="e"> ''<xsl:apply-templates />'' </xsl:template>
110
111 <xsl:template match="ul"><xsl:text>
112 </xsl:text><xsl:apply-templates /><xsl:text>
113 </xsl:text>
114 </xsl:template>
115
116 <xsl:template match="ol">
117 <xsl:apply-templates /></xsl:template>
118
119 <xsl:template match="li">
120 <xsl:choose><xsl:when test="name(..)='ul'"><xsl:for-each select="ancestor::ul|ancestor::ol">*</xsl:for-each><xsl:text> </xsl:text><xsl:apply-templates /></xsl:when><xsl:when test="name(..)='ol'"><xsl:for-each select="ancestor::ol|ancestor::ul">#</xsl:for-each><xsl:text> </xsl:text><xsl:apply-templates /></xsl:when><xsl:otherwise>OH NOES HERE IT GOES!</xsl:otherwise></xsl:choose><xsl:text>
121 </xsl:text>
122 </xsl:template>
123
124 <xsl:template match="sup">&lt;sup&gt;<xsl:apply-templates />&lt;/sup&gt;</xsl:template>
125
126 <xsl:template match="sub">&lt;sub&gt;<xsl:apply-templates />&lt;/sub&gt;</xsl:template>
127
128 <xsl:template match="title" />
129
130 <xsl:template match="date" />
131
132 <xsl:template match="version" />
133
134 <xsl:template match="c"><xsl:if test="string-length(preceding-sibling::text()) &gt; 1"><xsl:text> </xsl:text></xsl:if>&lt;code&gt;<xsl:apply-templates />&lt;/code&gt;<xsl:if test="string-length(following-sibling::text()) &gt; 1"><xsl:text> </xsl:text></xsl:if></xsl:template>
135
136 <xsl:template match="pre"><xsl:text>
137 </xsl:text>
138 {{Code|<xsl:value-of select="@caption" />|&lt;pre&gt;<xsl:apply-templates />&lt;/pre&gt;
139 }}
140 <xsl:text>
141 </xsl:text>
142 </xsl:template>
143
144 <xsl:template match="comment">## <xsl:apply-templates /></xsl:template>
145
146 <xsl:template match="path"> {{Path|<xsl:apply-templates />}} </xsl:template>
147
148 <xsl:template match="b"><xsl:if test="string-length(preceding-sibling::text()) &gt; 1"><xsl:text> </xsl:text></xsl:if>'''<xsl:apply-templates />'''<xsl:if test="string-length(following-sibling::text()) &gt; 1"><xsl:text> </xsl:text></xsl:if></xsl:template>
149
150 <xsl:template match="warn">
151 {{Warning|<xsl:apply-templates />}}
152 </xsl:template>
153
154 <xsl:template match="impo">
155 {{Important|<xsl:apply-templates />}}
156 </xsl:template>
157
158 <xsl:template match="brite">'''<xsl:apply-templates />'''</xsl:template>
159
160 <xsl:template match="note">
161 {{Note|<xsl:apply-templates />}}
162 </xsl:template>
163
164 <xsl:template match="table">
165
166 {| class="wikitable" style="text-align: left;" <xsl:apply-templates />
167 |-
168 |}
169
170 </xsl:template>
171
172 <xsl:template match="tr">
173 |- <xsl:apply-templates />
174 </xsl:template>
175
176 <xsl:template match="th">
177 ! <xsl:apply-templates />
178 </xsl:template>
179 <xsl:template match="ti">
180 | <xsl:apply-templates />
181 </xsl:template>
182
183 <xsl:template match="dl">
184 {| class="wikitable" style="text-align: left;"
185 <xsl:apply-templates />
186 |-
187 |}
188 </xsl:template>
189
190 <xsl:template match="dt">
191 ! <xsl:apply-templates />
192 </xsl:template>
193
194 <xsl:template match="dd">
195 | <xsl:apply-templates />
196 </xsl:template>
197
198 <xsl:template match="text()">
199 <xsl:choose>
200 <xsl:when test="ancestor::pre"><xsl:value-of select="." /></xsl:when>
201 <xsl:otherwise><xsl:value-of select="normalize-space()" /></xsl:otherwise>
202 </xsl:choose>
203 </xsl:template>
204
205 </xsl:stylesheet>

  ViewVC Help
Powered by ViewVC 1.1.20