~ubuntu-dev/ubuntu/lucid/mutt/lucid-201002110857

« back to all changes in this revision

Viewing changes to doc/db-cleanup.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-06-07 17:30:03 UTC
  • mto: (16.2.1 experimental) (2.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090607173003-rg37ui3h2bbv7wl0
Tags: upstream-1.5.19
ImportĀ upstreamĀ versionĀ 1.5.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="utf-8"?>
2
 
 
3
 
<!-- purpose: remove all non-ascii chars DocBook XSL places in -->
4
 
<!-- generated HTML files as the HTML -> plain ASCII text      -->
5
 
<!-- transition doesn't work that way                          -->
6
 
 
7
 
<xsl:stylesheet version="1.0"
8
 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
9
 
 
10
 
  <xsl:output 
11
 
    method="xml" 
12
 
    doctype-public="//W3C//DTD XHTML 1.0 Transitional//EN"
13
 
    doctype-system="ttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
14
 
    indent="no"
15
 
    />
16
 
 
17
 
  <xsl:strip-space elements="*"/>
18
 
 
19
 
  <!-- as default, copy each node as-is -->
20
 
  <xsl:template match="/ | node() | @* | comment() | processing-instruction()">
21
 
    <xsl:copy>
22
 
      <xsl:apply-templates select="@* | node()"/>
23
 
    </xsl:copy>
24
 
  </xsl:template>
25
 
 
26
 
  <!-- fixup all #text parts -->
27
 
  <xsl:template match="text()">
28
 
    <xsl:call-template name="fixup">
29
 
      <xsl:with-param name="str"><xsl:value-of select="."/></xsl:with-param>
30
 
    </xsl:call-template>
31
 
  </xsl:template>
32
 
 
33
 
  <!-- fixup all elements with title attributes, add more if needed -->
34
 
  <xsl:template match="@title">
35
 
    <xsl:attribute name="title">
36
 
      <xsl:call-template name="fixup">
37
 
        <xsl:with-param name="str"><xsl:value-of select="."/></xsl:with-param>
38
 
      </xsl:call-template>
39
 
    </xsl:attribute>
40
 
  </xsl:template>
41
 
 
42
 
  <!-- fixup a single string: -->
43
 
  <!-- 1) replace all non-breaking spaces by ascii-spaces (0xA0) -->
44
 
  <!-- 2) replace all quotes by ascii quotes (0x201C and 0x201D) -->
45
 
  <!-- 3) replace "fancy" tilde with real tilde (sic!) (0x2DC)   -->
46
 
  <!-- 4) replace "horizontal ellipses" with 3 dots (0x2026)     -->
47
 
  <xsl:template name="fixup">
48
 
    <xsl:param name="str"/>
49
 
    <xsl:choose>
50
 
      <xsl:when test="contains($str,'&#x2026;')">
51
 
        <xsl:call-template name="fixup">
52
 
          <xsl:with-param name="str"><xsl:value-of select="substring-before($str,'&#x2026;')"/></xsl:with-param>
53
 
        </xsl:call-template>
54
 
        <xsl:text>...</xsl:text>
55
 
        <xsl:call-template name="fixup">
56
 
          <xsl:with-param name="str"><xsl:value-of select="substring-after($str,'&#x2026;')"/></xsl:with-param>
57
 
        </xsl:call-template>
58
 
      </xsl:when>
59
 
      <xsl:otherwise>
60
 
        <xsl:value-of select="translate(translate(translate(translate($str,'&#xA0;',' '),'&#x201C;','&#x22;'),'&#x201D;','&#x22;'),'&#x2DC;','~')"/>
61
 
      </xsl:otherwise>
62
 
    </xsl:choose>
63
 
  </xsl:template>
64
 
 
65
 
</xsl:stylesheet>