1
<?xml version="1.0" encoding="utf-8"?>
6
# Copyright Ericsson AB 2009. All Rights Reserved.
8
# The contents of this file are subject to the Erlang Public License,
9
# Version 1.1, (the "License"); you may not use this file except in
10
# compliance with the License. You should have received a copy of the
11
# Erlang Public License along with this software. If not, it can be
12
# retrieved online at http://www.erlang.org/.
14
# Software distributed under the License is distributed on an "AS IS"
15
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16
# the License for the specific language governing rights and limitations
23
<xsl:stylesheet version="1.0"
24
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
25
xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
27
<xsl:output method="text" encoding="UTF-8" indent="no"/>
30
<xsl:template match="/book">
31
<xsl:text>%% %% Search data file for </xsl:text><xsl:value-of select="$appname"/><xsl:text> </xsl:text><xsl:value-of select="$appver"/>
32
<xsl:text> %% generated </xsl:text><xsl:value-of select="$gendate"/><xsl:text> %% </xsl:text>
33
<xsl:apply-templates select="applications"/>
34
<xsl:text>{notused, application, ["</xsl:text><xsl:value-of select="$appname"/><xsl:text>"]}. </xsl:text>
38
<xsl:template match="applications">
39
<xsl:apply-templates name="application"/>
42
<!-- Reference Manual -->
45
<xsl:template match="application">
46
<xsl:apply-templates select="erlref|cref|comref|fileref|appref"/>
50
<xsl:template match="erlref">
51
<xsl:text>{"</xsl:text><xsl:value-of select="module"/><xsl:text>.html", {function, {"</xsl:text><xsl:value-of select="$appname"/>
52
<xsl:text>", "</xsl:text><xsl:value-of select="module"/><xsl:text>"}}, [ </xsl:text>
53
<xsl:apply-templates select="funcs">
54
<xsl:with-param name="mod" select="module"/>
55
</xsl:apply-templates>
56
<xsl:text>]}. </xsl:text>
57
<xsl:text>{"</xsl:text><xsl:value-of select="module"/><xsl:text>.html", {module, "</xsl:text>
58
<xsl:value-of select="$appname"/><xsl:text>"}, ["</xsl:text><xsl:value-of select="module"/><xsl:text>"]}. </xsl:text>
62
<xsl:template match="cref">
63
<xsl:text>{"</xsl:text><xsl:value-of select="lib"/><xsl:text>.html", {function, {"</xsl:text><xsl:value-of select="$appname"/>
64
<xsl:text>", "</xsl:text><xsl:value-of select="lib"/><xsl:text>"}}, [ </xsl:text>
65
<xsl:apply-templates select="funcs">
66
<xsl:with-param name="mod" select="lib"/>
67
</xsl:apply-templates>
68
<xsl:text>]}. </xsl:text>
69
<xsl:text>{"</xsl:text><xsl:value-of select="lib"/><xsl:text>.html", {clib, "</xsl:text>
70
<xsl:value-of select="$appname"/><xsl:text>"}, ["</xsl:text><xsl:value-of select="lib"/><xsl:text>"]}. </xsl:text>
74
<xsl:template match="comref">
75
<xsl:text>{"</xsl:text><xsl:value-of select="com"/><xsl:text>.html", {command, "</xsl:text>
76
<xsl:value-of select="$appname"/><xsl:text>"}, ["</xsl:text><xsl:value-of select="com"/><xsl:text>"]}. </xsl:text>
80
<xsl:template match="fileref">
81
<xsl:text>{"</xsl:text><xsl:value-of select="file"/><xsl:text>.html", {file, "</xsl:text>
82
<xsl:value-of select="$appname"/><xsl:text>"}, ["</xsl:text><xsl:value-of select="file"/><xsl:text>"]}. </xsl:text>
86
<xsl:template match="appref">
87
<xsl:text>{"</xsl:text><xsl:value-of select="app"/><xsl:text>_app.html", {app, "</xsl:text>
88
<xsl:value-of select="$appname"/><xsl:text>"}, ["</xsl:text><xsl:value-of select="app"/><xsl:text>"]}. </xsl:text>
93
<xsl:template match="funcs">
94
<xsl:param name="mod"/>
95
<xsl:variable name="lastfuncsblock">
96
<xsl:value-of select="position() = last()"/>
98
<xsl:apply-templates select="func/name">
99
<xsl:with-param name="mod" select="$mod"/>
100
<xsl:with-param name="lastfuncsblock" select="$lastfuncsblock"/>
101
</xsl:apply-templates>
107
<xsl:template match="name">
108
<xsl:param name="mod"/>
109
<xsl:param name="lastfuncsblock"/>
111
<xsl:variable name="tmpstring">
112
<xsl:value-of select="substring-before(substring-after(., '('), '->')"/>
114
<xsl:variable name="ustring">
116
<xsl:when test="string-length($tmpstring) > 0">
117
<xsl:call-template name="remove-paren">
118
<xsl:with-param name="string" select="$tmpstring"/>
122
<xsl:call-template name="remove-paren">
123
<xsl:with-param name="string" select="substring-after(., '(')"/>
128
<xsl:variable name="arity">
129
<xsl:call-template name="calc-arity">
130
<xsl:with-param name="string" select="substring-before($ustring, ')')"/>
131
<xsl:with-param name="no-of-pars" select="0"/>
134
<xsl:variable name="fname">
136
<xsl:when test="ancestor::cref">
137
<xsl:value-of select="substring-before(nametext, '(')"/>
139
<xsl:when test="ancestor::erlref">
140
<xsl:variable name="fname1">
141
<xsl:value-of select="substring-before(., '(')"/>
143
<xsl:variable name="fname2">
144
<xsl:value-of select="substring-after($fname1, 'erlang:')"/>
147
<xsl:when test="string-length($fname2) > 0">
148
<xsl:value-of select="$fname2"/>
151
<xsl:value-of select="$fname1"/>
157
<xsl:text> {"</xsl:text><xsl:value-of select="$fname"/>
158
<xsl:text>", "</xsl:text><xsl:value-of select="$fname"/>
159
<xsl:text>(</xsl:text><xsl:value-of select="normalize-space($tmpstring)"/>
160
<xsl:text>", "</xsl:text><xsl:value-of select="$fname"/>
161
<xsl:text>-</xsl:text><xsl:value-of select="$arity"/><xsl:text>"}</xsl:text>
164
<xsl:when test="($lastfuncsblock = 'true') and (position() = last())">
165
<xsl:text> </xsl:text>
168
<xsl:text>, </xsl:text>
173
<!-- Special templates to calculate the arity of functions -->
174
<xsl:template name="calc-arity">
175
<xsl:param name="string"/>
176
<xsl:param name="no-of-pars"/>
177
<xsl:variable name="length">
178
<xsl:value-of select="string-length($string)"/>
181
<xsl:when test="$length > 0">
182
<xsl:call-template name="calc-arity">
183
<xsl:with-param name="string" select="substring-after($string, ',')"/>
184
<xsl:with-param name="no-of-pars" select="$no-of-pars+1"/>
188
<xsl:value-of select="$no-of-pars"/>
193
<xsl:template name="remove-paren">
194
<xsl:param name="string"/>
196
<xsl:variable name="str1">
197
<xsl:call-template name="remove-paren-1">
198
<xsl:with-param name="string" select="$string"/>
199
<xsl:with-param name="start">(</xsl:with-param>
200
<xsl:with-param name="end">)</xsl:with-param>
204
<xsl:variable name="str2">
205
<xsl:call-template name="remove-paren-1">
206
<xsl:with-param name="string" select="$str1"/>
207
<xsl:with-param name="start">{</xsl:with-param>
208
<xsl:with-param name="end">}</xsl:with-param>
212
<xsl:variable name="str3">
213
<xsl:call-template name="remove-paren-1">
214
<xsl:with-param name="string" select="$str2"/>
215
<xsl:with-param name="start">[</xsl:with-param>
216
<xsl:with-param name="end">]</xsl:with-param>
220
<xsl:value-of select="$str3"/>
225
<xsl:template name="remove-paren-1">
226
<xsl:param name="string"/>
227
<xsl:param name="start"/>
228
<xsl:param name="end"/>
230
<xsl:variable name="tmp1">
231
<xsl:value-of select="substring-before($string, $start)"/>
235
<xsl:when test="string-length($tmp1) > 0 or starts-with($string, $start)">
236
<xsl:variable name="tmp2">
237
<xsl:value-of select="substring-after($string, $end)"/>
239
<xsl:variable name="retstring">
240
<xsl:call-template name="remove-paren">
241
<xsl:with-param name="string" select="$tmp2"/>
244
<xsl:value-of select="concat(concat($tmp1, 'x'), $retstring)"/>
247
<xsl:value-of select="$string"/>
253
<!-- default content handling -->
254
<xsl:template match="text()"/>