Project

Profile

Help

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

he / tools / contents-builder.xsl @ 9e416749

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
  xmlns:cat="http://www.saxonica.com/ns/doc/catalog"
4
  xmlns:fn="http://www.saxonica.com/ns/doc/functions"
5
  xmlns:ch="http://www.saxonica.com/ns/doc/changes" xmlns:xs="http://www.w3.org/2001/XMLSchema"
6
  xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="cat fn ch xs saxon">
7

    
8
  <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
9
  
10
  <xsl:param name="version-number"/>
11

    
12
  <xsl:variable name="sections" select="/cat:catalog/cat:section/@ref"/>
13
  
14
  <!-- Note that for the 9.4 documentation, the Changes and Functions sections have a slightly different
15
     format to those in 9.5 onwards; so these are treated as a special case. -->
16

    
17
  <xsl:template match="/">
18
    <xsl:result-document method="xml" indent="yes">
19
      <xsl:comment> Generated at <xsl:value-of select="format-dateTime(current-dateTime(), '[D] [MNn] [Y0001] at [H01]:[m01]')"/>
20
      </xsl:comment>
21
      <contents>
22
        <xsl:for-each select="$sections[. ne 'javadoc' and . ne 'dotnetdoc']">
23
          <xsl:variable name="sname" select="string(.)"/>
24
          <xsl:variable name="sect" select="document(concat(., '.xml'),/)"/>
25

    
26
          <xsl:choose>
27
            <xsl:when test="$sname = 'functions' and $version-number = '9.4'">
28
              <section name="{$sname}" title="{$sect//fn:functions/@title}">
29
                <xsl:for-each select="$sect//fn:function">
30
                  <page name="{fn:name}" title="{fn:name}"/>                  
31
                </xsl:for-each>
32
              </section>
33
            </xsl:when>
34
            <xsl:when test="$sname = 'functions'">
35
              <section name="{$sname}" title="{$sect/article/@title}">
36
                <xsl:for-each select="$sect/article/section">
37
                  <xsl:variable name="fns" select="fn:function"/>
38
                  <xsl:variable name="sfns" as="element()*" select="fn:fn-list($fns)"/>
39
                  <page name="{@id}" title="{@title}">
40
                    <xsl:for-each select="$sfns">
41
                      <subpage name="{fn:name}" title="{fn:name}"/>
42
                    </xsl:for-each>
43
                  </page>
44
                </xsl:for-each>
45
              </section>
46
            </xsl:when>
47
            <xsl:when test="$sname = 'changes' and $version-number != '9.4'">
48
              <section name="{$sname}" title="{$sect/ch:changes/@title}">
49
                <xsl:for-each select="$sect/ch:changes/ch:release">
50
                  <xsl:variable name="release" select="."/>
51
                  <page name="{@number}" title="Version {@number} ({@date})">
52
                    <xsl:for-each select="$sect/ch:changes/ch:categories/ch:cat">
53
                      <xsl:if test="./@name = $release/ch:category/@name">
54
                        <subpage name="{@name}" title="{@title}"/>
55
                      </xsl:if>
56
                    </xsl:for-each>
57
                  </page>
58
                </xsl:for-each>
59
              </section>
60
            </xsl:when>
61
            <xsl:otherwise>
62
              <section name="{$sname}" title="{$sect/article/@title}">
63
                <xsl:for-each select="$sect/article/section">
64
                  <xsl:variable name="h" select="."/>
65
                  <page name="{$h/@id}" title="{$h/@title}">
66
                    <xsl:for-each select="section">
67
                      <subpage name="{@id}" title="{@title}">
68
                        <xsl:for-each select="section">
69
                          <subpage name="{@id}" title="{@title}">
70
                            <xsl:for-each select="section">
71
                              <subpage name="{@id}" title="{@title}"/>                              
72
                            </xsl:for-each>
73
                          </subpage>
74
                        </xsl:for-each>
75
                      </subpage>
76
                    </xsl:for-each>
77
                  </page>
78
                </xsl:for-each>
79
              </section>
80
            </xsl:otherwise>
81
          </xsl:choose>
82
        </xsl:for-each>
83
      </contents>
84
    </xsl:result-document>
85
  </xsl:template>
86

    
87
  <xsl:function name="fn:fn-list" as="element()*">
88
    <xsl:param name="fns" as="element()*"/>
89
    <xsl:perform-sort select="$fns">
90
      <xsl:sort select="lower-case(name)" lang="en"/>
91
    </xsl:perform-sort>
92
  </xsl:function>
93

    
94
</xsl:stylesheet>
(3-3/15)