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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download) (as text)
Wed Jul 24 20:51:35 2013 UTC (7 years ago) by swift
Branch: MAIN
Changes since 1.5: +3 -2 lines
File MIME type: application/xml
Use abstract at beginning of wiki article, and create internal link when needed

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

  ViewVC Help
Powered by ViewVC 1.1.20