Project

Profile

Help

How to connect?
Download (7.09 KB) Statistics
| Branch: | Revision:

he / tools / featureKeys / ToConfigFileDoc.xsl @ 2699858e

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fc="http://www.saxonica.com/ns/doc/functions"
4
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:map="http://www.w3.org/2005/xpath-functions/map"
5
    exclude-result-prefixes="xs fc xd map" version="3.0">
6
    <xd:doc scope="stylesheet">
7
        <xd:desc>
8
            <xd:p><xd:b>Created on:</xd:b> Mar 20, 2015</xd:p>
9
            <xd:p><xd:b>Author:</xd:b> Debbie Lockett, Saxonica</xd:p>
10
            <xd:p>Generates ConfigFileDoc.xml from AdditionalFeatures.xml and FeatureKeys.xml</xd:p>
11
        </xd:desc>
12
    </xd:doc>
13
    
14
    <!-- This stylesheet produces content for the configuration file documentation in the Configuration 
15
        section (configuration.xml): one result document per configuration file element, containing
16
        a table of its attributes (or in the case of the 'resources' element, its child elements). 
17
        The config file elements are listed in 'AdditionalFeatures.xml', and the source information 
18
        for the tables is contained in that file and 'FeatureKeys.xml'.-->
19

    
20

    
21
    <xsl:output method="xml" indent="yes"/>
22

    
23
    <xsl:template match="features">
24
        <xsl:for-each select="config-element">
25
            <xsl:call-template name="table">
26
                <xsl:with-param name="configfile-element" select="@name" as="xs:string"/>
27
                <xsl:with-param name="src-doc" select="doc(@src-doc)"/>
28
            </xsl:call-template>
29
        </xsl:for-each>
30
    </xsl:template>
31

    
32
    <xsl:template name="table">
33
        <xsl:param name="configfile-element" as="xs:string"/>
34
        <xsl:param name="src-doc" as="document-node()"/>
35
        <xsl:variable name="el-or-att">
36
            <xsl:choose>
37
                <xsl:when test="$configfile-element eq 'resources'">Element</xsl:when>
38
                <xsl:otherwise>Attribute</xsl:otherwise>
39
            </xsl:choose>
40
        </xsl:variable>
41

    
42
        <xsl:result-document href="ConfigFileDoc-{$configfile-element}.xml">
43
            <table>
44
                <xsl:comment> TABLE GENERATED FROM FeatureKeys.xml and AdditionalFeatures.xml - DO NOT EDIT THIS FILE</xsl:comment>
45
                <thead>
46
                    <tr>
47
                        <td>
48
                            <p>
49
                                <strong>
50
                                    <xsl:value-of select="$el-or-att"/>
51
                                </strong>
52
                            </p>
53
                        </td>
54
                        <td>
55
                            <p>
56
                                <strong>Applies to</strong>
57
                            </p>
58
                        </td>
59
                        <td>
60
                            <p>
61
                                <strong>Values</strong>
62
                            </p>
63
                        </td>
64
                        <td>
65
                            <p>
66
                                <strong>Effect</strong>
67
                            </p>
68
                        </td>
69
                    </tr>
70
                </thead>
71
                <tbody>
72
                    <xsl:call-template name="config-features">
73
                        <xsl:with-param name="configfile-element" select="$configfile-element"/>
74
                        <xsl:with-param name="src-doc" select="$src-doc"/>
75
                    </xsl:call-template>
76
                </tbody>
77
            </table>
78
        </xsl:result-document>
79
    </xsl:template>
80

    
81
    <xsl:template name="config-features">
82
        <xsl:param name="configfile-element" as="xs:string"/>
83
        <xsl:param name="src-doc" as="document-node()"/>
84
        <xsl:variable name="separator">
85
            <xsl:choose>
86
                <xsl:when test="$configfile-element eq 'resources'">
87
                    <xsl:value-of select="'/'"/>
88
                </xsl:when>
89
                <xsl:otherwise>
90
                    <xsl:value-of select="'@'"/>
91
                </xsl:otherwise>
92
            </xsl:choose>
93
        </xsl:variable>
94
        
95
        <xsl:variable name="features-of-config-el" as="element(feature)*"
96
            select="$src-doc//configfile[tokenize(string(.),'/')[1] eq $configfile-element]/parent::node()"/>
97
        
98
        <xsl:for-each select="fc:sort-by-config-name($features-of-config-el)">
99
            <tr>
100
                <td>
101
                    <p>
102
                        <xsl:variable name="attname" select="tokenize(configfile[1], $separator)[2]"/>
103
                        <xsl:choose>
104
                            <xsl:when test="additional">
105
                                <xsl:value-of select="$attname"/>
106
                            </xsl:when>
107
                            <xsl:when test="use eq 'required'">
108
                                <code><strong><xsl:value-of select="$attname"/></strong></code>
109
                            </xsl:when>
110
                            <xsl:otherwise> <!-- use eq 'optional' or undefined.  -->
111
                                <code><xsl:value-of select="$attname"/></code>
112
                                <!--<code><xsl:value-of select="concat($attname, if ($separator eq '/')
113
                                    then '' else '?')"/></code>-->
114
                            </xsl:otherwise>
115
                        </xsl:choose>
116
                    </p>
117
                </td>
118
                <td>
119
                    <p>
120
                        <xsl:value-of select="editions"/>
121
                    </p>
122
                </td>
123
                <td>
124
                    <p>
125
                        <xsl:choose>
126
                            <xsl:when test="exists(typedesc)">
127
                                <xsl:apply-templates select="typedesc/node()"/>
128
                            </xsl:when>
129
                            <xsl:when test="type eq 'boolean'">
130
                                <xsl:text>true|false</xsl:text>
131
                            </xsl:when>
132
                            <xsl:otherwise>
133
                                <xsl:apply-templates select="type/node()"/>
134
                            </xsl:otherwise>
135
                        </xsl:choose>
136
                    </p>
137
                </td>
138
                <td>
139
                    <xsl:apply-templates select="configfiledesc/node()"/>
140
                </td>
141
            </tr>
142
        </xsl:for-each>
143
    </xsl:template>
144

    
145
    <xsl:template match="*">
146
        <xsl:copy>
147
            <xsl:copy-of select="@*"/>
148
            <xsl:apply-templates/>
149
        </xsl:copy>
150
    </xsl:template>
151

    
152
    <xsl:template match="link">
153
        <a href="{.}" class="javalink">
154
            <xsl:value-of select="tokenize(., '\.')[last()]"/>
155
        </a>
156
    </xsl:template>
157

    
158
    <xsl:function name="fc:sort-by-config-name" as="element(feature)*">
159
        <xsl:param name="features" as="element(feature)*"/>
160
        <xsl:perform-sort select="$features">
161
            <xsl:sort select="additional"/> <!-- additional attributes after others-->
162
            <xsl:sort select="use" order="descending"/> <!-- 'required' > 'optional' > undefined use -->
163
            <xsl:sort select="lower-case(tokenize(configfile[1], '/')[2])" lang="en"/>
164
        </xsl:perform-sort>
165
    </xsl:function>
166

    
167
</xsl:stylesheet>
(7-7/8)