--- /dev/null
+<?xml version='1.0' encoding='ISO-8859-1'?>\r
+\r
+<!-- =============================================================== -->\r
+<!-- -->\r
+<!-- Convert XSL FO (as in REC 2001-10-15) to HTML -->\r
+<!-- -->\r
+<!-- © RenderX 2000-2001 -->\r
+<!-- Permission to copy and modify is granted, provided this notice -->\r
+<!-- is included in all copies and/or derived work. -->\r
+<!-- -->\r
+<!-- Author: Nikolai Grigoriev, grig@renderx.com -->\r
+<!-- -->\r
+<!-- =============================================================== -->\r
+\r
+\r
+<!DOCTYPE xsl:stylesheet [\r
+ <!ENTITY anchor "<xsl:apply-templates select='@id' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'/>">\r
+ <!ENTITY add-style "<xsl:call-template name='add-style-attribute' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'/>">\r
+]>\r
+\r
+<xsl:stylesheet version="1.0"\r
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"\r
+ exclude-result-prefixes="fo">\r
+\r
+<xsl:output method="html"\r
+ version="4.0"\r
+ encoding="utf-8"\r
+ doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"\r
+ indent="no"/>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Root. Create the bone and call templates for each page sequence -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:root">\r
+ <html>\r
+ <head>\r
+ <title>\r
+ <xsl:choose>\r
+ <xsl:when test="descendant::fo:title[1]">\r
+ <xsl:value-of select="descendant::fo:title[1]"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>XSL FO Document</xsl:otherwise>\r
+ </xsl:choose>\r
+ </title>\r
+ <META http-equiv="Content-Style-Type" content="text/css"/>\r
+ <style type="text/css">\r
+ a { color: black; border: none; text-decoration: none; }\r
+ img { border: none; }\r
+ </style>\r
+ </head>\r
+\r
+ <body bgcolor="white" marginwidth="6" marginheight="6" leftmargin="6" topmargin="6">\r
+ <xsl:apply-templates select="fo:page-sequence"/>\r
+ </body>\r
+ </html>\r
+\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:page-sequence. Draws a header before and a footer after. -->\r
+<!-- Sidebars are skipped: there's no way to rotate the text in HTML -->\r
+<!-- and horizontal text in the sidebars eats up too much space. -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:page-sequence">\r
+\r
+ <xsl:variable name="current-master"><xsl:value-of select="@master-reference"/></xsl:variable>\r
+\r
+ <!-- One page master will be used for the whole page sequence -->\r
+ <xsl:variable name="page-master-name">\r
+ <xsl:choose>\r
+ <xsl:when test="../fo:layout-master-set/fo:simple-page-master[@master-name=$current-master]">\r
+ <!-- specified master is a page master: use it -->\r
+ <xsl:value-of select="$current-master"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <!-- specified master is a page sequence master: -->\r
+ <!-- find master name for the first page -->\r
+ <xsl:apply-templates select="../fo:layout-master-set/fo:page-sequence-master[@master-name=$current-master]"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:variable>\r
+\r
+ <!-- Load the page master into a variable. No problem if it's null; should work the same ;-) -->\r
+ <xsl:variable name="page-master" select="../fo:layout-master-set/fo:simple-page-master[@master-name=$page-master-name]"/>\r
+\r
+\r
+ <!-- Start real drawing -->\r
+ <br/> <!-- make an offset before each page sequence -->\r
+\r
+ <!-- Header -->\r
+ <xsl:variable name="header-region" select="$page-master/fo:region-before"/>\r
+ <xsl:apply-templates select="fo:static-content[@flow-name = $header-region/@region-name\r
+ or (@flow-name='xsl-region-before' and not($header-region/@region-name))]">\r
+ <xsl:with-param name="region" select="$header-region"/>\r
+ </xsl:apply-templates>\r
+\r
+ <!-- Body -->\r
+ <xsl:apply-templates select="fo:flow">\r
+ <xsl:with-param name="region" select="$page-master/fo:region-body"/>\r
+ </xsl:apply-templates>\r
+\r
+ <!-- Footer -->\r
+ <xsl:variable name="footer-region" select="$page-master/fo:region-after"/>\r
+ <xsl:apply-templates select="fo:static-content[@flow-name = $footer-region/@region-name\r
+ or (@flow-name='xsl-region-after' and not($footer-region/@region-name))]">\r
+ <xsl:with-param name="region" select="$footer-region"/>\r
+ </xsl:apply-templates>\r
+\r
+ <br/> <!-- make an offset after each page sequence -->\r
+\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:block -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:block">\r
+ &anchor;<div>&add-style;<xsl:apply-templates mode="check-for-pre"/></div>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:inline-sequence -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:inline | fo:wrapper">\r
+ &anchor;<span>&add-style;<xsl:apply-templates/></span>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:list-block -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:list-block">\r
+ <xsl:variable name="label-separation">\r
+ <xsl:choose>\r
+ <xsl:when test="@provisional-label-separation">\r
+ <xsl:apply-templates select="@provisional-label-separation"\r
+ mode="convert-to-pixels"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>8</xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:variable>\r
+\r
+ <xsl:variable name="body-offset">\r
+ <xsl:choose>\r
+ <xsl:when test="@provisional-distance-between-starts">\r
+ <xsl:apply-templates select="@provisional-distance-between-starts"\r
+ mode="convert-to-pixels"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>32</xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:variable>\r
+\r
+ <div>&add-style;\r
+ &anchor;\r
+ <table width="100%">\r
+ <xsl:apply-templates select="fo:list-item | fo:list-item-label">\r
+ <xsl:with-param name="label-width"\r
+ select="$body-offset - $label-separation"/>\r
+ <xsl:with-param name="gap-width"\r
+ select="$label-separation"/>\r
+ </xsl:apply-templates>\r
+ </table>\r
+ </div>\r
+\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:list-item -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:list-item">\r
+ <xsl:param name="label-width"/>\r
+ <xsl:param name="gap-width"/>\r
+\r
+ <tr>&add-style;\r
+ <xsl:apply-templates select="fo:list-item-label" mode="draw-cell">\r
+ <xsl:with-param name="width" select="$label-width"/>\r
+ </xsl:apply-templates>\r
+ <xsl:if test="$gap-width > 0">\r
+ <td width="{$gap-width}"> </td>\r
+ </xsl:if>\r
+\r
+ <xsl:apply-templates select="fo:list-item-body" mode="draw-cell"/>\r
+ </tr>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:list-item-label - itemless lists -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:list-block/fo:list-item-label">\r
+ <xsl:param name="label-width"/>\r
+ <xsl:param name="gap-width"/>\r
+\r
+ <tr>\r
+ <xsl:apply-templates select="." mode="draw-cell">\r
+ <xsl:with-param name="width" select="$label-width"/>\r
+ </xsl:apply-templates>\r
+ <xsl:if test="$gap-width > 0">\r
+ <td width="{$gap-width}"> </td>\r
+ </xsl:if>\r
+\r
+ <xsl:apply-templates select="following-sibling::fo:list-item-body[1]" mode="draw-cell"/>\r
+ </tr>\r
+</xsl:template>\r
+\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:list-item-body - itemless lists -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:list-item-label | fo:list-item-body" mode="draw-cell">\r
+ <xsl:param name="width" select="'auto'"/>\r
+ <td valign="top">&add-style;&anchor;\r
+ <xsl:if test="$width != 'auto'">\r
+ <xsl:attribute name="width">\r
+ <xsl:value-of select="$width"/>\r
+ </xsl:attribute>\r
+ </xsl:if>\r
+\r
+ <xsl:apply-templates mode="check-for-pre"/>\r
+ </td>\r
+</xsl:template>\r
+\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:table and its components -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:table">\r
+ &anchor;\r
+ <table>&add-style;\r
+ <xsl:if test="not(@display-align)">\r
+ <xsl:attribute name="valign">top</xsl:attribute>\r
+ </xsl:if>\r
+\r
+ <xsl:apply-templates/>\r
+ </table>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:table-header">\r
+ <thead>&add-style;\r
+ <xsl:apply-templates/>\r
+ </thead>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:table-footer">\r
+ <tfoot>&add-style;\r
+ <xsl:apply-templates/>\r
+ </tfoot>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:table-body">\r
+ <tbody>&add-style;\r
+ <xsl:apply-templates/>\r
+ </tbody>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:table-row">\r
+ <tr>&add-style;\r
+ <xsl:apply-templates mode="display"/>\r
+ </tr>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:table-cell" mode="display">\r
+ <td>&add-style;\r
+ <xsl:if test="not(@display-align)">\r
+ <xsl:attribute name="valign">top</xsl:attribute>\r
+ </xsl:if>\r
+ <xsl:apply-templates select="@*" mode="get-table-attributes"/>\r
+ <xsl:apply-templates mode="check-for-pre"/>\r
+ </td>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:table-cell" priority="-1"/>\r
+\r
+<!-- This template accounts for "rowless" tables -->\r
+<xsl:template priority="1"\r
+ match="fo:table-cell[not(parent::fo:table-row)]\r
+ [not(preceding-sibling::fo:table-cell) or @starts-row='true'\r
+ or preceding-sibling::fo:table-cell[1][@ends-row='true']]">\r
+ <tr>\r
+ <xsl:call-template name="enumerate-rowless-cells"/>\r
+ </tr>\r
+</xsl:template>\r
+\r
+<xsl:template name="enumerate-rowless-cells">\r
+ <xsl:apply-templates select="." mode="display"/>\r
+ <xsl:if test="not(@ends-row='true')">\r
+ <xsl:for-each select="following-sibling::fo:table-cell[1]\r
+ [not(@starts-row='true')]">\r
+ <xsl:call-template name="enumerate-rowless-cells"/>\r
+ </xsl:for-each>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:inline-graphic -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:external-graphic">\r
+ <xsl:variable name="cleaned-url">\r
+ <xsl:apply-templates select="@src" mode="unbracket-url"/>\r
+ </xsl:variable>\r
+ &anchor;<img src="{$cleaned-url}"><xsl:apply-templates select="@height|@width|@*[starts-with(name(),'border')]"/></img>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:basic-link -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:basic-link[@external-destination]">\r
+\r
+ <xsl:variable name="cleaned-url">\r
+ <xsl:apply-templates select="@external-destination" mode="unbracket-url"/>\r
+ </xsl:variable>\r
+\r
+ &anchor;<a href="{$cleaned-url}">&add-style;<xsl:apply-templates/></a>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:basic-link[@internal-destination]">\r
+ \r
+ <xsl:variable name="citation-id" select="@internal-destination"/>\r
+\r
+ &anchor;<a href="#{$citation-id}">&add-style;<xsl:apply-templates/></a>\r
+</xsl:template>\r
+\r
+\r
+<!-- =============================================================== -->\r
+<!-- fo:marker/fo:retrieve-marker -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:marker"/>\r
+<xsl:template match="fo:marker" mode="retrieve-marker">\r
+ <xsl:apply-templates/>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:retrieve-marker">\r
+\r
+ <xsl:variable name="class-name" select="@retrieve-class-name"/>\r
+ <xsl:variable name="matching-markers"\r
+ select="ancestor::fo:page-sequence/descendant::fo:marker[@marker-class-name=$class-name]"/>\r
+\r
+ <xsl:choose>\r
+ <xsl:when test="@retrieve-position='last-starting-within-page'\r
+ or @retrieve-position='last-ending-within-page'">\r
+ <xsl:apply-templates select="$matching-markers[position()=last()]" mode="retrieve-marker"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:apply-templates select="$matching-markers[1]" mode="retrieve-marker"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+\r
+</xsl:template>\r
+\r
+\r
+\r
+\r
+\r
+<!-- *************************************************************** -->\r
+<!-- Treatment of attributes that are either identical to their CSS1 -->\r
+<!-- counterparts, of find an equivalent expression there -->\r
+\r
+<!-- =============================================================== -->\r
+<!-- Default rule: copy CSS1 attributes and suppress all other -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="@*" priority="-2" mode="collect-style-attributes"/>\r
+\r
+<xsl:template match="@color |\r
+ @background |\r
+ @background-color |\r
+ @background-image |\r
+ @background-position |\r
+ @background-repeat |\r
+ @padding |\r
+ @padding-top |\r
+ @padding-bottom |\r
+ @padding-right |\r
+ @padding-left |\r
+ @margin |\r
+ @margin-top |\r
+ @margin-bottom |\r
+ @margin-right |\r
+ @margin-left |\r
+ @border |\r
+ @border-top |\r
+ @border-bottom |\r
+ @border-right |\r
+ @border-left |\r
+ @border-width |\r
+ @border-top-width |\r
+ @border-bottom-width |\r
+ @border-right-width |\r
+ @border-left-width |\r
+ @border-color |\r
+ @border-top-color |\r
+ @border-bottom-color |\r
+ @border-right-color |\r
+ @border-left-color |\r
+ @border-style |\r
+ @border-top-style |\r
+ @border-bottom-style |\r
+ @border-right-style |\r
+ @border-left-style |\r
+ @letter-spacing |\r
+ @word-spacing |\r
+ @line-height |\r
+ @font |\r
+ @font-family |\r
+ @font-size |\r
+ @font-weight |\r
+ @font-style |\r
+ @font-variant |\r
+ @vertical-align |\r
+ @text-decoration |\r
+ @text-indent |\r
+ @text-transform"\r
+ mode="collect-style-attributes">\r
+ <xsl:value-of select="name()"/>\r
+ <xsl:text>: </xsl:text>\r
+ <xsl:value-of select="."/>\r
+ <xsl:text>; </xsl:text>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Some attributes deserve special treatment -->\r
+\r
+<xsl:template match="@text-align" mode="collect-style-attributes">\r
+ <xsl:text>text-align: </xsl:text>\r
+ <xsl:choose>\r
+ <xsl:when test=".='start' or .='inside'">left</xsl:when>\r
+ <xsl:when test=".='end' or .='outside'">right</xsl:when>\r
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:text>; </xsl:text>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Handling writing-mode in borders, padding, and margins -->\r
+<!-- This version presumes lr-tb writing mode only. -->\r
+\r
+<xsl:template match="@space-before.optimum |\r
+ @space-before [not (../@space-before.optimum)] |\r
+ @space-before.minimum [not (../@space-before.optimum) and not (../@space-before)] |\r
+ @space-before.maximum [not (../@space-before.optimum) and not (../@space-before) and not (../@space-before.minimum)] |\r
+ @space-after.optimum |\r
+ @space-after [not (../@space-after.optimum)] |\r
+ @space-after.minimum [not (../@space-after.optimum) and not (../@space-after)] |\r
+ @space-after.maximum [not (../@space-after.optimum) and not (../@space-after) and not (../@space-after.minimum)] |\r
+ @space-start.optimum |\r
+ @space-start [not (../@space-start.optimum)] |\r
+ @space-start.minimum [not (../@space-start.optimum) and not (../@space-start)] |\r
+ @space-start.maximum [not (../@space-start.optimum) and not (../@space-start) and not (../@space-start.minimum)] |\r
+ @space-end.optimum |\r
+ @space-end [not (../@space-end.optimum)] |\r
+ @space-end.minimum [not (../@space-end.optimum) and not (../@space-end)] |\r
+ @space-end.maximum [not (../@space-end.optimum) and not (../@space-end) and not (../@space-end.minimum)] |\r
+ @start-indent[not(parent::fo:list-item-body)] |\r
+ @end-indent[not(parent::fo:list-item-label)] |\r
+ @padding-before |\r
+ @padding-before.length |\r
+ @margin-before |\r
+ @border-before |\r
+ @border-before-width |\r
+ @border-before-width.length |\r
+ @border-before-color |\r
+ @border-before-style |\r
+ @padding-after |\r
+ @padding-after.length |\r
+ @margin-after |\r
+ @border-after |\r
+ @border-after-width |\r
+ @border-after-width.length |\r
+ @border-after-color |\r
+ @border-after-style |\r
+ @padding-start |\r
+ @padding-start.length |\r
+ @margin-start |\r
+ @border-start |\r
+ @border-start-width |\r
+ @border-start-width.length |\r
+ @border-start-color |\r
+ @border-start-style |\r
+ @padding-end |\r
+ @padding-end.length |\r
+ @margin-end |\r
+ @border-end |\r
+ @border-end-width |\r
+ @border-end-width.length |\r
+ @border-end-color |\r
+ @border-end-style"\r
+ mode="collect-style-attributes">\r
+\r
+ <xsl:variable name="property">\r
+ <xsl:choose>\r
+ <xsl:when test="starts-with(name(), 'border')">border</xsl:when>\r
+ <xsl:when test="starts-with(name(), 'padding')">padding</xsl:when>\r
+ <xsl:when test="starts-with(name(), 'margin')">margin</xsl:when>\r
+ <xsl:when test="starts-with(name(), 'space')">margin</xsl:when>\r
+ <xsl:when test="contains(name(), '-indent')">margin</xsl:when>\r
+ </xsl:choose>\r
+ </xsl:variable>\r
+\r
+ <xsl:variable name="side">\r
+ <xsl:choose>\r
+ <xsl:when test="contains(name(), '-before') or contains(name(), '-top')">-top</xsl:when>\r
+ <xsl:when test="contains(name(), '-after') or contains(name(), '-bottom')">-bottom</xsl:when>\r
+ <xsl:when test="contains(name(), '-start') or starts-with(name(), 'start-') or contains(name(), '-left')">-left</xsl:when>\r
+ <xsl:when test="contains(name(), '-end') or starts-with(name(), 'end-') or contains(name(), '-right')">-right</xsl:when>\r
+ </xsl:choose>\r
+ </xsl:variable>\r
+\r
+ <xsl:variable name="parameter">\r
+ <xsl:choose>\r
+ <xsl:when test="contains(name(), '-width')">-width</xsl:when>\r
+ <xsl:when test="contains(name(), '-color')">-color</xsl:when>\r
+ <xsl:when test="contains(name(), '-style')">-style</xsl:when>\r
+ </xsl:choose>\r
+ </xsl:variable>\r
+\r
+ <xsl:value-of select="concat($property, $side, $parameter)"/>\r
+ <xsl:text>: </xsl:text>\r
+ <xsl:value-of select="."/>\r
+ <xsl:text>; </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="*" mode="check-for-pre" priority="-1">\r
+ <xsl:apply-templates select="."/>\r
+</xsl:template>\r
+\r
+<xsl:template match="*[@white-space-collapse='false'\r
+ or @linefeed-treatment='preserve'\r
+ or @wrap-option='no-wrap'\r
+ or @white-space='pre']"\r
+ mode="check-for-pre">\r
+ <pre><xsl:apply-templates select="."/></pre>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Recalculate a length to pixels. 1 in = 96 px, 1 em = 1 pc; -->\r
+<!-- this gives reasonable results for 800x600 and 1024x768 screens -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="@*" mode="convert-to-pixels">\r
+ <xsl:variable name="scaling-factor">\r
+ <xsl:choose>\r
+ <xsl:when test="contains (., 'pt')">1.33</xsl:when>\r
+ <xsl:when test="contains (., 'px')">1</xsl:when>\r
+ <xsl:when test="contains (., 'pc')">16</xsl:when>\r
+ <xsl:when test="contains (., 'in')">96</xsl:when>\r
+ <xsl:when test="contains (., 'cm')">37.8</xsl:when>\r
+ <xsl:when test="contains (., 'mm')">3.78</xsl:when>\r
+ <xsl:when test="contains (., 'em')">16</xsl:when> <!-- guess: 1em = 12pt -->\r
+ <xsl:otherwise>1</xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:variable>\r
+\r
+ <xsl:variable name="numeric-value"\r
+ select="translate (., '-0123456789.ptxcinme', '-0123456789.')"/>\r
+ <xsl:value-of select="$numeric-value * $scaling-factor"/>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Remove brackets & quotes around URLs -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="@*" mode="unbracket-url">\r
+ <xsl:variable name="href" select="normalize-space(.)"/>\r
+\r
+ <xsl:choose>\r
+ <xsl:when test="(starts-with($href, 'url(') or starts-with($href, 'url ('))\r
+ and substring ($href, string-length($href)) = ')'">\r
+ <!-- Remove 'url' from the beginning -->\r
+ <xsl:variable name="bracketed"\r
+ select="normalize-space(substring($href, 4))"/>\r
+ <!-- Remove brackets -->\r
+ <xsl:variable name="quoted"\r
+ select="normalize-space(substring($bracketed, 2, string-length ($bracketed) - 2 ))"/>\r
+\r
+ <xsl:variable name="q" select="'"'"/>\r
+ <xsl:variable name="a" select='"'"'/>\r
+ <!-- Remove optional quotes -->\r
+ <xsl:choose>\r
+ <xsl:when test="( substring($quoted, 1, 1) = $q and\r
+ substring($quoted, string-length($quoted), 1) = $q )\r
+ or ( substring($quoted, 1, 1) = $a and\r
+ substring($quoted, string-length($quoted), 1) = $a )">\r
+ <xsl:value-of select="substring($quoted, 2, string-length($quoted) - 2)"/>\r
+ </xsl:when>\r
+ <xsl:otherwise><xsl:value-of select="$quoted"/></xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:when>\r
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Page number - replace by a bullet -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:page-number | fo:page-number-citation">\r
+ <span>&add-style;<xsl:text>•</xsl:text></span>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Leader - replace by a space -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:leader">\r
+ <xsl:text>     </xsl:text>\r
+</xsl:template>\r
+\r
+\r
+\r
+<!-- =============================================================== -->\r
+<!-- Static content - add a <hr/> before or after it -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:flow | fo:static-content">\r
+ <xsl:param name="region"/>\r
+\r
+ <div>&add-style;&anchor;\r
+ <xsl:apply-templates select="$region"/>\r
+ <xsl:apply-templates/>\r
+ <xsl:if test=".//fo:footnote">\r
+ <br/><hr/>\r
+ <xsl:apply-templates select=".//fo:footnote" mode="after-text"/>\r
+ </xsl:if>\r
+ </div>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Footnotes -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:footnote">\r
+ <xsl:apply-templates select="fo:inline"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:footnote" mode="after-text">\r
+ <div>&add-style;&anchor;\r
+ <xsl:apply-templates select="fo:footnote-body"/>\r
+ </div>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Copy all CSS1-compatible attributes to "style" property -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template name="add-style-attribute">\r
+ <xsl:param name="orientation" select="0"/>\r
+ <xsl:variable name="style">\r
+ <xsl:apply-templates select="@*" mode="collect-style-attributes"/>\r
+ </xsl:variable>\r
+\r
+ <xsl:if test="string-length($style) > 0">\r
+ <xsl:attribute name="style"><xsl:value-of select="normalize-space($style)"/></xsl:attribute>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Create an anchor -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="@id"><a name="{.}"/></xsl:template>\r
+\r
+<!-- =============================================================== -->\r
+<!-- Table cell geometry -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="@*" mode="get-table-attributes" priority="-1"/>\r
+\r
+<xsl:template match="@number-columns-spanned"\r
+ mode="get-table-attributes">\r
+ <xsl:attribute name="colspan"><xsl:value-of select="."/></xsl:attribute>\r
+</xsl:template>\r
+\r
+<xsl:template match="@number-rows-spanned"\r
+ mode="get-table-attributes">\r
+ <xsl:attribute name="rowspan"><xsl:value-of select="."/></xsl:attribute>\r
+</xsl:template>\r
+\r
+\r
+\r
+<!-- =============================================================== -->\r
+<!-- Page layout: determine master name for the first page -->\r
+<!-- =============================================================== -->\r
+\r
+<xsl:template match="fo:page-sequence-master">\r
+ <xsl:apply-templates select="*[1]"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:single-page-master-reference\r
+ | fo:repeatable-page-master-reference">\r
+ <xsl:value-of select="@master-reference"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:repeatable-page-master-alternatives">\r
+ <xsl:choose>\r
+ <xsl:when test="fo:conditional-page-master-reference[@page-position='first']">\r
+ <xsl:value-of select="fo:conditional-page-master-reference[@page-position='first'][1]/@master-reference"/>\r
+ </xsl:when>\r
+ <xsl:when test="fo:conditional-page-master-reference[@odd-or-even='odd' and not (@blank-or-not-blank='blank')]">\r
+ <xsl:value-of select="fo:conditional-page-master-reference[@odd-or-even='odd' and not (@blank-or-not-blank='blank')][1]/@master-reference"/>\r
+ </xsl:when>\r
+ <xsl:when test="fo:conditional-page-master-reference[not(@odd-or-even='even') and not (@blank-or-not-blank='blank')]">\r
+ <xsl:value-of select="fo:conditional-page-master-reference[not(@odd-or-even='even') and not (@blank-or-not-blank='blank')][1]/@master-reference"/>\r
+ </xsl:when>\r
+ <xsl:otherwise> <!-- cannot guess; take the first -->\r
+ <xsl:value-of select="fo:conditional-page-master-reference[1]/@master-reference"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+\r
+<!-- =============================================================== -->\r
+<!-- Header/footer properties -->\r
+<!-- =============================================================== -->\r
+\r
+\r
+<xsl:template match="@extent">\r
+ <xsl:attribute name="width"><xsl:apply-templates select="." mode="convert-to-pixels"/></xsl:attribute>\r
+</xsl:template>\r
+\r
+<xsl:template match="@width | @height">\r
+ <xsl:attribute name="{name()}"><xsl:apply-templates select="." mode="convert-to-pixels"/></xsl:attribute>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:region-before | fo:region-after">\r
+ <xsl:call-template name="get-area-attributes"/>\r
+\r
+ <!-- For header and footer, we suppress margins and padding -->\r
+ <xsl:variable name="style">\r
+ <xsl:apply-templates\r
+ select="@*[not (starts-with (name(), 'margin')\r
+ or starts-with (name(), 'space')\r
+ or starts-with (name(), 'padding'))]"\r
+ mode="collect-style-attributes">\r
+ <xsl:with-param name="orientation" select="@reference-orientation"/>\r
+ </xsl:apply-templates>\r
+ </xsl:variable>\r
+\r
+ <xsl:if test="string-length($style) > 0">\r
+ <xsl:attribute name="style"><xsl:value-of select="normalize-space($style)"/></xsl:attribute>\r
+ </xsl:if>\r
+\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:region-body">\r
+ <xsl:call-template name="get-area-attributes"/>\r
+\r
+ <!-- For region-body, we suppress margin attributes -->\r
+ <xsl:variable name="style">\r
+ <xsl:apply-templates\r
+ select="@*[not (starts-with (name(), 'margin')\r
+ or starts-with (name(), 'space'))]"\r
+ mode="collect-style-attributes">\r
+ <xsl:with-param name="orientation" select="@reference-orientation"/>\r
+ </xsl:apply-templates>\r
+ </xsl:variable>\r
+\r
+ <xsl:if test="string-length($style) > 0">\r
+ <xsl:attribute name="style"><xsl:value-of select="normalize-space($style)"/></xsl:attribute>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="fo:region-start | fo:region-end"/>\r
+\r
+<xsl:template name="get-area-attributes">\r
+ <xsl:attribute name="valign">\r
+ <xsl:choose>\r
+ <xsl:when test="@display-align"><xsl:value-of select="@display-align"/></xsl:when>\r
+ <xsl:otherwise>top</xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:attribute>\r
+</xsl:template>\r
+\r
+</xsl:stylesheet>\r