[phpBB Documentation Commits] r363 [53/63] - in /trunk/documentation: ./ xsl/ xsl/pdf/ xsl/pdf/common/ xsl/pdf/fo/ xsl/pdf/html/ xsl/pdf/lib/
Patrick Webster
noxwizard at phpbb.com
Sun Jun 20 02:00:40 BST 2010
Added: trunk/documentation/xsl/pdf/fo/glossary.xsl
==============================================================================
*** trunk/documentation/xsl/pdf/fo/glossary.xsl (added)
--- trunk/documentation/xsl/pdf/fo/glossary.xsl Sun Jun 20 02:00:40 2010
***************
*** 0 ****
--- 1,1144 ----
+ <?xml version='1.0'?>
+ <!DOCTYPE xsl:stylesheet [
+ <!ENTITY % common.entities SYSTEM "../common/entities.ent">
+ %common.entities;
+ ]>
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink='http://www.w3.org/1999/xlink'
+ exclude-result-prefixes="xlink"
+ version='1.0'>
+
+ <!-- ********************************************************************
+ $Id: glossary.xsl 8393 2009-04-02 14:20:44Z dcramer $
+ ********************************************************************
+
+ This file is part of the XSL DocBook Stylesheet distribution.
+ See ../README or http://docbook.sf.net/release/xsl/current/ for
+ copyright and other information.
+
+ ******************************************************************** -->
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="glossary">
+ <xsl:call-template name="make-glossary"/>
+ </xsl:template>
+
+ <xsl:template match="glossdiv/title"/>
+ <xsl:template match="glossdiv/subtitle"/>
+ <xsl:template match="glossdiv/titleabbrev"/>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template name="make-glossary">
+ <xsl:param name="divs" select="glossdiv"/>
+ <xsl:param name="entries" select="glossentry"/>
+ <xsl:param name="preamble" select="*[not(self::title
+ or self::subtitle
+ or self::glossdiv
+ or self::glossentry)]"/>
+
+ &setup-language-variable;
+
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+
+ <xsl:variable name="presentation">
+ <xsl:call-template name="pi.dbfo_glossary-presentation"/>
+ </xsl:variable>
+
+ <xsl:variable name="term-width">
+ <xsl:call-template name="pi.dbfo_glossterm-width"/>
+ </xsl:variable>
+
+ <xsl:variable name="width">
+ <xsl:choose>
+ <xsl:when test="$term-width = ''">
+ <xsl:value-of select="$glossterm.width"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$term-width"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <fo:block id="{$id}">
+ <xsl:call-template name="glossary.titlepage"/>
+ </fo:block>
+
+ <xsl:if test="$preamble">
+ <xsl:apply-templates select="$preamble"/>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="$presentation = 'list'">
+ <xsl:apply-templates select="$divs" mode="glossary.as.list">
+ <xsl:with-param name="width" select="$width"/>
+ </xsl:apply-templates>
+ <xsl:if test="$entries">
+ <fo:list-block provisional-distance-between-starts="{$width}"
+ provisional-label-separation="{$glossterm.separation}"
+ xsl:use-attribute-sets="normal.para.spacing">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:apply-templates select="$entries" mode="glossary.as.list">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:list-block>
+ </xsl:if>
+ </xsl:when>
+ <xsl:when test="$presentation = 'blocks'">
+ <xsl:apply-templates select="$divs" mode="glossary.as.blocks"/>
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:apply-templates select="$entries" mode="glossary.as.blocks">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$glossary.as.blocks != 0">
+ <xsl:apply-templates select="$divs" mode="glossary.as.blocks"/>
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:apply-templates select="$entries" mode="glossary.as.blocks">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="$divs" mode="glossary.as.list">
+ <xsl:with-param name="width" select="$width"/>
+ </xsl:apply-templates>
+ <xsl:if test="$entries">
+ <fo:list-block provisional-distance-between-starts="{$width}"
+ provisional-label-separation="{$glossterm.separation}"
+ xsl:use-attribute-sets="normal.para.spacing">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:apply-templates select="$entries" mode="glossary.as.list">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:list-block>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="book/glossary|part/glossary|/glossary" priority="2">
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+
+ <xsl:variable name="master-reference">
+ <xsl:call-template name="select.pagemaster"/>
+ </xsl:variable>
+
+ <fo:page-sequence hyphenate="{$hyphenate}"
+ master-reference="{$master-reference}">
+ <xsl:attribute name="language">
+ <xsl:call-template name="l10n.language"/>
+ </xsl:attribute>
+
+ <xsl:attribute name="format">
+ <xsl:call-template name="page.number.format">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:attribute name="initial-page-number">
+ <xsl:call-template name="initial.page.number">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:attribute name="force-page-count">
+ <xsl:call-template name="force.page.count">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:attribute name="hyphenation-character">
+ <xsl:call-template name="gentext">
+ <xsl:with-param name="key" select="'hyphenation-character'"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="hyphenation-push-character-count">
+ <xsl:call-template name="gentext">
+ <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="hyphenation-remain-character-count">
+ <xsl:call-template name="gentext">
+ <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:apply-templates select="." mode="running.head.mode">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="." mode="running.foot.mode">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:apply-templates>
+
+ <fo:flow flow-name="xsl-region-body">
+ <xsl:call-template name="set.flow.properties">
+ <xsl:with-param name="element" select="local-name(.)"/>
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="make-glossary"/>
+ </fo:flow>
+ </fo:page-sequence>
+ </xsl:template>
+
+ <xsl:template match="glossary/glossaryinfo"></xsl:template>
+ <xsl:template match="glossary/info"></xsl:template>
+ <xsl:template match="glossary/title"></xsl:template>
+ <xsl:template match="glossary/subtitle"></xsl:template>
+ <xsl:template match="glossary/titleabbrev"></xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="glosslist">
+ &setup-language-variable;
+
+ <xsl:variable name="presentation">
+ <xsl:call-template name="pi.dbfo_glosslist-presentation"/>
+ </xsl:variable>
+
+ <xsl:variable name="term-width">
+ <xsl:call-template name="pi.dbfo_glossterm-width"/>
+ </xsl:variable>
+
+ <xsl:variable name="width">
+ <xsl:choose>
+ <xsl:when test="$term-width = ''">
+ <xsl:value-of select="$glossterm.width"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$term-width"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:if test="title or info/title">
+ <xsl:apply-templates select="(title|info/title)[1]" mode="list.title.mode"/>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="$presentation = 'list'">
+ <fo:list-block provisional-distance-between-starts="{$width}"
+ provisional-label-separation="{$glossterm.separation}"
+ xsl:use-attribute-sets="normal.para.spacing">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:apply-templates select="glossentry" mode="glossary.as.list">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="glossentry" mode="glossary.as.list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:list-block>
+ </xsl:when>
+ <xsl:when test="$presentation = 'blocks'">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:apply-templates select="glossentry" mode="glossary.as.blocks">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="glossentry" mode="glossary.as.blocks"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$glosslist.as.blocks != 0">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:apply-templates select="glossentry" mode="glossary.as.blocks">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="glossentry" mode="glossary.as.blocks"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <fo:list-block provisional-distance-between-starts="{$width}"
+ provisional-label-separation="{$glossterm.separation}"
+ xsl:use-attribute-sets="normal.para.spacing">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:apply-templates select="glossentry" mode="glossary.as.list">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="glossentry" mode="glossary.as.list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:list-block>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+ <!-- Glossary collection -->
+
+ <xsl:template match="glossary[@role='auto']" priority="2">
+ <xsl:variable name="collection" select="document($glossary.collection, .)"/>
+ <xsl:if test="$glossary.collection = ''">
+ <xsl:message>
+ <xsl:text>Warning: processing automatic glossary </xsl:text>
+ <xsl:text>without a glossary.collection file.</xsl:text>
+ </xsl:message>
+ </xsl:if>
+
+ <xsl:if test="not($collection) and $glossary.collection != ''">
+ <xsl:message>
+ <xsl:text>Warning: processing automatic glossary but unable to </xsl:text>
+ <xsl:text>open glossary.collection file '</xsl:text>
+ <xsl:value-of select="$glossary.collection"/>
+ <xsl:text>'</xsl:text>
+ </xsl:message>
+ </xsl:if>
+
+ <xsl:call-template name="make-auto-glossary"/>
+ </xsl:template>
+
+ <xsl:template name="make-auto-glossary">
+ <xsl:param name="collection" select="document($glossary.collection, .)"/>
+ <xsl:param name="terms" select="//glossterm[not(parent::glossdef)]|//firstterm"/>
+ <xsl:param name="preamble" select="*[not(self::title
+ or self::subtitle
+ or self::glossdiv
+ or self::glossentry)]"/>
+
+ &setup-language-variable;
+
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+
+ <xsl:variable name="presentation">
+ <xsl:call-template name="pi.dbfo_glossary-presentation"/>
+ </xsl:variable>
+
+ <xsl:variable name="term-width">
+ <xsl:call-template name="pi.dbfo_glossterm-width"/>
+ </xsl:variable>
+
+ <xsl:variable name="width">
+ <xsl:choose>
+ <xsl:when test="$term-width = ''">
+ <xsl:value-of select="$glossterm.width"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$term-width"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:if test="$glossary.collection = ''">
+ <xsl:message>
+ <xsl:text>Warning: processing automatic glossary </xsl:text>
+ <xsl:text>without a glossary.collection file.</xsl:text>
+ </xsl:message>
+ </xsl:if>
+
+ <fo:block id="{$id}">
+ <xsl:call-template name="glossary.titlepage"/>
+ </fo:block>
+
+ <xsl:if test="$preamble">
+ <xsl:apply-templates select="$preamble"/>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="glossdiv and $collection//glossdiv">
+ <xsl:for-each select="$collection//glossdiv">
+ <!-- first see if there are any in this div -->
+ <xsl:variable name="exist.test">
+ <xsl:for-each select="glossentry">
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:value-of select="glossterm"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:if test="$exist.test != ''">
+ <xsl:choose>
+ <xsl:when test="$presentation = 'list'">
+ <xsl:apply-templates select="." mode="auto-glossary-as-list">
+ <xsl:with-param name="width" select="$width"/>
+ <xsl:with-param name="terms" select="$terms"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:when test="$presentation = 'blocks'">
+ <xsl:apply-templates select="." mode="auto-glossary-as-blocks">
+ <xsl:with-param name="terms" select="$terms"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:when test="$glossary.as.blocks != 0">
+ <xsl:apply-templates select="." mode="auto-glossary-as-blocks">
+ <xsl:with-param name="terms" select="$terms"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="." mode="auto-glossary-as-list">
+ <xsl:with-param name="width" select="$width"/>
+ <xsl:with-param name="terms" select="$terms"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$presentation = 'list'">
+ <fo:list-block provisional-distance-between-starts="{$width}"
+ provisional-label-separation="{$glossterm.separation}"
+ xsl:use-attribute-sets="normal.para.spacing">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:for-each select="$collection//glossentry">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:apply-templates select="."
+ mode="auto-glossary-as-list"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:for-each select="$collection//glossentry">
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:apply-templates select="."
+ mode="auto-glossary-as-list"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:list-block>
+ </xsl:when>
+ <xsl:when test="$presentation = 'blocks' or
+ $glossary.as.blocks != 0">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:for-each select="$collection//glossentry">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:apply-templates select="."
+ mode="auto-glossary-as-blocks"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:for-each select="$collection//glossentry">
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:apply-templates select="."
+ mode="auto-glossary-as-blocks"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <fo:list-block provisional-distance-between-starts="{$width}"
+ provisional-label-separation="{$glossterm.separation}"
+ xsl:use-attribute-sets="normal.para.spacing">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:for-each select="$collection//glossentry">
+
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:apply-templates select="."
+ mode="auto-glossary-as-list"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:for-each select="$collection//glossentry">
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:apply-templates select="."
+ mode="auto-glossary-as-list"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:list-block>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="book/glossary[@role='auto']|
+ part/glossary[@role='auto']|
+ /glossary[@role='auto']" priority="2.5">
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+
+ <xsl:variable name="master-reference">
+ <xsl:call-template name="select.pagemaster"/>
+ </xsl:variable>
+
+ <xsl:if test="$glossary.collection = ''">
+ <xsl:message>
+ <xsl:text>Warning: processing automatic glossary </xsl:text>
+ <xsl:text>without a glossary.collection file.</xsl:text>
+ </xsl:message>
+ </xsl:if>
+
+ <fo:page-sequence hyphenate="{$hyphenate}"
+ master-reference="{$master-reference}">
+ <xsl:attribute name="language">
+ <xsl:call-template name="l10n.language"/>
+ </xsl:attribute>
+ <xsl:attribute name="format">
+ <xsl:call-template name="page.number.format">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:attribute name="initial-page-number">
+ <xsl:call-template name="initial.page.number">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:attribute name="force-page-count">
+ <xsl:call-template name="force.page.count">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:attribute name="hyphenation-character">
+ <xsl:call-template name="gentext">
+ <xsl:with-param name="key" select="'hyphenation-character'"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="hyphenation-push-character-count">
+ <xsl:call-template name="gentext">
+ <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="hyphenation-remain-character-count">
+ <xsl:call-template name="gentext">
+ <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:apply-templates select="." mode="running.head.mode">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="." mode="running.foot.mode">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:apply-templates>
+
+ <fo:flow flow-name="xsl-region-body">
+ <xsl:call-template name="set.flow.properties">
+ <xsl:with-param name="element" select="local-name(.)"/>
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="make-auto-glossary"/>
+ </fo:flow>
+ </fo:page-sequence>
+ </xsl:template>
+
+ <xsl:template match="glossdiv" mode="auto-glossary-as-list">
+ <xsl:param name="width" select="$glossterm.width"/>
+ <xsl:param name="terms" select="."/>
+
+ &setup-language-variable;
+
+ <xsl:variable name="preamble"
+ select="*[not(self::title
+ or self::subtitle
+ or self::glossentry)]"/>
+
+ <xsl:call-template name="glossdiv.titlepage"/>
+
+ <xsl:apply-templates select="$preamble"/>
+
+ <fo:list-block provisional-distance-between-starts="{$width}"
+ provisional-label-separation="{$glossterm.separation}"
+ xsl:use-attribute-sets="normal.para.spacing">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:for-each select="glossentry">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:apply-templates select="." mode="auto-glossary-as-list"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:for-each select="glossentry">
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:apply-templates select="." mode="auto-glossary-as-list"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:list-block>
+ </xsl:template>
+
+ <xsl:template match="glossentry" mode="auto-glossary-as-list">
+ <xsl:apply-templates select="." mode="glossary.as.list"/>
+ </xsl:template>
+
+ <xsl:template match="glossdiv" mode="auto-glossary-as-blocks">
+ <xsl:param name="terms" select="."/>
+
+ &setup-language-variable;
+
+ <xsl:variable name="preamble"
+ select="*[not(self::title
+ or self::subtitle
+ or self::glossentry)]"/>
+
+ <xsl:call-template name="glossdiv.titlepage"/>
+
+ <xsl:apply-templates select="$preamble"/>
+
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:for-each select="glossentry">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:apply-templates select="." mode="auto-glossary-as-blocks"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:for-each select="glossentry">
+ <xsl:variable name="cterm" select="glossterm"/>
+ <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+ <xsl:apply-templates select="." mode="auto-glossary-as-blocks"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <xsl:template match="glossentry" mode="auto-glossary-as-blocks">
+ <xsl:apply-templates select="." mode="glossary.as.blocks"/>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+ <!-- Format glossary as a list -->
+
+ <xsl:template match="glossdiv" mode="glossary.as.list">
+ <xsl:param name="width" select="$glossterm.width"/>
+
+ &setup-language-variable;
+
+ <xsl:variable name="entries" select="glossentry"/>
+
+ <xsl:variable name="preamble"
+ select="*[not(self::title
+ or self::subtitle
+ or self::glossentry)]"/>
+
+ <xsl:call-template name="glossdiv.titlepage"/>
+
+ <xsl:apply-templates select="$preamble"/>
+
+ <fo:list-block provisional-distance-between-starts="{$width}"
+ provisional-label-separation="{$glossterm.separation}"
+ xsl:use-attribute-sets="normal.para.spacing">
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:apply-templates select="$entries" mode="glossary.as.list">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:list-block>
+ </xsl:template>
+
+ <!--
+ GlossEntry ::=
+ GlossTerm, Acronym?, Abbrev?,
+ (IndexTerm)*,
+ RevHistory?,
+ (GlossSee | GlossDef+)
+ -->
+
+ <xsl:template match="glossentry" mode="glossary.as.list">
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+
+ <fo:list-item xsl:use-attribute-sets="glossentry.list.item.properties">
+ <xsl:call-template name="anchor">
+ <xsl:with-param name="conditional">
+ <xsl:choose>
+ <xsl:when test="$glossterm.auto.link != 0
+ or $glossary.collection != ''">0</xsl:when>
+ <xsl:otherwise>1</xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block xsl:use-attribute-sets="glossterm.list.properties">
+ <xsl:choose>
+ <xsl:when test="$glossentry.show.acronym = 'primary'">
+ <xsl:choose>
+ <xsl:when test="acronym|abbrev">
+ <xsl:apply-templates select="acronym|abbrev"
+ mode="glossary.as.list"/>
+ <xsl:text> (</xsl:text>
+ <xsl:apply-templates select="glossterm"
+ mode="glossary.as.list"/>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="glossterm"
+ mode="glossary.as.list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:when test="$glossentry.show.acronym = 'yes'">
+ <xsl:apply-templates select="glossterm" mode="glossary.as.list"/>
+
+ <xsl:if test="acronym|abbrev">
+ <xsl:text> (</xsl:text>
+ <xsl:apply-templates select="acronym|abbrev"
+ mode="glossary.as.list"/>
+ <xsl:text>)</xsl:text>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:apply-templates select="glossterm" mode="glossary.as.list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates select="indexterm"/>
+ </fo:block>
+ </fo:list-item-label>
+
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block xsl:use-attribute-sets="glossdef.list.properties">
+ <xsl:apply-templates select="glosssee|glossdef" mode="glossary.as.list"/>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </xsl:template>
+
+ <xsl:template match="glossentry/glossterm" mode="glossary.as.list">
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+ <fo:inline id="{$id}">
+ <xsl:apply-templates/>
+ </fo:inline>
+ <xsl:if test="following-sibling::glossterm">, </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="glossentry/acronym" mode="glossary.as.list">
+ <xsl:apply-templates/>
+ <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="glossentry/abbrev" mode="glossary.as.list">
+ <xsl:apply-templates/>
+ <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="glossentry/revhistory" mode="glossary.as.list">
+ </xsl:template>
+
+ <xsl:template match="glossentry/glosssee" mode="glossary.as.list">
+ <xsl:variable name="otherterm" select="@otherterm"/>
+ <xsl:variable name="targets" select="key('id', $otherterm)"/>
+ <xsl:variable name="target" select="$targets[1]"/>
+ <xsl:variable name="xlink" select="@xlink:href"/>
+
+ <fo:block>
+ <xsl:variable name="template">
+ <xsl:call-template name="gentext.template">
+ <xsl:with-param name="context" select="'glossary'"/>
+ <xsl:with-param name="name" select="'see'"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="title">
+ <xsl:choose>
+ <xsl:when test="$target">
+ <fo:basic-link internal-destination="{$otherterm}"
+ xsl:use-attribute-sets="xref.properties">
+ <xsl:apply-templates select="$target" mode="xref-to"/>
+ </fo:basic-link>
+ </xsl:when>
+ <xsl:when test="$xlink">
+ <xsl:call-template name="simple.xlink">
+ <xsl:with-param name="content">
+ <xsl:apply-templates/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$otherterm != '' and not($target)">
+ <xsl:message>
+ <xsl:text>Warning: glosssee @otherterm reference not found: </xsl:text>
+ <xsl:value-of select="$otherterm"/>
+ </xsl:message>
+ <xsl:apply-templates mode="glossary.as.list"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="glossary.as.list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:call-template name="substitute-markup">
+ <xsl:with-param name="template" select="$template"/>
+ <xsl:with-param name="title" select="$title"/>
+ </xsl:call-template>
+ </fo:block>
+ </xsl:template>
+
+ <xsl:template match="glossentry/glossdef" mode="glossary.as.list">
+ <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"/>
+ <xsl:if test="glossseealso">
+ <fo:block>
+ <xsl:variable name="template">
+ <xsl:call-template name="gentext.template">
+ <xsl:with-param name="context" select="'glossary'"/>
+ <xsl:with-param name="name" select="'seealso'"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="title">
+ <xsl:apply-templates select="glossseealso" mode="glossary.as.list"/>
+ </xsl:variable>
+ <xsl:call-template name="substitute-markup">
+ <xsl:with-param name="template" select="$template"/>
+ <xsl:with-param name="title" select="$title"/>
+ </xsl:call-template>
+ </fo:block>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="glossentry/glossdef/para[1]|glossentry/glossdef/simpara[1]"
+ mode="glossary.as.list">
+ <fo:block>
+ <xsl:apply-templates/>
+ </fo:block>
+ </xsl:template>
+
+ <xsl:template match="glossseealso" mode="glossary.as.list">
+ <xsl:variable name="otherterm" select="@otherterm"/>
+ <xsl:variable name="targets" select="key('id', $otherterm)"/>
+ <xsl:variable name="target" select="$targets[1]"/>
+ <xsl:variable name="xlink" select="@xlink:href"/>
+
+ <xsl:choose>
+ <xsl:when test="$target">
+ <fo:basic-link internal-destination="{$otherterm}"
+ xsl:use-attribute-sets="xref.properties">
+ <xsl:apply-templates select="$target" mode="xref-to"/>
+ </fo:basic-link>
+ </xsl:when>
+ <xsl:when test="$xlink">
+ <xsl:call-template name="simple.xlink">
+ <xsl:with-param name="content">
+ <xsl:apply-templates/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$otherterm != '' and not($target)">
+ <xsl:message>
+ <xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
+ <xsl:value-of select="$otherterm"/>
+ </xsl:message>
+ <xsl:apply-templates mode="glossary.as.list"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="glossary.as.list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:choose>
+ <xsl:when test="position() = last()"/>
+ <xsl:otherwise>
+ <xsl:call-template name="gentext.template">
+ <xsl:with-param name="context" select="'glossary'"/>
+ <xsl:with-param name="name" select="'seealso-separator'"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+ <!-- Format glossary blocks -->
+
+ <xsl:template match="glossdiv" mode="glossary.as.blocks">
+ &setup-language-variable;
+ <xsl:variable name="entries" select="glossentry"/>
+ <xsl:variable name="preamble"
+ select="*[not(self::title
+ or self::subtitle
+ or self::glossentry)]"/>
+
+ <xsl:call-template name="glossdiv.titlepage"/>
+
+ <xsl:apply-templates select="$preamble"/>
+
+ <xsl:choose>
+ <xsl:when test="$glossary.sort != 0">
+ <xsl:apply-templates select="$entries" mode="glossary.as.blocks">
+ <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!--
+ GlossEntry ::=
+ GlossTerm, Acronym?, Abbrev?,
+ (IndexTerm)*,
+ RevHistory?,
+ (GlossSee | GlossDef+)
+ -->
+
+ <xsl:template match="glossentry" mode="glossary.as.blocks">
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+
+ <fo:block xsl:use-attribute-sets="glossterm.block.properties">
+ <xsl:call-template name="anchor">
+ <xsl:with-param name="conditional">
+ <xsl:choose>
+ <xsl:when test="$glossterm.auto.link != 0
+ or $glossary.collection != ''">0</xsl:when>
+ <xsl:otherwise>1</xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:choose>
+ <xsl:when test="$glossentry.show.acronym = 'primary'">
+ <xsl:choose>
+ <xsl:when test="acronym|abbrev">
+ <xsl:apply-templates select="acronym|abbrev" mode="glossary.as.blocks"/>
+ <xsl:text> (</xsl:text>
+ <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
+ <xsl:text>)</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:when test="$glossentry.show.acronym = 'yes'">
+ <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
+
+ <xsl:if test="acronym|abbrev">
+ <xsl:text> (</xsl:text>
+ <xsl:apply-templates select="acronym|abbrev" mode="glossary.as.blocks"/>
+ <xsl:text>)</xsl:text>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:apply-templates select="indexterm"/>
+ </fo:block>
+
+ <fo:block xsl:use-attribute-sets="glossdef.block.properties">
+ <xsl:apply-templates select="glosssee|glossdef" mode="glossary.as.blocks"/>
+ </fo:block>
+ </xsl:template>
+
+ <xsl:template match="glossentry/glossterm" mode="glossary.as.blocks">
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+ <fo:inline id="{$id}">
+ <xsl:apply-templates/>
+ </fo:inline>
+ <xsl:if test="following-sibling::glossterm">, </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="glossentry/acronym" mode="glossary.as.blocks">
+ <xsl:apply-templates/>
+ <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="glossentry/abbrev" mode="glossary.as.blocks">
+ <xsl:apply-templates/>
+ <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="glossentry/glosssee" mode="glossary.as.blocks">
+ <xsl:variable name="otherterm" select="@otherterm"/>
+ <xsl:variable name="targets" select="key('id', $otherterm)"/>
+ <xsl:variable name="target" select="$targets[1]"/>
+ <xsl:variable name="xlink" select="@xlink:href"/>
+
+ <xsl:variable name="template">
+ <xsl:call-template name="gentext.template">
+ <xsl:with-param name="context" select="'glossary'"/>
+ <xsl:with-param name="name" select="'see'"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="title">
+ <xsl:choose>
+ <xsl:when test="$target">
+ <fo:basic-link internal-destination="{$otherterm}"
+ xsl:use-attribute-sets="xref.properties">
+ <xsl:apply-templates select="$target" mode="xref-to"/>
+ </fo:basic-link>
+ </xsl:when>
+ <xsl:when test="$xlink">
+ <xsl:call-template name="simple.xlink">
+ <xsl:with-param name="content">
+ <xsl:apply-templates/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$otherterm != '' and not($target)">
+ <xsl:message>
+ <xsl:text>Warning: glosssee @otherterm reference not found: </xsl:text>
+ <xsl:value-of select="$otherterm"/>
+ </xsl:message>
+ <xsl:apply-templates mode="glossary.as.blocks"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="glossary.as.blocks"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:call-template name="substitute-markup">
+ <xsl:with-param name="template" select="$template"/>
+ <xsl:with-param name="title" select="$title"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="glossentry/glossdef" mode="glossary.as.blocks">
+ <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"
+ mode="glossary.as.blocks"/>
+ <xsl:if test="glossseealso">
+ <fo:block>
+ <xsl:variable name="template">
+ <xsl:call-template name="gentext.template">
+ <xsl:with-param name="context" select="'glossary'"/>
+ <xsl:with-param name="name" select="'seealso'"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="title">
+ <xsl:apply-templates select="glossseealso" mode="glossary.as.blocks"/>
+ </xsl:variable>
+ <xsl:call-template name="substitute-markup">
+ <xsl:with-param name="template" select="$template"/>
+ <xsl:with-param name="title" select="$title"/>
+ </xsl:call-template>
+ </fo:block>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="glossentry/glossdef/para[1]|glossentry/glossdef/simpara[1]"
+ mode="glossary.as.blocks">
+ <fo:block>
+ <xsl:apply-templates/>
+ </fo:block>
+ </xsl:template>
+
+ <!-- Handle any other glossdef content normally -->
+ <xsl:template match="*" mode="glossary.as.blocks">
+ <xsl:apply-templates select="." />
+ </xsl:template>
+
+ <xsl:template match="glossseealso" mode="glossary.as.blocks">
+ <xsl:variable name="otherterm" select="@otherterm"/>
+ <xsl:variable name="targets" select="key('id', $otherterm)"/>
+ <xsl:variable name="target" select="$targets[1]"/>
+ <xsl:variable name="xlink" select="@xlink:href"/>
+
+ <xsl:choose>
+ <xsl:when test="$target">
+ <fo:basic-link internal-destination="{$otherterm}"
+ xsl:use-attribute-sets="xref.properties">
+ <xsl:apply-templates select="$target" mode="xref-to"/>
+ </fo:basic-link>
+ </xsl:when>
+ <xsl:when test="$xlink">
+ <xsl:call-template name="simple.xlink">
+ <xsl:with-param name="content">
+ <xsl:apply-templates/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$otherterm != '' and not($target)">
+ <xsl:message>
+ <xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
+ <xsl:value-of select="$otherterm"/>
+ </xsl:message>
+ <xsl:apply-templates mode="glossary.as.blocks"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="glossary.as.blocks"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:choose>
+ <xsl:when test="position() = last()"/>
+ <xsl:otherwise>
+ <xsl:call-template name="gentext.template">
+ <xsl:with-param name="context" select="'glossary'"/>
+ <xsl:with-param name="name" select="'seealso-separator'"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ </xsl:stylesheet>
Added: trunk/documentation/xsl/pdf/fo/graphics.xsl
==============================================================================
*** trunk/documentation/xsl/pdf/fo/graphics.xsl (added)
--- trunk/documentation/xsl/pdf/fo/graphics.xsl Sun Jun 20 02:00:40 2010
***************
*** 0 ****
--- 1,642 ----
+ <?xml version='1.0'?>
+ <!DOCTYPE xsl:stylesheet [
+ <!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
+ <!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
+ ]>
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory"
+ xmlns:xtext="com.nwalsh.xalan.Text"
+ xmlns:lxslt="http://xml.apache.org/xslt"
+ exclude-result-prefixes="xlink stext xtext lxslt"
+ extension-element-prefixes="stext xtext"
+ version='1.0'>
+
+ <!-- ********************************************************************
+ $Id: graphics.xsl 8144 2008-10-25 09:41:24Z mzjn $
+ ********************************************************************
+
+ This file is part of the XSL DocBook Stylesheet distribution.
+ See ../README or http://docbook.sf.net/release/xsl/current/ for
+ copyright and other information.
+
+ Contributors:
+ Colin Paul Adams, <colin at colina.demon.co.uk>
+ Paul Grosso, <pgrosso at arbortext.com>
+
+ ******************************************************************** -->
+
+ <!-- ==================================================================== -->
+ <!-- Graphic format tests for the FO backend -->
+
+ <xsl:param name="graphic.notations">
+ <!-- n.b. exactly one leading space, one trailing space, and one inter-word space -->
+ <xsl:choose>
+ <xsl:when test="$passivetex.extensions != 0">
+ <xsl:text> PNG PDF JPG JPEG linespecific </xsl:text>
+ </xsl:when>
+ <xsl:when test="$fop1.extensions != 0">
+ <xsl:text> BMP GIF TIFF SVG PNG EPS JPG JPEG linespecific </xsl:text>
+ </xsl:when>
+ <xsl:when test="$fop.extensions != 0">
+ <xsl:text> BMP GIF TIFF SVG PNG EPS JPG JPEG linespecific </xsl:text>
+ </xsl:when>
+ <xsl:when test="$arbortext.extensions != 0">
+ <xsl:text> PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text>
+ </xsl:when>
+ <xsl:when test="$xep.extensions != 0">
+ <xsl:text> SVG PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text> PNG PDF JPG JPEG linespecific GIF GIF87a GIF89a TIFF BMP </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:param>
+
+ <xsl:template name="is.graphic.format">
+ <xsl:param name="format"/>
+ <xsl:if test="contains($graphic.notations, concat(' ',$format,' '))">1</xsl:if>
+ </xsl:template>
+
+ <xsl:param name="graphic.extensions">
+ <!-- n.b. exactly one leading space, one trailing space, and one inter-word space -->
+ <xsl:choose>
+ <xsl:when test="$passivetex.extensions != 0">
+ <xsl:text> png pdf jpg jpeg </xsl:text>
+ </xsl:when>
+ <xsl:when test="$fop1.extensions != 0">
+ <xsl:text> bmp gif tif tiff svg png pdf jpg jpeg eps </xsl:text>
+ </xsl:when>
+ <xsl:when test="$fop.extensions != 0">
+ <xsl:text> bmp gif tif tiff svg png pdf jpg jpeg eps </xsl:text>
+ </xsl:when>
+ <xsl:when test="$arbortext.extensions != 0">
+ <xsl:text> png pdf jpg jpeg gif tif tiff bmp </xsl:text>
+ </xsl:when>
+ <xsl:when test="$xep.extensions != 0">
+ <xsl:text> svg png pdf jpg jpeg gif tif tiff bmp eps </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text> svg png pdf jpg jpeg gif tif tiff bmp eps </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:param>
+
+ <xsl:template name="is.graphic.extension">
+ <xsl:param name="ext"/>
+ <xsl:variable name="lcext" select="translate($ext,
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'abcdefghijklmnopqrstuvwxyz')"/>
+
+ <xsl:if test="contains($graphic.extensions,
+ concat(' ', $lcext, ' '))">1</xsl:if>
+ </xsl:template>
+
+ <xsl:template name="graphic.format.content-type">
+ <xsl:param name="format"/>
+ <xsl:variable name="is.graphic.format">
+ <xsl:call-template name="is.graphic.format">
+ <xsl:with-param name="format" select="$format"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:if test="$is.graphic.format">
+ <xsl:choose>
+ <xsl:when test="$format = ''"></xsl:when>
+ <xsl:when test="$format = 'linespecific'"></xsl:when>
+ <xsl:when test="$format = 'PS'">application/postscript</xsl:when>
+ <xsl:when test="$format = 'PDF'">application/pdf</xsl:when>
+ <xsl:when test="$format = 'PNG'">image/png</xsl:when>
+ <xsl:when test="$format = 'SVG'">image/svg+xml</xsl:when>
+ <xsl:when test="$format = 'JPG'">image/jpeg</xsl:when>
+ <xsl:when test="$format = 'GIF87a'">image/gif</xsl:when>
+ <xsl:when test="$format = 'GIF89a'">image/gif</xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat('image/',
+ translate($format, &uppercase;, &lowercase;))"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:template>
+
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="screenshot">
+ <fo:block>
+ <xsl:apply-templates/>
+ </fo:block>
+ </xsl:template>
+
+ <xsl:template match="screeninfo">
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+ <!-- Override these templates for FO -->
+ <!-- ==================================================================== -->
+
+ <xsl:template name="process.image">
+ <!-- When this template is called, the current node should be -->
+ <!-- a graphic, inlinegraphic, imagedata, or videodata. All -->
+ <!-- those elements have the same set of attributes, so we can -->
+ <!-- handle them all in one place. -->
+
+ <xsl:variable name="scalefit">
+ <xsl:choose>
+ <xsl:when test="$ignore.image.scaling != 0">0</xsl:when>
+ <xsl:when test="@contentwidth">0</xsl:when>
+ <xsl:when test="@contentdepth and
+ @contentdepth != '100%'">0</xsl:when>
+ <xsl:when test="@scale">0</xsl:when>
+ <xsl:when test="@scalefit"><xsl:value-of select="@scalefit"/></xsl:when>
+ <xsl:when test="@width or @depth">1</xsl:when>
+ <xsl:when test="$default.image.width != ''">1</xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="scale">
+ <xsl:choose>
+ <xsl:when test="$ignore.image.scaling != 0">0</xsl:when>
+ <xsl:when test="@contentwidth or @contentdepth">1.0</xsl:when>
+ <xsl:when test="@scale">
+ <xsl:value-of select="@scale div 100.0"/>
+ </xsl:when>
+ <xsl:otherwise>0.7855</xsl:otherwise> <!-- 1.0 --> <!-- 78.55% hack job of fixing the scaling it's doing -->
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="filename">
+ <xsl:choose>
+ <xsl:when test="local-name(.) = 'graphic'
+ or local-name(.) = 'inlinegraphic'">
+ <!-- handle legacy graphic and inlinegraphic by new template -->
+ <xsl:call-template name="mediaobject.filename">
+ <xsl:with-param name="object" select="."/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- imagedata, videodata, audiodata -->
+ <xsl:call-template name="mediaobject.filename">
+ <xsl:with-param name="object" select=".."/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="content-type">
+ <xsl:if test="@format">
+ <xsl:call-template name="graphic.format.content-type">
+ <xsl:with-param name="format" select="@format"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+
+ <xsl:variable name="bgcolor">
+ <xsl:call-template name="pi.dbfo_background-color">
+ <xsl:with-param name="node" select=".."/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <fo:external-graphic>
+ <xsl:attribute name="src">
+ <xsl:call-template name="fo-external-image">
+ <xsl:with-param name="filename">
+ <xsl:if test="$img.src.path != '' and
+ not(starts-with($filename, '/')) and
+ not(contains($filename, '://'))">
+ <xsl:value-of select="$img.src.path"/>
+ </xsl:if>
+ <xsl:value-of select="$filename"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:attribute name="width">
+ <xsl:choose>
+ <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
+ <xsl:when test="contains(@width,'%')">
+ <xsl:value-of select="@width"/>
+ </xsl:when>
+ <xsl:when test="@width and not(@width = '')">
+ <xsl:call-template name="length-spec">
+ <xsl:with-param name="length" select="@width"/>
+ <xsl:with-param name="default.units" select="'px'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="not(@depth) and $default.image.width != ''">
+ <xsl:call-template name="length-spec">
+ <xsl:with-param name="length" select="$default.image.width"/>
+ <xsl:with-param name="default.units" select="'px'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>auto</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <xsl:attribute name="height">
+ <xsl:choose>
+ <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
+ <xsl:when test="contains(@depth,'%')">
+ <xsl:value-of select="@depth"/>
+ </xsl:when>
+ <xsl:when test="@depth">
+ <xsl:call-template name="length-spec">
+ <xsl:with-param name="length" select="@depth"/>
+ <xsl:with-param name="default.units" select="'px'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>auto</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <xsl:attribute name="content-width">
+ <xsl:choose>
+ <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
+ <xsl:when test="contains(@contentwidth,'%')">
+ <xsl:value-of select="@contentwidth"/>
+ </xsl:when>
+ <xsl:when test="@contentwidth">
+ <xsl:call-template name="length-spec">
+ <xsl:with-param name="length" select="@contentwidth"/>
+ <xsl:with-param name="default.units" select="'px'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="number($scale) != 1.0">
+ <xsl:value-of select="$scale * 100"/>
+ <xsl:text>%</xsl:text>
+ </xsl:when>
+ <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
+ <xsl:otherwise>auto</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <xsl:attribute name="content-height">
+ <xsl:choose>
+ <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
+ <xsl:when test="contains(@contentdepth,'%')">
+ <xsl:value-of select="@contentdepth"/>
+ </xsl:when>
+ <xsl:when test="@contentdepth">
+ <xsl:call-template name="length-spec">
+ <xsl:with-param name="length" select="@contentdepth"/>
+ <xsl:with-param name="default.units" select="'px'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="number($scale) != 1.0">
+ <xsl:value-of select="$scale * 100"/>
+ <xsl:text>%</xsl:text>
+ </xsl:when>
+ <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
+ <xsl:otherwise>auto</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <xsl:if test="$content-type != ''">
+ <xsl:attribute name="content-type">
+ <xsl:value-of select="concat('content-type:',$content-type)"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="$bgcolor != ''">
+ <xsl:attribute name="background-color">
+ <xsl:value-of select="$bgcolor"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="@align">
+ <xsl:attribute name="text-align">
+ <xsl:value-of select="@align"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="@valign">
+ <xsl:attribute name="display-align">
+ <xsl:choose>
+ <xsl:when test="@valign = 'top'">before</xsl:when>
+ <xsl:when test="@valign = 'middle'">center</xsl:when>
+ <xsl:when test="@valign = 'bottom'">after</xsl:when>
+ <xsl:otherwise>auto</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ </fo:external-graphic>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="graphic">
+ <xsl:choose>
+ <xsl:when test="parent::inlineequation">
+ <xsl:call-template name="process.image"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <fo:block>
+ <xsl:if test="@align">
+ <xsl:attribute name="text-align">
+ <xsl:value-of select="@align"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:call-template name="process.image"/>
+ </fo:block>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="inlinegraphic">
+ <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
+ <xsl:variable name="filename">
+ <xsl:choose>
+ <xsl:when test="@entityref">
+ <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="@fileref"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="@format='linespecific'">
+ <xsl:choose>
+ <xsl:when test="$use.extensions != '0'
+ and $textinsert.extension != '0'">
+ <xsl:choose>
+ <xsl:when test="contains($vendor, 'SAXON')">
+ <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
+ </xsl:when>
+ <xsl:when test="contains($vendor, 'Apache Software Foundation')">
+ <xtext:insertfile href="{$filename}"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message terminate="yes">
+ <xsl:text>Don't know how to insert files with </xsl:text>
+ <xsl:value-of select="$vendor"/>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message terminate="yes">
+ <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
+ <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="process.image"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="mediaobject|mediaobjectco">
+
+ <xsl:variable name="olist" select="imageobject|imageobjectco
+ |videoobject|audioobject
+ |textobject"/>
+
+ <xsl:variable name="object.index">
+ <xsl:call-template name="select.mediaobject.index">
+ <xsl:with-param name="olist" select="$olist"/>
+ <xsl:with-param name="count" select="1"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="object" select="$olist[position() = $object.index]"/>
+
+ <xsl:variable name="align">
+ <xsl:value-of select="$object/descendant::imagedata[@align][1]/@align"/>
+ </xsl:variable>
+
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+
+ <fo:block id="{$id}">
+ <xsl:if test="$align != '' ">
+ <xsl:attribute name="text-align">
+ <xsl:value-of select="$align"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:apply-templates select="$object"/>
+ <xsl:apply-templates select="caption"/>
+ </fo:block>
+ </xsl:template>
+
+ <xsl:template match="inlinemediaobject">
+ <xsl:call-template name="select.mediaobject"/>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="imageobjectco">
+ <xsl:apply-templates select="imageobject"/>
+ <xsl:apply-templates select="calloutlist"/>
+ </xsl:template>
+
+ <xsl:template match="imageobject">
+ <xsl:choose>
+ <xsl:when test="imagedata">
+ <xsl:apply-templates select="imagedata"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <fo:instream-foreign-object>
+ <xsl:apply-templates mode="copy-all"/>
+ </fo:instream-foreign-object>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="*" mode="copy-all">
+ <xsl:copy>
+ <xsl:for-each select="@*">
+ <xsl:copy/>
+ </xsl:for-each>
+ <xsl:apply-templates mode="copy-all"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="text()|comment()|processing-instruction()" mode="copy-all">
+ <xsl:copy/>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="imagedata">
+ <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
+ <xsl:variable name="filename">
+ <xsl:call-template name="mediaobject.filename">
+ <xsl:with-param name="object" select=".."/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
+ <xsl:apply-templates/>
+ </xsl:when>
+
+ <xsl:when test="@format='linespecific'">
+ <xsl:choose>
+ <xsl:when test="$use.extensions != '0'
+ and $textinsert.extension != '0'">
+ <xsl:choose>
+ <xsl:when test="contains($vendor, 'SAXON')">
+ <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
+ </xsl:when>
+ <xsl:when test="contains($vendor, 'Apache Software Foundation')">
+ <xtext:insertfile href="{$filename}"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message terminate="yes">
+ <xsl:text>Don't know how to insert files with </xsl:text>
+ <xsl:value-of select="$vendor"/>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message terminate="yes">
+ <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
+ <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="process.image"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="videoobject">
+ <xsl:apply-templates select="videodata"/>
+ </xsl:template>
+
+ <xsl:template match="videodata">
+ <xsl:call-template name="process.image"/>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="audioobject">
+ <xsl:apply-templates select="audiodata"/>
+ </xsl:template>
+
+ <xsl:template match="audiodata">
+ <xsl:call-template name="process.image"/>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="textobject">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="textdata">
+ <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
+ <xsl:variable name="filename">
+ <xsl:choose>
+ <xsl:when test="@entityref">
+ <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="@fileref"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="encoding">
+ <xsl:choose>
+ <xsl:when test="@encoding">
+ <xsl:value-of select="@encoding"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$textdata.default.encoding"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$use.extensions != '0'
+ and $textinsert.extension != '0'">
+ <xsl:choose>
+ <xsl:when test="element-available('stext:insertfile')">
+ <stext:insertfile href="{$filename}" encoding="{$encoding}"/>
+ </xsl:when>
+ <xsl:when test="element-available('xtext:insertfile')">
+ <xtext:insertfile href="{$filename}"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message terminate="yes">
+ <xsl:text>Don't know how to insert files with </xsl:text>
+ <xsl:value-of select="$vendor"/>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message terminate="yes">
+ <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/>
+ <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template match="caption">
+ <fo:block>
+ <xsl:if test="@align = 'right' or @align = 'left' or @align='center'">
+ <xsl:attribute name="text-align"><xsl:value-of
+ select="@align"/></xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates/>
+ </fo:block>
+ </xsl:template>
+
+ <!-- ==================================================================== -->
+
+ <xsl:template name="fo-external-image">
+ <xsl:param name="filename"/>
+
+ <xsl:choose>
+ <xsl:when test="$passivetex.extensions != 0
+ or $fop.extensions != 0">
+ <xsl:value-of select="$filename"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat('url(', $filename, ')')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- Resolve xml:base attributes -->
+ <xsl:template match="@fileref">
+ <!-- need a check for absolute urls -->
+ <xsl:choose>
+ <xsl:when test="contains(., ':') or starts-with(.,'/')">
+ <!-- it has a uri scheme or starts with '/', so it is an absolute uri -->
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:when test="$keep.relative.image.uris != 0">
+ <!-- leave it alone -->
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- its a relative uri -->
+ <xsl:call-template name="relative-uri">
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ </xsl:stylesheet>
Added: trunk/documentation/xsl/pdf/fo/htmltbl.xsl
==============================================================================
*** trunk/documentation/xsl/pdf/fo/htmltbl.xsl (added)
--- trunk/documentation/xsl/pdf/fo/htmltbl.xsl Sun Jun 20 02:00:40 2010
***************
*** 0 ****
--- 1,425 ----
+ <?xml version="1.0"?>
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ version="1.0">
+
+ <!-- ********************************************************************
+ $Id: htmltbl.xsl 8392 2009-04-01 08:47:55Z bobstayton $
+ ********************************************************************
+
+ This file is part of the XSL DocBook Stylesheet distribution.
+ See ../README or http://docbook.sf.net/release/xsl/current/ for
+ copyright and other information.
+
+ ******************************************************************** -->
+
+ <!-- ==================================================================== -->
+
+ <!-- Outputs an fo:table only, not the caption -->
+ <xsl:template match="table|informaltable" mode="htmlTable">
+
+ <xsl:variable name="numcols">
+ <xsl:call-template name="widest-html-row">
+ <xsl:with-param name="rows" select=".//tr"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="prop-columns"
+ select=".//col[contains(@width, '%')] |
+ .//colgroup[contains(@width, '%')]"/>
+
+ <xsl:variable name="table.width">
+ <xsl:call-template name="table.width"/>
+ </xsl:variable>
+
+ <fo:table xsl:use-attribute-sets="table.table.properties">
+ <xsl:choose>
+ <xsl:when test="$fop.extensions != 0 or
+ $passivetex.extensions != 0">
+ <xsl:attribute name="table-layout">fixed</xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:attribute name="width">
+ <xsl:choose>
+ <xsl:when test="@width">
+ <xsl:value-of select="@width"/>
+ </xsl:when>
+ <xsl:when test="$table.width">
+ <xsl:value-of select="$table.width"/>
+ </xsl:when>
+ <xsl:otherwise>100%</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <xsl:call-template name="table.frame">
+ <xsl:with-param name="frame">
+ <xsl:choose>
+ <xsl:when test="@frame = 'box'">all</xsl:when>
+ <xsl:when test="@frame = 'border'">all</xsl:when>
+ <xsl:when test="@frame = 'below'">bottom</xsl:when>
+ <xsl:when test="@frame = 'above'">top</xsl:when>
+ <xsl:when test="@frame = 'hsides'">topbot</xsl:when>
+ <xsl:when test="@frame = 'vsides'">sides</xsl:when>
+ <xsl:when test="@frame = 'lhs'">lhs</xsl:when>
+ <xsl:when test="@frame = 'rhs'">rhs</xsl:when>
+ <xsl:when test="@frame = 'void'">none</xsl:when>
+ <xsl:when test="@border != '' and @border != 0">all</xsl:when>
+ <xsl:when test="@border != '' and @border = 0">none</xsl:when>
+ <xsl:when test="@frame != ''">
+ <xsl:value-of select="@frame"/>
+ </xsl:when>
+ <xsl:when test="$default.table.frame != ''">
+ <xsl:value-of select="$default.table.frame"/>
+ </xsl:when>
+ <xsl:otherwise>all</xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:call-template name="make-html-table-columns">
+ <xsl:with-param name="count" select="$numcols"/>
+ </xsl:call-template>
+
+ <xsl:apply-templates select="thead" mode="htmlTable"/>
+ <xsl:apply-templates select="tfoot" mode="htmlTable"/>
+ <xsl:choose>
+ <xsl:when test="tbody">
+ <xsl:apply-templates select="tbody" mode="htmlTable"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <fo:table-body start-indent="0pt" end-indent="0pt">
+ <xsl:apply-templates select="tr" mode="htmlTable"/>
+ </fo:table-body>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:table>
+
+ </xsl:template>
+
+ <!-- This template writes rowsep or colsep equivalant for html tables -->
+ <xsl:template name="html.table.cell.rules">
+ <xsl:variable name="border"
+ select="(ancestor::table |
+ ancestor::informaltable)[last()]/@border"/>
+ <xsl:variable name="table.rules"
+ select="(ancestor::table |
+ ancestor::informaltable)[last()]/@rules"/>
+
+ <xsl:variable name="rules">
+ <xsl:choose>
+ <xsl:when test="$table.rules != ''">
+ <xsl:value-of select="$table.rules"/>
+ </xsl:when>
+ <xsl:when test="$default.table.rules != ''">
+ <xsl:value-of select="$default.table.rules"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$border != '' and $border != 0">
+ <xsl:attribute name="border">
+ <xsl:value-of select="$table.cell.border.thickness"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$table.cell.border.style"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$table.cell.border.color"/>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="$rules = 'none'">
+ <xsl:attribute name="border-start-style">none</xsl:attribute>
+ <xsl:attribute name="border-end-style">none</xsl:attribute>
+ <xsl:attribute name="border-top-style">none</xsl:attribute>
+ <xsl:attribute name="border-bottom-style">none</xsl:attribute>
+ </xsl:when>
+
+ <xsl:when test="$rules = 'cols' and following-sibling::*">
+ <!-- If not the last column, add border after -->
+ <xsl:attribute name="border-start-style">none</xsl:attribute>
+ <xsl:attribute name="border-top-style">none</xsl:attribute>
+ <xsl:attribute name="border-bottom-style">none</xsl:attribute>
+ <xsl:attribute name="border-end-style">
+ <xsl:value-of select="$table.frame.border.style"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-end-width">
+ <xsl:value-of select="$table.frame.border.thickness"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-end-color">
+ <xsl:value-of select="$table.frame.border.color"/>
+ </xsl:attribute>
+ </xsl:when>
+ <!-- If not the last row, add border below -->
+ <xsl:when test="$rules = 'rows'">
+ <xsl:variable name="rowborder">
+ <xsl:choose>
+ <!-- If in thead and tbody has rows, add border -->
+ <xsl:when test="parent::tr/parent::thead/
+ following-sibling::tbody/tr">1</xsl:when>
+ <!-- If in tbody and tfoot has rows, add border -->
+ <xsl:when test="parent::tr/parent::tbody/
+ following-sibling::tfoot/tr">1</xsl:when>
+ <xsl:when test="parent::tr/parent::tbody/
+ preceding-sibling::tfoot/tr">1</xsl:when>
+ <!-- If following rows, but not rowspan reaches last row -->
+ <xsl:when test="parent::tr/following-sibling::tr and
+ not(@rowspan = count(parent::tr/following-sibling::tr) + 1)">1</xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:if test="$rowborder = 1">
+ <xsl:attribute name="border-start-style">none</xsl:attribute>
+ <xsl:attribute name="border-end-style">none</xsl:attribute>
+ <xsl:attribute name="border-top-style">none</xsl:attribute>
+ <xsl:attribute name="border-bottom-style">
+ <xsl:value-of select="$table.frame.border.style"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-bottom-width">
+ <xsl:value-of select="$table.frame.border.thickness"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-bottom-color">
+ <xsl:value-of select="$table.frame.border.color"/>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:when>
+ <xsl:when test="$rules = 'all'">
+ <xsl:attribute name="border-start-style">none</xsl:attribute>
+ <xsl:attribute name="border-top-style">none</xsl:attribute>
+
+ <xsl:variable name="rowborder">
+ <xsl:choose>
+ <!-- If in thead and tbody has rows, add border -->
+ <xsl:when test="parent::tr/parent::thead/
+ following-sibling::tbody/tr">1</xsl:when>
+ <!-- If in tbody and tfoot has rows, add border -->
+ <xsl:when test="parent::tr/parent::tbody/
+ following-sibling::tfoot/tr">1</xsl:when>
+ <xsl:when test="parent::tr/parent::tbody/
+ preceding-sibling::tfoot/tr">1</xsl:when>
+ <!-- If following rows, but not rowspan reaches last row -->
+ <xsl:when test="parent::tr/following-sibling::tr and
+ not(@rowspan = count(parent::tr/following-sibling::tr) + 1)">1</xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:if test="$rowborder = 1">
+ <xsl:attribute name="border-bottom-style">
+ <xsl:value-of select="$table.frame.border.style"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-bottom-width">
+ <xsl:value-of select="$table.frame.border.thickness"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-bottom-color">
+ <xsl:value-of select="$table.frame.border.color"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="following-sibling::*">
+ <!-- If not the last column, add border after -->
+ <xsl:attribute name="border-end-style">
+ <xsl:value-of select="$table.frame.border.style"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-end-width">
+ <xsl:value-of select="$table.frame.border.thickness"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-end-color">
+ <xsl:value-of select="$table.frame.border.color"/>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:when>
+ <xsl:when test="$rules = 'groups' and ancestor::thead
+ and not(parent::tr/following-sibling::tr)">
+ <xsl:attribute name="border-start-style">none</xsl:attribute>
+ <xsl:attribute name="border-end-style">none</xsl:attribute>
+ <xsl:attribute name="border-top-style">none</xsl:attribute>
+ <xsl:attribute name="border-bottom-style">
+ <xsl:value-of select="$table.frame.border.style"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-bottom-width">
+ <xsl:value-of select="$table.frame.border.thickness"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-bottom-color">
+ <xsl:value-of select="$table.frame.border.color"/>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="$rules = 'groups' and ancestor::tfoot
+ and not(parent::tr/preceding-sibling::tr)">
+ <xsl:attribute name="border-start-style">none</xsl:attribute>
+ <xsl:attribute name="border-end-style">none</xsl:attribute>
+ <xsl:attribute name="border-top-style">none</xsl:attribute>
+ <xsl:attribute name="border-top-style">
+ <xsl:value-of select="$table.frame.border.style"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-top-width">
+ <xsl:value-of select="$table.frame.border.thickness"/>
+ </xsl:attribute>
+ <xsl:attribute name="border-top-color">
+ <xsl:value-of select="$table.frame.border.color"/>
+ </xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="caption" mode="htmlTable">
+ <!-- Handled by formal.object.heading -->
+ </xsl:template>
+
+ <xsl:template name="widest-html-row">
+ <xsl:param name="rows" select="''"/>
+ <xsl:param name="count" select="0"/>
+ <xsl:choose>
+ <xsl:when test="count($rows) = 0">
+ <xsl:value-of select="$count"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$count > count($rows[1]/*)">
+ <xsl:call-template name="widest-html-row">
+ <xsl:with-param name="rows" select="$rows[position() > 1]"/>
+ <xsl:with-param name="count" select="$count"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="widest-html-row">
+ <xsl:with-param name="rows" select="$rows[position() > 1]"/>
+ <xsl:with-param name="count" select="count($rows[1]/*)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="make-html-table-columns">
+ <xsl:param name="count" select="0"/>
+ <xsl:param name="number" select="1"/>
+
+ <xsl:choose>
+ <xsl:when test="col|colgroup/col">
+ <xsl:for-each select="col|colgroup/col">
+ <fo:table-column>
+ <xsl:attribute name="column-number">
+ <xsl:number from="table|informaltable" level="any" format="1"/>
+ </xsl:attribute>
+ <xsl:if test="@width">
+ <xsl:attribute name="column-width">
+ <xsl:choose>
+ <xsl:when test="$fop.extensions != 0 and
+ contains(@width, '%')">
+ <xsl:value-of select="concat('proportional-column-width(',
+ substring-before(@width, '%'),
+ ')')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@width"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ </fo:table-column>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:when test="$fop.extensions != 0">
+ <xsl:if test="$number <= $count">
+ <fo:table-column column-number="{$number}"
+ column-width="{6.5 div $count}in"/>
+ <xsl:call-template name="make-html-table-columns">
+ <xsl:with-param name="count" select="$count"/>
+ <xsl:with-param name="number" select="$number + 1"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="tbody" mode="htmlTable">
+ <fo:table-body start-indent="0pt"
+ end-indent="0pt">
+ <xsl:apply-templates mode="htmlTable"/>
+ </fo:table-body>
+ </xsl:template>
+
+ <xsl:template match="tfoot" mode="htmlTable">
+ <fo:table-footer start-indent="0pt"
+ end-indent="0pt">
+ <xsl:apply-templates mode="htmlTable"/>
+ </fo:table-footer>
+ </xsl:template>
+
+ <xsl:template match="th|td" mode="htmlTable">
+ <xsl:variable name="bgcolor.pi">
+ <xsl:call-template name="pi.dbfo_bgcolor"/>
+ </xsl:variable>
+
+ <xsl:variable name="bgcolor">
+ <xsl:choose>
+ <xsl:when test="$bgcolor.pi != ''">
+ <xsl:value-of select="$bgcolor.pi"/>
+ </xsl:when>
+ <xsl:when test="string-length(@bgcolor) != 0">
+ <xsl:value-of select="@bgcolor"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="align">
+ <xsl:call-template name="inherited.table.attribute">
+ <xsl:with-param name="entry" select="."/>
+ <xsl:with-param name="row" select="parent::tr"/>
+ <xsl:with-param name="attribute" select="'align'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="valign">
+ <xsl:call-template name="inherited.table.attribute">
+ <xsl:with-param name="entry" select="."/>
+ <xsl:with-param name="row" select="parent::tr"/>
+ <xsl:with-param name="attribute" select="'valign'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <fo:table-cell xsl:use-attribute-sets="table.cell.padding">
+ <xsl:call-template name="table.cell.properties">
+ <xsl:with-param name="bgcolor.pi" select="$bgcolor"/>
+ <xsl:with-param name="rowsep.inherit" select="0"/>
+ <xsl:with-param name="align.inherit" select="$align"/>
+ <xsl:with-param name="valign.inherit" select="$valign"/>
+ <xsl:with-param name="colsep.inherit" select="0"/>
+ </xsl:call-template>
+
+ <xsl:if test="@colspan > 1">
+ <xsl:attribute name="number-columns-spanned">
+ <xsl:value-of select="@colspan"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="@rowspan > 1">
+ <xsl:attribute name="number-rows-spanned">
+ <xsl:value-of select="@rowspan"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <fo:block>
+ <xsl:call-template name="table.cell.block.properties"/>
+ <xsl:apply-templates/>
+ </fo:block>
+ </fo:table-cell>
+ </xsl:template>
+
+ <xsl:template match="thead" mode="htmlTable">
+ <fo:table-header start-indent="0pt"
+ end-indent="0pt">
+ <xsl:apply-templates mode="htmlTable"/>
+ </fo:table-header>
+ </xsl:template>
+
+ <xsl:template match="tr" mode="htmlTable">
+ <fo:table-row>
+ <xsl:call-template name="table.row.properties"/>
+ <xsl:apply-templates mode="htmlTable"/>
+ </fo:table-row>
+ </xsl:template>
+
+ </xsl:stylesheet>
More information about the documentation-commits
mailing list