summaryrefslogtreecommitdiffstats
path: root/common/entities/entities.xsl
blob: b28dbac6fa0e6aa4537595bef482aee9c95bacaf (plain)
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 version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output indent="yes" omit-xml-declaration="yes"/>

  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="entities">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="entity">
    <xsl:variable name="name" select="name"/>
    <xsl:variable name="desc">
      <xsl:choose>
        <xsl:when test="comment = ''">
          WHO AM I?  WHAT AM I? I CAN'T REMEMBER!
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="comment"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="extra">
      <xsl:choose>
        <xsl:when test="@kind = 'system'">
          <xsl:text> SYSTEM</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text></xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="body">
      <xsl:apply-templates/>
    </xsl:variable>
    <xsl:value-of select="concat( '&lt;!ENTITY ', @name, ' ', normalize-space($extra), ' &quot;', normalize-space($body), '&quot; &gt; &lt;!-- ', normalize-space($desc), ' --&gt;')" disable-output-escaping="yes"/>
  </xsl:template>

  <xsl:template match="use">
    <xsl:variable name="content" select="@entity"/>
    <xsl:value-of select="normalize-space(concat( '&amp;', $content, &apos;;&apos;))" disable-output-escaping="yes"/>
  </xsl:template>

  <xsl:template match="group">
    <xsl:comment>
      <xsl:value-of select="concat( ' Group: ', @name, ' ')"/>
    </xsl:comment>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="comment"/>

  <xsl:template match="title">
    <xsl:comment>
      <xsl:text> </xsl:text>
      <xsl:copy-of select="."/>
      <xsl:text> </xsl:text>
    </xsl:comment>
  </xsl:template>

  <xsl:template match="ulink">
    <xsl:text disable-output-escaping="yes">&lt;ulink url=&apos;</xsl:text>
    <xsl:value-of select="normalize-space(@url)" disable-output-escaping="yes"/>
    <xsl:text disable-output-escaping="yes">&apos;/&gt;</xsl:text>
  </xsl:template>

</xsl:stylesheet>