a b/src/filters/abiword.xsl
1
<?xml version="1.0"?>
2
<xsl:stylesheet version="1.0"
3
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
  xmlns:ab="http://www.abisource.com/awml.dtd" 
5
  exclude-result-prefixes="ab"
6
  >
7
8
<xsl:output method="html" encoding="UTF-8"/>
9
10
<xsl:template match="/">
11
<html>
12
  <head>
13
    <xsl:apply-templates select="ab:abiword/ab:metadata"/>
14
  </head>
15
  <body>
16
17
    <!-- This is for the older abiword format with no namespaces -->
18
    <xsl:for-each select="abiword/section">
19
      <xsl:apply-templates select="p"/>
20
    </xsl:for-each>
21
22
    <!-- Newer namespaced format -->
23
    <xsl:for-each select="ab:abiword/ab:section">
24
      <xsl:for-each select="ab:p">
25
        <p><xsl:value-of select="."/></p><xsl:text>
26
        </xsl:text>
27
      </xsl:for-each>
28
    </xsl:for-each>
29
30
  </body>
31
</html>
32
</xsl:template>
33
34
<xsl:template match="p">
35
  <p><xsl:value-of select="."/></p><xsl:text>
36
      </xsl:text>
37
</xsl:template>
38
39
<xsl:template match="ab:metadata">
40
    <xsl:for-each select="ab:m">
41
      <xsl:choose>
42
        <xsl:when test="@key = 'dc.creator'">
43
    <meta>
44
      <xsl:attribute name="name">author</xsl:attribute>
45
      <xsl:attribute name="content">
46
      <xsl:value-of select="."/>
47
      </xsl:attribute>
48
          </meta><xsl:text>
49
      </xsl:text>
50
        </xsl:when>
51
        <xsl:when test="@key = 'abiword.keywords'">
52
    <meta>
53
      <xsl:attribute name="name">keywords</xsl:attribute>
54
      <xsl:attribute name="content">
55
      <xsl:value-of select="."/>
56
      </xsl:attribute>
57
          </meta><xsl:text>
58
      </xsl:text>
59
        </xsl:when>
60
        <xsl:when test="@key = 'dc.subject'">
61
    <meta>
62
      <xsl:attribute name="name">keywords</xsl:attribute>
63
      <xsl:attribute name="content">
64
      <xsl:value-of select="."/>
65
      </xsl:attribute>
66
          </meta><xsl:text>
67
      </xsl:text>
68
        </xsl:when>
69
        <xsl:when test="@key = 'dc.description'">
70
    <meta>
71
      <xsl:attribute name="name">abstract</xsl:attribute>
72
      <xsl:attribute name="content">
73
      <xsl:value-of select="."/>
74
      </xsl:attribute>
75
          </meta><xsl:text>
76
      </xsl:text>
77
        </xsl:when>
78
        <xsl:when test="@key = 'dc.title'">
79
    <title><xsl:value-of select="."/></title><xsl:text>
80
      </xsl:text>
81
        </xsl:when>
82
        <xsl:otherwise>
83
        </xsl:otherwise>
84
      </xsl:choose>
85
    </xsl:for-each>
86
</xsl:template>
87
88
</xsl:stylesheet>