123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <?xml version='1.0' encoding="utf-8"?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- version='1.0'>
- <!-- ********************************************************************
- $Id$
- ********************************************************************
- XSL-FO specification treats all space characters like ordinary spaces.
- We need to map them to fo:leader with different widths in order to
- simulate desired behaviour.
- ******************************************************************** -->
- <xsl:template match="text()[namespace-uri(..) = '']">
- <xsl:choose>
- <xsl:when test="$passivetex.extensions != 0">
- <xsl:call-template name="passivetex.dash.subst">
- <xsl:with-param name="string">
- <xsl:call-template name="space.2000.subst">
- <xsl:with-param name="string" select="."/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.2000.subst">
- <xsl:with-param name="string" select="."/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:param name="space.enquad.width">0.5em</xsl:param> <!-- U+2000 -->
- <xsl:param name="space.emquad.width">1em</xsl:param> <!-- U+2001 -->
- <xsl:param name="space.enspace.width">0.5em</xsl:param> <!-- U+2002 -->
- <xsl:param name="space.emspace.width">1em</xsl:param> <!-- U+2003 -->
- <xsl:param name="space.3emspace.width">0.33em</xsl:param><!-- U+2004 -->
- <xsl:param name="space.4emspace.width">0.25em</xsl:param><!-- U+2005 -->
- <xsl:param name="space.6emspace.width">0.16em</xsl:param><!-- U+2006 -->
- <xsl:param name="space.figspace.width"></xsl:param> <!-- U+2007 -->
- <xsl:param name="space.punctspace.width"></xsl:param> <!-- U+2008 -->
- <xsl:param name="space.thinspace.width">0.2em</xsl:param><!-- U+2009 -->
- <xsl:param name="space.hairspace.width">0.1em</xsl:param><!-- U+200A -->
- <xsl:template name="space.2000.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.enquad.width != ''">
- <xsl:call-template name="space.2001.subst">
- <xsl:with-param name="string" select="substring-before($string, ' ')"/>
- </xsl:call-template>
- <fo:leader leader-length="{$space.enquad.width}"/>
- <xsl:call-template name="space.2000.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.2001.subst">
- <xsl:with-param name="string" select="$string"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="space.2001.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.emquad.width != ''">
- <xsl:call-template name="space.2002.subst">
- <xsl:with-param name="string" select="substring-before($string, ' ')"/>
- </xsl:call-template>
- <fo:leader leader-length="{$space.emquad.width}"/>
- <xsl:call-template name="space.2001.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.2002.subst">
- <xsl:with-param name="string" select="$string"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="space.2002.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.enspace.width != ''">
- <xsl:call-template name="space.2003.subst">
- <xsl:with-param name="string" select="substring-before($string, ' ')"/>
- </xsl:call-template>
- <fo:leader leader-length="{$space.enspace.width}"/>
- <xsl:call-template name="space.2002.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.2003.subst">
- <xsl:with-param name="string" select="$string"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="space.2003.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.emspace.width != ''">
- <xsl:call-template name="space.2004.subst">
- <xsl:with-param name="string" select="substring-before($string, ' ')"/>
- </xsl:call-template>
- <fo:leader leader-length="{$space.emspace.width}"/>
- <xsl:call-template name="space.2003.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.2004.subst">
- <xsl:with-param name="string" select="$string"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="space.2004.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.3emspace.width != ''">
- <xsl:call-template name="space.2005.subst">
- <xsl:with-param name="string" select="substring-before($string, ' ')"/>
- </xsl:call-template>
- <fo:leader leader-length="{$space.3emspace.width}"/>
- <xsl:call-template name="space.2004.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.2005.subst">
- <xsl:with-param name="string" select="$string"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="space.2005.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.4emspace.width != ''">
- <xsl:call-template name="space.2006.subst">
- <xsl:with-param name="string" select="substring-before($string, ' ')"/>
- </xsl:call-template>
- <fo:leader leader-length="{$space.4emspace.width}"/>
- <xsl:call-template name="space.2005.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.2006.subst">
- <xsl:with-param name="string" select="$string"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="space.2006.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.6emspace.width != ''">
- <xsl:call-template name="space.2007.subst">
- <xsl:with-param name="string" select="substring-before($string, ' ')"/>
- </xsl:call-template>
- <fo:leader leader-length="{$space.6emspace.width}"/>
- <xsl:call-template name="space.2006.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.2007.subst">
- <xsl:with-param name="string" select="$string"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="space.2007.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.figspace.width != ''">
- <xsl:call-template name="space.2008.subst">
- <xsl:with-param name="string" select="substring-before($string, ' ')"/>
- </xsl:call-template>
- <fo:leader leader-length="{$space.figspace.width}"/>
- <xsl:call-template name="space.2007.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.2008.subst">
- <xsl:with-param name="string" select="$string"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="space.2008.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.punctspace.width != ''">
- <xsl:call-template name="space.2009.subst">
- <xsl:with-param name="string" select="substring-before($string, ' ')"/>
- </xsl:call-template>
- <fo:leader leader-length="{$space.punctspace.width}"/>
- <xsl:call-template name="space.2008.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.2009.subst">
- <xsl:with-param name="string" select="$string"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="space.2009.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.thinspace.width != ''">
- <xsl:call-template name="space.200A.subst">
- <xsl:with-param name="string" select="substring-before($string, ' ')"/>
- </xsl:call-template>
- <fo:leader leader-length="{$space.thinspace.width}"/>
- <xsl:call-template name="space.2009.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="space.200A.subst">
- <xsl:with-param name="string" select="$string"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="space.200A.subst">
- <xsl:param name="string"/>
- <xsl:choose>
- <xsl:when test="contains($string, ' ') and $space.hairspace.width != ''">
- <xsl:value-of select="substring-before($string, ' ')"/>
- <fo:leader leader-length="{$space.hairspace.width}"/>
- <xsl:call-template name="space.200A.subst">
- <xsl:with-param name="string" select="substring-after($string, ' ')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$string"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </xsl:stylesheet>
|