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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download) (as text)
Sat Jul 20 18:12:53 2013 UTC (7 years ago) by swift
Branch: MAIN
Changes since 1.2: +12 -25 lines
File MIME type: application/xml
Fix command listing, use of c, author acknowledgements, multi-level indents (not fully, but much better)

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:apply-templates />
20 <xsl:if test="//guide/author[not(@title='script generated')]">
21 == Acknowledgements ==
22
23 We would like to thank the following authors and editors for their contributions to this guide:
24 <xsl:for-each select="//guide/author">
25 * <xsl:choose><xsl:when test="mail/text()"><xsl:value-of select="mail" /></xsl:when><xsl:otherwise><xsl:value-of select="mail/@link" /></xsl:otherwise></xsl:choose>
26 </xsl:for-each>
27 </xsl:if>
28
29 [[Category:Server and Security]]
30 </xsl:template>
31
32 <xsl:template match="author" />
33
34 <xsl:template match="abstract" />
35
36 <xsl:template match="chapter">
37 <!-- Ignore developers and subprojects as these will be provided by the wiki itself. -->
38 <xsl:if test="not(title='Developers') and not(title='Subprojects')">
39 == <xsl:value-of select="title" /> ==<xsl:text>
40 </xsl:text>
41 <xsl:apply-templates />
42 </xsl:if>
43 </xsl:template>
44
45 <xsl:template match="section">
46 <xsl:if test="preceding-sibling::section"><xsl:text>
47 </xsl:text>
48 </xsl:if>
49 <xsl:if test="title">
50 === <xsl:value-of select="title" /> ===
51 </xsl:if>
52
53 <xsl:apply-templates />
54 </xsl:template>
55
56 <xsl:template match="body"><xsl:apply-templates /></xsl:template>
57
58 <!--
59 i is for in-pre commands, we cannot support that easily as we have no
60 knowledge of what needs to be RootCmd, UserCmd, what is output, etc.
61 -->
62 <xsl:template match="i"><xsl:apply-templates /></xsl:template>
63
64 <xsl:template match="mail"><xsl:text> </xsl:text><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>
65
66 <xsl:template match="p"><xsl:apply-templates /><xsl:text>
67
68 </xsl:text>
69 </xsl:template>
70
71 <xsl:template match="br" />
72 <xsl:template match="license" />
73
74 <!--
75 var is formatting in pre, difficult to handle this
76 -->
77 <xsl:template match="var"><xsl:apply-templates /></xsl:template>
78
79 <!--
80 stmt is formatting in pre, difficult to handle this
81 -->
82 <xsl:template match="stmt"><xsl:apply-templates /></xsl:template>
83
84 <!--
85 const is formatting in pre, difficult to handle this
86 -->
87 <xsl:template match="const"><xsl:apply-templates /></xsl:template>
88
89 <xsl:template match="uri"><xsl:text> </xsl:text><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:choose><xsl:text> </xsl:text></xsl:template>
90
91 <xsl:template match="e"> ''<xsl:apply-templates />'' </xsl:template>
92
93 <xsl:template match="ul"><xsl:text>
94 </xsl:text><xsl:apply-templates /><xsl:text>
95 </xsl:text>
96 </xsl:template>
97
98 <xsl:template match="ol">
99 <xsl:apply-templates /></xsl:template>
100
101 <xsl:template match="li">
102 <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>
103 </xsl:text>
104 </xsl:template>
105
106 <xsl:template match="sup">&lt;sup&gt;<xsl:apply-templates />&lt;/sup&gt;</xsl:template>
107
108 <xsl:template match="sub">&lt;sub&gt;<xsl:apply-templates />&lt;/sub&gt;</xsl:template>
109
110 <xsl:template match="title" />
111
112 <xsl:template match="date" />
113
114 <xsl:template match="version" />
115
116 <xsl:template match="c"> &lt;code&gt;<xsl:apply-templates />&lt;/code&gt; </xsl:template>
117
118 <xsl:template match="pre"><xsl:text>
119 </xsl:text>
120 {{GenericCmd|&lt;pre&gt;<xsl:apply-templates />&lt;/pre&gt;
121 }}
122 <xsl:text>
123 </xsl:text>
124 </xsl:template>
125
126 <xsl:template match="comment">## <xsl:apply-templates /></xsl:template>
127
128 <xsl:template match="path"> {{Path|<xsl:apply-templates />}} </xsl:template>
129
130 <xsl:template match="b"><xsl:text> </xsl:text>'''<xsl:apply-templates />'''<xsl:text> </xsl:text></xsl:template>
131
132 <xsl:template match="warn">
133 {{Warning|<xsl:apply-templates />}}
134 </xsl:template>
135
136 <xsl:template match="impo">
137 {{Important|<xsl:apply-templates />}}
138 </xsl:template>
139
140 <xsl:template match="brite">'''<xsl:apply-templates />'''</xsl:template>
141
142 <xsl:template match="note">
143 {{Note|<xsl:apply-templates />}}
144 </xsl:template>
145
146 <xsl:template match="table">
147
148 {| class="wikitable" style="text-align: left;" <xsl:apply-templates />
149 |-
150 |}
151
152 </xsl:template>
153
154 <xsl:template match="tr">
155 |- <xsl:apply-templates />
156 </xsl:template>
157
158 <xsl:template match="th">
159 ! <xsl:apply-templates />
160 </xsl:template>
161 <xsl:template match="ti">
162 | <xsl:apply-templates />
163 </xsl:template>
164
165 <xsl:template match="dl">
166 {| class="wikitable" style="text-align: left;"
167 <xsl:apply-templates />
168 |-
169 |}
170 </xsl:template>
171
172 <xsl:template match="dt">
173 ! <xsl:apply-templates />
174 </xsl:template>
175
176 <xsl:template match="dd">
177 | <xsl:apply-templates />
178 </xsl:template>
179
180 <xsl:template match="text()">
181 <xsl:choose>
182 <xsl:when test="ancestor::pre"><xsl:value-of select="." /></xsl:when>
183 <xsl:otherwise><xsl:value-of select="normalize-space()" /></xsl:otherwise>
184 </xsl:choose>
185 </xsl:template>
186
187 </xsl:stylesheet>

  ViewVC Help
Powered by ViewVC 1.1.20