--- a/FOPRunXSLTExt/examples/balisage2014.xsl Mon Jul 28 20:41:13 2014 +0100
+++ b/FOPRunXSLTExt/examples/balisage2014.xsl Mon Jul 28 23:28:14 2014 +0100
@@ -37,7 +37,7 @@
<xsl:key name="overrides" match="override" use="@id" />
<!-- All 'box' elements in source. -->
-<xsl:key name="boxes" match="box" use="true()" />
+<xsl:key name="boxes" match="box" use="@id"/>
<!-- ============================================================= -->
@@ -45,7 +45,7 @@
<!-- ============================================================= -->
<!-- Initial font size. -->
-<xsl:param name="font-size" select="40" as="xs:double" />
+<xsl:param name="font-size" select="15" as="xs:double" />
<!-- Allowed difference in height between outer box and formatted
paragraph text to be able to say paragraph fits within box and
@@ -80,18 +80,21 @@
<!-- ATTRIBUTE SETS -->
<!-- ============================================================= -->
-<xsl:attribute-set name="code-title">
+<xsl:attribute-set name="title">
<xsl:attribute name="font-weight" select="'bold'" />
<xsl:attribute name="font-size" select="'2em'" />
+ <xsl:attribute name="keep-with-next" select="'always'" />
<xsl:attribute name="space-before" select="'1em'" />
<xsl:attribute name="space-after" select="'0.5em'" />
</xsl:attribute-set>
<xsl:attribute-set name="code">
<xsl:attribute name="font-family" select="'monospace'" />
+</xsl:attribute-set>
+
+<xsl:attribute-set name="code-block" use-attribute-sets="code">
<xsl:attribute name="padding" select="'6pt'" />
<xsl:attribute name="space-before.conditionality" select="'retain'" />
- <xsl:attribute name="background-color" select="'#f8f8f8'" />
<xsl:attribute name="linefeed-treatment" select="'preserve'" />
<xsl:attribute name="white-space-collapse" select="'false'" />
<xsl:attribute name="white-space-treatment" select="'preserve'" />
@@ -117,16 +120,19 @@
font-size="9pt"
axf:column-count="4"
column-gap="48pt">
- <fo:block xsl:use-attribute-sets="code-title">XML</fo:block>
- <fo:block xsl:use-attribute-sets="code">
+ <fo:block xsl:use-attribute-sets="title">XML</fo:block>
+ <fo:block xsl:use-attribute-sets="code-block"
+ background-color="#f0f3f3">
<xsl:sequence
select="if ($pygmentize ne 'no')
then doc(concat(tokenize(base-uri(), '/')[last()], '.fo'))
else unparsed-text(base-uri())" />
</fo:block>
- <fo:block xsl:use-attribute-sets="code-title">XSLT</fo:block>
+ <fo:block xsl:use-attribute-sets="title">XSLT</fo:block>
<fo:block height="100%"
- xsl:use-attribute-sets="code">
+ xsl:use-attribute-sets="code-block"
+ background-color="#f0f3f3"
+ display-align="justify">
<xsl:sequence
select="if ($pygmentize ne 'no')
then doc(concat(tokenize(base-uri(doc('')), '/')[last()], '.fo'))
@@ -156,7 +162,7 @@
<xsl:with-param name="font-size.minimum"
select="$font-size" as="xs:double" tunnel="yes" />
<xsl:with-param name="font-size.maximum"
- select="$font-size * 3" as="xs:double" tunnel="yes" />
+ select="$font-size * 6" as="xs:double" tunnel="yes" />
<xsl:with-param name="iteration" select="1" as="xs:integer" />
<xsl:with-param name="iteration-max"
select="$iteration-max" as="xs:integer" tunnel="yes" />
@@ -192,7 +198,7 @@
<xsl:variable name="overrides">
<overrides>
<!-- Set the font size. -->
- <xsl:for-each select="key('boxes', true())">
+ <xsl:for-each select="key('boxes', @id)">
<xsl:variable name="id" select="@id" as="xs:string" />
<override id="{$id}" font-size="{$font-size}" />
</xsl:for-each>
@@ -220,7 +226,7 @@
<xsl:variable
name="block"
- select="ppl:block-by-id($area-tree, key('boxes', true())[1]/@id)"
+ select="ppl:block-by-id($area-tree, @id)"
as="element()" />
<xsl:variable
@@ -230,14 +236,15 @@
<xsl:variable
name="target-height"
- select="xs:double(substring-before(key('boxes', true())[1]/@height, 'pt'))"
+ select="ppl:length-to-pt(@height)"
as="xs:double" />
<xsl:message select="concat('bpd: ', $bpd)" />
<xsl:message select="concat('target-height: ', $target-height)" />
<xsl:choose>
<xsl:when test="$target-height - $bpd > 0 and
- $target-height - $bpd < $tolerance">
+ $target-height - $bpd < $tolerance and
+ ppl:is-last($block)">
<xsl:message>It fits. Using <xsl:value-of select="$font-size" />.</xsl:message>
<xsl:apply-templates select="." mode="#default">
<xsl:with-param
@@ -248,7 +255,8 @@
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$font-size.maximum - $font-size.minimum < $font-size-tolerance and
- $target-height - $bpd > 0">
+ $target-height - $bpd > 0 and
+ ppl:is-last($block)">
<xsl:message>Font size difference less than $font-size-tolerance. Using <xsl:value-of select="$font-size" />.</xsl:message>
<xsl:apply-templates select="." mode="#default">
<xsl:with-param
@@ -268,8 +276,9 @@
tunnel="yes" />
</xsl:apply-templates>
</xsl:when>
- <xsl:when test="$bpd > $target-height">
- <xsl:message>$bpd gt $target-height</xsl:message>
+ <xsl:when test="$bpd > $target-height or
+ not(ppl:is-last($block))">
+ <xsl:message>$bpd gt $target-height or not last</xsl:message>
<xsl:call-template name="do-box">
<xsl:with-param
name="font-size"
@@ -364,11 +373,7 @@
name="block"
select="ppl:block-by-id($area-tree, 'header')"
as="element()" />
-<xsl:message
- select="max(for $line-area in $block/ahf:FlowReferenceArea/ahf:BlockArea/ahf:LineArea
- return ppl:sum-lengths-to-pt($line-area/*/@width))"
- xmlns:ahf="http://www.antennahouse.com/names/XSL/AreaTree" />
-<xsl:message select="$block"/>
+
<xsl:variable
name="ipd"
select="ppl:block-ipd($block)"
@@ -379,8 +384,6 @@
select="ppl:block-available-ipd($block)"
as="xs:double" />
- <xsl:message select="$ipd"/>
- <xsl:message select="$available-ipd"/>
<xsl:apply-templates select="." mode="#default">
<xsl:with-param name="overrides" tunnel="yes">
<xsl:document>
@@ -416,9 +419,11 @@
<xsl:param name="overrides" select="$overrides"
as="document-node()" tunnel="yes"/>
- <fo:block-container role="{local-name()}" border="medium solid black"
- width="{@width}" height="{@height}" padding="12pt"
- id="{@id}">
+ <fo:block-container
+ role="{local-name()}" border="{(@border, 'medium solid black')[1]}"
+ width="{@width}" height="{@height}" padding="12pt"
+ id="{@id}" axf:column-count="{(@columns, 1)[1]}"
+ column-gap="48pt">
<xsl:if test="key('overrides', @id, $overrides)/@rotate = 'yes'">
<xsl:attribute name="reference-orientation" select="'270'" />
</xsl:if>
@@ -430,6 +435,12 @@
</fo:block-container>
</xsl:template>
+<xsl:template match="title">
+ <fo:block xsl:use-attribute-sets="title">
+ <xsl:apply-templates />
+ </fo:block>
+</xsl:template>
+
<xsl:template match="paragraph">
<fo:block id="{@id}" text-align="justify" space-before="3pt">
<xsl:apply-templates/>
@@ -476,14 +487,14 @@
<fo:list-block
provisional-distance-between-starts="35mm"
provisional-label-separation="4pt"
- space-after="3pt"
+ space-before="0.5em"
id="{@id}">
<xsl:apply-templates/>
</fo:list-block>
</xsl:template>
<xsl:template match="api-list/item">
- <fo:list-item space-before="3pt">
+ <fo:list-item space-before="3pt" keep-together.within-column="always">
<fo:list-item-label end-indent="0">
<fo:block xsl:use-attribute-sets="code"
background-color="transparent">
@@ -492,7 +503,7 @@
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block />
- <fo:block space-before="2em"
+ <fo:block space-before="1.5em"
space-before.conditionality="retain">
<xsl:apply-templates select="def" />
</fo:block>
@@ -508,6 +519,12 @@
</fo:instream-foreign-object>
</xsl:template>
+<xsl:template match="code | url">
+ <fo:inline font-size="0.9em" xsl:use-attribute-sets="code">
+ <xsl:apply-templates />
+ </fo:inline>
+</xsl:template>
+
<xsl:template match="font-size">
<xsl:param name="font-size" as="xs:double" tunnel="yes" />