-
Notifications
You must be signed in to change notification settings - Fork 188
/
wiki.xslt
107 lines (103 loc) · 3.29 KB
/
wiki.xslt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="escape_underscore">
<xsl:param name="text" />
<xsl:choose>
<xsl:when test="contains($text, '_')">
<xsl:value-of select="substring-before($text,'_')" />
<xsl:value-of select="'\_'" />
<xsl:call-template name="escape_underscore">
<xsl:with-param name="text" select="substring-after($text,'_')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/classes">
<xsl:for-each select="class">
<xsl:text>
</xsl:text>
<xsl:variable name="class-name">
<xsl:call-template name="escape_underscore">
<xsl:with-param name="text" select="@name" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="class-desc">
<xsl:call-template name="escape_underscore">
<xsl:with-param name="text" select="description" />
</xsl:call-template>
</xsl:variable>
<xsl:if test="attributes/attribute">
***
#### <xsl:value-of select="$class-name"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="$class-desc"/>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:for-each select="attributes/attribute">
<xsl:variable name="attr-name">
<xsl:call-template name="escape_underscore">
<xsl:with-param name="text" select="@name" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="attr-type">
<!-- Don't need to escape this because we put it in code tags -->
<xsl:value-of select="@type"/>
</xsl:variable>
<xsl:variable name="attr-vars">
<!-- Don't need to escape this because we put it in code tags -->
<xsl:value-of select="@vars"/>
</xsl:variable>
<xsl:variable name="attr-desc">
<xsl:call-template name="escape_underscore">
<xsl:with-param name="text" select="." />
</xsl:call-template>
</xsl:variable>
**<xsl:value-of select="$attr-name"/>** | `<xsl:value-of select="$attr-type"/><xsl:if test="$attr-vars != ''"> : <xsl:value-of select="$attr-vars"/></xsl:if>` | <xsl:value-of select="$attr-desc"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
***
### Predefined Strings
<xsl:text>
</xsl:text>
Below are some strings that are used in various attributes.
<xsl:for-each select="class">
<xsl:text>
</xsl:text>
<xsl:variable name="class-name">
<xsl:call-template name="escape_underscore">
<xsl:with-param name="text" select="@name" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="class-desc">
<xsl:call-template name="escape_underscore">
<xsl:with-param name="text" select="description" />
</xsl:call-template>
</xsl:variable>
<xsl:if test="attributes/type">
***
#### <xsl:value-of select="$class-name"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="$class-desc"/>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:for-each select="attributes/type">
<xsl:variable name="type-name">
<xsl:call-template name="escape_underscore">
<xsl:with-param name="text" select="@name" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="type-desc">
<xsl:call-template name="escape_underscore">
<xsl:with-param name="text" select="." />
</xsl:call-template>
</xsl:variable>
**<xsl:value-of select="$type-name"/>** | <xsl:value-of select="$type-desc"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>