-
Notifications
You must be signed in to change notification settings - Fork 6
/
xqdoc2md.xsl
70 lines (60 loc) · 2.02 KB
/
xqdoc2md.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="text" indent="no"/>
<xsl:strip-space elements="*"/>
<xsl:template match="module">
<xsl:text>
eXgit
=====
</xsl:text>
<xsl:value-of select="description"/>
<xsl:text>
functions
---------
</xsl:text>
<xsl:apply-templates select="function"/>
</xsl:template>
<xsl:template match="function">
<xsl:text>
```xquery
</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>(</xsl:text>
<xsl:for-each select="argument">
<xsl:text>$</xsl:text>
<xsl:value-of select="@var"/>
<xsl:text> as </xsl:text>
<xsl:value-of select="@type"/>
<xsl:apply-templates select="@cardinality"/>
<xsl:if test="position() != count(../argument)">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>) as </xsl:text>
<xsl:value-of select="returns/@type"/>
<xsl:apply-templates select="returns/@cardinality"/>
<xsl:text>
```
</xsl:text>
<xsl:for-each select="argument">
<xsl:text>$</xsl:text>
<xsl:value-of select="@var"/>
<xsl:text> as </xsl:text>
<xsl:value-of select="@type"/>
<xsl:apply-templates select="@cardinality"/>
<xsl:text> - </xsl:text>
<xsl:value-of select="text()"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="@cardinality">
<xsl:choose>
<xsl:when test=". = 'exactly one'"></xsl:when>
<xsl:when test=". = 'one or more'"><xsl:text>+</xsl:text></xsl:when>
<xsl:when test=". = 'zero or more'"><xsl:text>*</xsl:text></xsl:when>
<xsl:when test=". = 'zero or one'"><xsl:text>?</xsl:text></xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>