1 <?xml version="1.0" encoding="utf-8"?>
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 -->
7 <xsl:stylesheet version="1.0"
8 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
12 doctype-public="//W3C//DTD XHTML 1.0 Transitional//EN"
13 doctype-system="ttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
17 <xsl:strip-space elements="*"/>
19 <!-- as default, copy each node as-is -->
20 <xsl:template match="/ | node() | @* | comment() | processing-instruction()">
22 <xsl:apply-templates select="@* | node()"/>
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>
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>
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"/>
50 <xsl:when test="contains($str,'…')">
51 <xsl:call-template name="fixup">
52 <xsl:with-param name="str"><xsl:value-of select="substring-before($str,'…')"/></xsl:with-param>
54 <xsl:text>...</xsl:text>
55 <xsl:call-template name="fixup">
56 <xsl:with-param name="str"><xsl:value-of select="substring-after($str,'…')"/></xsl:with-param>
60 <xsl:value-of select="translate(translate(translate(translate($str,' ',' '),'“','"'),'”','"'),'˜','~')"/>