-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen-html.xsl
133 lines (125 loc) · 4.57 KB
/
gen-html.xsl
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?xml version="1.0"?>
<!--
gen-html
human-readable docs from ALPS xml
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<head>
<title>Documentation</title>
</head>
<body>
<h1>Documentation</h1>
<xsl:copy-of select="//alps/doc" disable-output-escaping="yes"/>
<xsl:if test="count(//alps/link)>0">
<ul class="link">
<xsl:for-each select="//alps/link">
<li>rel:<xsl:value-of select="@rel" /> = <a href="{@href}" rel="{@rel}"><xsl:value-of select="@href" /></a></li>
</xsl:for-each>
</ul>
</xsl:if>
<xsl:apply-templates select="*" /> <!--|@*|text()"/>-->
</body>
</html>
</xsl:template>
<xsl:template name="call-link">
<ul class="link">
<xsl:for-each select="link">
<li>rel:<xsl:value-of select="@rel" /> = <a href="{@href}" rel="{@rel}"><xsl:value-of select="@href" /></a></li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="descriptor">
<div class="descriptor">
<h4 class="id" id="{@id}"><xsl:value-of select="@id" /></h4>
<xsl:if test="count(doc)>0">
<xsl:copy-of select="doc" disable-output-escaping="yes"/>
</xsl:if>
<xsl:if test="count(link)>0">
<xsl:call-template name="call-link" />
</xsl:if>
<ul class="attributes">
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="contains(.,'#')">
<li><xsl:value-of select="name()" /> : <a href="{.}"><xsl:value-of select="." /></a></li>
</xsl:when>
<xsl:when test="name()='href'">
<li><xsl:value-of select="name()" /> : <a href="{.}"><xsl:value-of select="." /></a></li>
</xsl:when>
<xsl:otherwise>
<li><xsl:value-of select="name()" /> : <xsl:value-of select="." /></li>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:if test="count(contains)>0">
<li>Contains: <xsl:apply-templates select="*"/></li>
</xsl:if>
<xsl:if test="count(property)>0">
<li>Properties: <xsl:apply-templates select="*" /></li>
</xsl:if>
<xsl:if test="count(descriptor)>0">
<li>Contains: <xsl:apply-templates select="*" /></li>
</xsl:if>
</ul>
</div>
</xsl:template>
<xsl:template match="property">
<div class="property">
<h4 class="id" id="{@id}"><xsl:value-of select="@id" /></h4>
<xsl:if test="count(doc)>0">
<xsl:copy-of select="doc" disable-output-escaping="yes"/>
</xsl:if>
<xsl:if test="count(link)>0">
<xsl:call-template name="call-link" />
</xsl:if>
<ul class="attributes">
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="contains(.,'#')">
<li><xsl:value-of select="name()" /> : <a href="{.}"><xsl:value-of select="." /></a></li>
</xsl:when>
<xsl:when test="name()='href'">
<li><xsl:value-of select="name()" /> : <a href="{.}"><xsl:value-of select="." /></a></li>
</xsl:when>
<xsl:otherwise>
<li><xsl:value-of select="name()" /> : <xsl:value-of select="." /></li>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</div>
</xsl:template>
<!-- supports old format ALPS docs -->
<xsl:template match="contains">
<div class="contains">
<h4 class="id" id="{@id}"><xsl:value-of select="@id" /></h4>
<xsl:if test="count(doc)>0">
<xsl:copy-of select="doc" disable-output-escaping="yes"/>
</xsl:if>
<xsl:if test="count(link)>0">
<xsl:call-template name="call-link" />
</xsl:if>
<ul class="attributes">
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="contains(.,'#')">
<li><xsl:value-of select="name()" /> : <a href="{.}"><xsl:value-of select="." /></a></li>
</xsl:when>
<xsl:when test="name()='href'">i
<li><xsl:value-of select="name()" /> : <a href="{.}"><xsl:value-of select="." /></a></li>
</xsl:when>
<xsl:otherwise>
<li><xsl:value-of select="name()" /> : <xsl:value-of select="." /></li>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</div>
</xsl:template>
<xsl:template match="doc">
<!-- to catch (and not display) doc elements -->
</xsl:template>
</xsl:stylesheet>