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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download) (as text)
Sat Jul 27 20:07:36 2013 UTC (7 years ago) by swift
Branch: MAIN
Changes since 1.6: +8 -5 lines
File MIME type: application/xml
No indentation when sentence starts with a tag

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

  ViewVC Help
Powered by ViewVC 1.1.20