File: makeindex.xsl

package info (click to toggle)
gimp-help 3.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 297,088 kB
  • sloc: xml: 118,538; sh: 4,332; python: 1,004; makefile: 585; perl: 134
file content (132 lines) | stat: -rw-r--r-- 5,146 bytes parent folder | download | duplicates (7)
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:output method="xml" encoding="UTF-8" indent="yes" />

  <!-- include template "gimp-help.help-id.sort" -->
  <xsl:include href="getsortkey.xsl" />

  <xsl:param name="obj.missing.title.warning" select="0"/>
  <xsl:param name="obj.title.debug"           select="0"/>

  <xsl:template match="/">
    <gimp-help>
      <xsl:apply-templates select="*" />
    </gimp-help>
  </xsl:template>

  <xsl:template match="/div/div[@targetptr='help-missing']">
    <help-missing>
      <xsl:attribute name="ref">
        <xsl:value-of select="@href" />
      </xsl:attribute>
    </help-missing>
  </xsl:template>

  <xsl:template match="div">
    <xsl:choose>
      <xsl:when test="@targetptr">
        <help-item>
          <xsl:attribute name="id">
            <xsl:value-of select="@targetptr" />
          </xsl:attribute>
          <xsl:attribute name="ref">
            <xsl:value-of select="@href" />
          </xsl:attribute>
          <xsl:attribute name="title">
            <xsl:choose>
              <xsl:when test="@number=''">
                <xsl:value-of select="normalize-space(ttl)" />
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of
                  select="concat(@number, '. ', normalize-space(ttl))" />
              </xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
          <xsl:attribute name="parent">
            <xsl:value-of select="ancestor::div[@targetptr][1]/@targetptr"/>
          </xsl:attribute>
          <xsl:attribute name="sort">
            <xsl:call-template name="gimp-help.help-id.sort"/>
          </xsl:attribute>
        </help-item>
      </xsl:when>
    </xsl:choose>
    <xsl:apply-templates select="*" />
  </xsl:template>

  <xsl:template match="obj">
    <xsl:if test="@targetptr
              and not(@element = 'footnote')
              and not(@element = 'figure')
              and (starts-with(@targetptr, 'gimp-') or
                   starts-with(@targetptr, 'plug-in-') or
                   starts-with(@targetptr, 'script-fu-'))">
      <help-item>
        <xsl:attribute name="id">
          <xsl:value-of select="@targetptr" />
        </xsl:attribute>
        <xsl:attribute name="ref">
          <xsl:value-of select="@href" />
        </xsl:attribute>
        <xsl:attribute name="title">
          <xsl:choose>
            <xsl:when test="not(contains(ttl, '???')) and normalize-space(ttl) != ''">
              <!-- case 1: "obj" has "ttl" (title) attribute -->
              <xsl:value-of select="concat('(', normalize-space(ttl), ')')" />
              <xsl:if test="$obj.title.debug = 1">
                <xsl:message>
                  <xsl:text>Debug: GIMP help browser title (ttl) = </xsl:text>
                  <xsl:value-of select="concat('(', normalize-space(ttl), ')')" />
                </xsl:message>
              </xsl:if>
            </xsl:when>
            <xsl:otherwise> <!-- "obj" without "ttl" attribute -->
              <xsl:variable name="xreftext.normalized">
                <xsl:if test="not(contains(xreftext,'???'))">
                  <xsl:value-of select="normalize-space(xreftext)"/>
                </xsl:if>
              </xsl:variable>
              <xsl:choose>
                <xsl:when test="$xreftext.normalized != ''">
                  <!-- case 3: "obj" has "xreftext" attribute -->
                  <xsl:value-of select="concat('(', $xreftext.normalized, ')')" />
                  <xsl:if test="$obj.title.debug = 1">
                    <xsl:message>
                      <xsl:text>Debug: GIMP help browser title (xreftext) = </xsl:text>
                      <xsl:value-of select="concat('(', $xreftext.normalized, ')')" />
                    </xsl:message>
                  </xsl:if>
                </xsl:when>
                <xsl:otherwise>
                  <!-- case 4: "obj" has no "ttl" or "xreftext" attribute -->
                  <xsl:value-of select="concat('FIXME TITLE: ', @targetptr)" />
                  <xsl:if test="$obj.missing.title.warning = 1">
                    <xsl:message>
                      <xsl:text>Warning: </xsl:text>
                      <xsl:text>No GIMP help browser title for </xsl:text>
                      <xsl:value-of select="@element" />
                      <xsl:text> </xsl:text>
                      <xsl:value-of select="@targetptr" />
                    </xsl:message>
                  </xsl:if>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:otherwise> <!--end of "obj without ttl"-->
          </xsl:choose>
        </xsl:attribute> <!--title-->
        <xsl:attribute name="parent">
          <xsl:value-of select="ancestor::*[@targetptr][1]/@targetptr"/>
        </xsl:attribute>
        <xsl:attribute name="sort">
          <xsl:call-template name="gimp-help.help-id.sort"/>
        </xsl:attribute>
      </help-item>
    </xsl:if>
    <xsl:apply-templates select="*" />
  </xsl:template>

  <xsl:template match="*"></xsl:template>

</xsl:stylesheet>