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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download) (as text)
Mon Jul 8 19:54:35 2013 UTC (7 years, 1 month ago) by swift
Branch: MAIN
Changes since 1.1: +40 -8 lines
File MIME type: application/xml
Updates on wikification of GuideXML, better newline handling

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:value-of select="mail" />
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
38 == <xsl:value-of select="title" /> ==<xsl:text>
39
40 </xsl:text>
41 <xsl:apply-templates />
42 </xsl:template>
43
44 <xsl:template match="section">
45 <xsl:if test="preceding-sibling::section"><xsl:text>
46 </xsl:text>
47 </xsl:if>
48 <xsl:if test="title">
49 === <xsl:value-of select="title" /> ===
50 </xsl:if>
51
52 <xsl:apply-templates />
53 </xsl:template>
54
55 <xsl:template match="body"><xsl:apply-templates /></xsl:template>
56
57 <!--
58 i is for in-pre commands, we cannot support that easily as we have no
59 knowledge of what needs to be RootCmd, UserCmd, what is output, etc.
60 -->
61 <xsl:template match="i"><xsl:apply-templates /></xsl:template>
62
63 <xsl:template match="mail"><xsl:choose><xsl:when test="link">{{Mail|<xsl:value-of select="@link" />|<xsl:value-of select="text()" />}}</xsl:when><xsl:otherwise>{{Mail|<xsl:value-of select="text()" />}}</xsl:otherwise></xsl:choose></xsl:template>
64
65 <xsl:template match="p"><xsl:apply-templates /><xsl:text>
66
67 </xsl:text>
68 </xsl:template>
69
70 <xsl:template match="br" />
71 <xsl:template match="license" />
72
73 <!--
74 var is formatting in pre, difficult to handle this
75 -->
76 <xsl:template match="var"><xsl:apply-templates /></xsl:template>
77
78 <!--
79 stmt is formatting in pre, difficult to handle this
80 -->
81 <xsl:template match="stmt"><xsl:apply-templates /></xsl:template>
82
83 <!--
84 const is formatting in pre, difficult to handle this
85 -->
86 <xsl:template match="const"><xsl:apply-templates /></xsl:template>
87
88 <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>
89
90 <xsl:template match="e"> ''<xsl:apply-templates />'' </xsl:template>
91
92 <xsl:template match="ul">
93 <xsl:apply-templates /><xsl:text>
94 </xsl:text>
95 </xsl:template>
96
97 <xsl:template match="ol">
98 <xsl:apply-templates /></xsl:template>
99
100 <xsl:template match="li">
101 <xsl:choose><xsl:when test="name(..)='ul'">* <xsl:apply-templates /></xsl:when><xsl:when test="name(..)='ol'"># <xsl:apply-templates /></xsl:when><xsl:otherwise>OH NOES HERE IT GOES!</xsl:otherwise></xsl:choose><xsl:text>
102 </xsl:text>
103 </xsl:template>
104
105 <xsl:template match="sup">&lt;sup&gt;<xsl:apply-templates />&lt;/sup&gt;</xsl:template>
106
107 <xsl:template match="sub">&lt;sub&gt;<xsl:apply-templates />&lt;/sub&gt;</xsl:template>
108
109 <xsl:template match="title" />
110
111 <xsl:template match="date" />
112
113 <xsl:template match="version" />
114
115 <xsl:template match="c"> '''<xsl:apply-templates />''' </xsl:template>
116
117 <xsl:template match="pre"><xsl:text>
118 </xsl:text>
119 <xsl:choose>
120 <xsl:when test="starts-with(normalize-space(), '~$') or starts-with(normalize-space(), '$')">
121 {{Cmd|INTERNAL commandhere|output=&lt;pre&gt;
122 <xsl:apply-templates />&lt;/pre&gt;
123 }}
124 </xsl:when>
125 <xsl:when test="starts-with(normalize-space(), '~#') or starts-with(normalize-space(), '#')">
126 {{RootCmd|INTERNAL commandhere|output=&lt;pre&gt;
127 <xsl:apply-templates />&lt;/pre&gt;
128 }}
129 </xsl:when>
130 <xsl:otherwise>
131 {{GenericCmd|&lt;pre&gt;
132 <xsl:apply-templates />&lt;/pre&gt;
133 }}
134 </xsl:otherwise>
135 </xsl:choose><xsl:text>
136 </xsl:text>
137 </xsl:template>
138
139 <xsl:template match="comment">## <xsl:apply-templates /></xsl:template>
140
141 <xsl:template match="path"> {{Path|<xsl:apply-templates />}} </xsl:template>
142
143 <xsl:template match="b">'''<xsl:apply-templates />'''</xsl:template>
144
145 <xsl:template match="warn">
146 {{Warning|<xsl:apply-templates />}}
147 </xsl:template>
148
149 <xsl:template match="impo">
150 {{Important|<xsl:apply-templates />}}
151 </xsl:template>
152
153 <xsl:template match="brite">'''<xsl:apply-templates />'''</xsl:template>
154
155 <xsl:template match="note">
156 {{Note|<xsl:apply-templates />}}
157 </xsl:template>
158
159 <xsl:template match="table">
160
161 {| class="wikitable" style="text-align: left;" <xsl:apply-templates />
162 |-
163 |}
164
165 </xsl:template>
166
167 <xsl:template match="tr">
168 |- <xsl:apply-templates />
169 </xsl:template>
170
171 <xsl:template match="th">
172 ! <xsl:apply-templates />
173 </xsl:template>
174 <xsl:template match="ti">
175 | <xsl:apply-templates />
176 </xsl:template>
177
178 <xsl:template match="dl">
179 {| class="wikitable" style="text-align: left;"
180 <xsl:apply-templates />
181 |-
182 |}
183 </xsl:template>
184
185 <xsl:template match="dt">
186 ! <xsl:apply-templates />
187 </xsl:template>
188
189 <xsl:template match="dd">
190 | <xsl:apply-templates />
191 </xsl:template>
192
193 <xsl:template match="text()">
194 <xsl:choose>
195 <xsl:when test="ancestor::pre"><xsl:value-of select="." /></xsl:when>
196 <xsl:otherwise><xsl:value-of select="normalize-space()" /></xsl:otherwise>
197 </xsl:choose>
198 </xsl:template>
199
200 </xsl:stylesheet>

  ViewVC Help
Powered by ViewVC 1.1.20