summaryrefslogtreecommitdiffstats
path: root/packaging/strip-for-txt.xsl
blob: a61a8e8e23ee33c71eb43ae48d4c02c9ebf6d002 (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
71
72
73
74
75
76
77
78
79
<!-- Strip <revhistory> element from DocBook -->
<!-- Note this XSLT upgrades your DocBook to the V4.4 DTD! -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output encoding="UTF-8" indent="no" method="xml"
  omit-xml-declaration="no" standalone="no" version="1.0"
  doctype-public="-//OASIS//DTD DocBook XML V4.4//EN"
  doctype-system="http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" />

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

  <xsl:template match="/book">
    <xsl:element name="book">
      <xsl:for-each select="*">
	<xsl:choose>
	  <xsl:when test="self::bookinfo">
	    <xsl:call-template name="bookinfo"/>
	  </xsl:when>
	  <xsl:when test="self::index">
	    <xsl:text/>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:copy-of select="."/>
	  </xsl:otherwise>
	</xsl:choose>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

  <xsl:template match="/article">
    <xsl:element name="article">
      <xsl:for-each select="*">
	<xsl:choose>
	  <xsl:when test="self::articleinfo">
	    <xsl:call-template name="articleinfo"/>
	  </xsl:when>
	  <xsl:when test="self::index">
	    <xsl:text/>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:copy-of select="."/>
	  </xsl:otherwise>
	</xsl:choose>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

  <xsl:template name="bookinfo">
    <xsl:element name="bookinfo">
      <xsl:for-each select="*">
	<xsl:choose>
	  <xsl:when test="self::revhistory">
	    <xsl:text/>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:copy-of select="."/>
	  </xsl:otherwise>
	</xsl:choose>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

  <xsl:template name="articleinfo">
    <xsl:element name="articleinfo">
      <xsl:for-each select="*">
	<xsl:choose>
	  <xsl:when test="self::revhistory">
	    <xsl:text/>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:copy-of select="."/>
	  </xsl:otherwise>
	</xsl:choose>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>