Added Example 4 for setting list item label width.
--- a/FOPRunXSLTExt/examples/example3.xml Sun Apr 28 16:04:32 2013 +0100
+++ b/FOPRunXSLTExt/examples/example3.xml Sun Apr 28 16:05:43 2013 +0100
@@ -1,4 +1,4 @@
-<example name="Example 1">
+<example name="Example 3">
<header>Print and Page Layout Community Group</header>
<box id="box001" width="8in" height="5in">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/FOPRunXSLTExt/examples/example4.xml Sun Apr 28 16:05:43 2013 +0100
@@ -0,0 +1,17 @@
+<example name="Example 4">
+<header>Print and Page Layout Community Group</header>
+
+<paragraph id="para001">The Print and Page Layout Community Group is:
+</paragraph>
+<list id="list001">
+ <item label="1.1">the "virtual water cooler"</item>
+ <item label="1.45678">where you can hang out</item>
+</list>
+
+<paragraph id="para002">The Print and Page Layout Community Group is:
+</paragraph>
+<list id="list002" label-width="narrow">
+ <item label="1.1">the "virtual water cooler"</item>
+ <item label="1.456">where you can hang out</item>
+</list>
+</example>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/FOPRunXSLTExt/examples/example4_saxon9_fop10.xsl Sun Apr 28 16:05:43 2013 +0100
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ============================================================= -->
+<!-- FOPRunXSLTExt Saxon example 4 -->
+<!-- -->
+<!-- See http://www.w3.org/community/ppl/wiki/FOPRunXSLTExt -->
+<!-- -->
+<!-- Requires Saxon 9.4 or later and FOP 1.0 -->
+<!-- -->
+<!-- Produced by the Print and Page Layout Community Group @ W3C -->
+<!-- ============================================================= -->
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="2.0"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:runfop="http://org.w3c.ppl.xslt/saxon-extension"
+ exclude-result-prefixes="xs runfop">
+
+<!-- Common templates for formatting FOPRunXSLTExt examples -->
+<xsl:import href="formatting.xsl" />
+
+<xsl:key name="lists" match="list" use="true()" />
+
+<xsl:key name="blocks" match="block[exists(@prod-id)]" use="@prod-id" />
+
+<!-- Where to write the output files. -->
+<xsl:param name="dest_dir" select="out" as="xs:string"/>
+<xsl:param name="area_tree_filename" />
+
+<!-- Initial template -->
+<xsl:template name="main">
+ <!-- Make a test document containing only the list labels. Re-use
+ example markup rather than creating FOs directly just because
+ it's convenient. -->
+ <xsl:variable name="test-doc">
+ <example>
+ <xsl:for-each select="key('lists', true())">
+ <box id="{@id}" width="3in" height="3in">
+ <xsl:for-each select="item/@label">
+ <paragraph>
+ <xsl:value-of select="."/>
+ </paragraph>
+ </xsl:for-each>
+ </box>
+ </xsl:for-each>
+ </example>
+ </xsl:variable>
+ <!-- Save the FO tree from $test-doc in a variable. -->
+ <xsl:variable name="fo_tree">
+ <xsl:apply-templates select="$test-doc" />
+ </xsl:variable>
+
+ <xsl:variable name="area_tree_file"
+ select="concat($dest_dir, '/', $area_tree_filename)" />
+
+ <xsl:message>Area tree filename = <xsl:value-of select="$area_tree_file" /></xsl:message>
+
+ <xsl:variable
+ name="url"
+ select="runfop:area-tree-url($fo_tree, $area_tree_file)"
+ as="xs:string" />
+
+ <xsl:variable
+ name="area-tree"
+ select="document($url)"
+ as="document-node()?" />
+
+ <xsl:variable name="overrides">
+ <overrides>
+ <!-- Find the maximum label width for each list and convert to pt. -->
+ <xsl:for-each select="key('lists', true())">
+ <xsl:variable name="id" select="@id" as="xs:string" />
+ <xsl:variable name="block"
+ select="key('blocks', $id, $area-tree)[1]" />
+ <override id="{$id}" label-width="{max($block//text/@ipd) div 1000}pt" />
+ </xsl:for-each>
+ </overrides>
+ </xsl:variable>
+
+ <xsl:apply-templates select="/">
+ <xsl:with-param name="overrides" select="$overrides" as="document-node()" tunnel="yes" />
+ </xsl:apply-templates>
+</xsl:template>
+
+</xsl:stylesheet>
--- a/FOPRunXSLTExt/examples/formatting.xsl Sun Apr 28 16:04:32 2013 +0100
+++ b/FOPRunXSLTExt/examples/formatting.xsl Sun Apr 28 16:05:43 2013 +0100
@@ -22,7 +22,7 @@
</xsl:variable>
<xsl:template match="/">
- <fo:root>
+ <fo:root font-family="verdana, sans-serif" font-size="12pt">
<fo:layout-master-set>
<fo:simple-page-master master-name="test-page">
<fo:region-body margin="1in"/>
@@ -31,15 +31,14 @@
<fo:page-sequence master-reference="test-page">
<fo:flow flow-name="xsl-region-body">
- <xsl:apply-templates select="example" />
+ <xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="header">
- <fo:block font-size="14pt" font-family="verdana, sans-serif"
- color="red" space-before="5mm" space-after="5mm">
+ <fo:block font-size="14pt" color="red" space-before="5mm" space-after="5mm">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
@@ -57,8 +56,7 @@
</xsl:template>
<xsl:template match="paragraph">
- <fo:block id="{@id}" text-indent="5mm"
- font-family="verdana, sans-serif" font-size="12pt">
+ <fo:block id="{@id}" text-indent="5mm" space-before="3pt">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
@@ -69,4 +67,40 @@
</fo:instream-foreign-object>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+<xsl:template match="list">
+ <xsl:param name="overrides" select="$overrides" as="document-node()" tunnel="yes"/>
+ <fo:list-block
+ provisional-distance-between-starts="{if (@label-width = 'narrow')
+ then '10mm'
+ else '35mm'}"
+ provisional-label-separation="4pt"
+ space-after="3pt"
+ id="{@id}">
+ <!-- If we know the exact label width, set the provisional
+ distance between starts to the width plus the label
+ separation. -->
+ <xsl:if test="exists(key('overrides', @id, $overrides))">
+ <xsl:attribute
+ name="provisional-distance-between-starts"
+ select="concat(key('overrides', @id, $overrides)/@label-width, ' + 4pt')" />
+ </xsl:if>
+ <xsl:apply-templates/>
+ </fo:list-block>
+</xsl:template>
+
+<xsl:template match="item">
+ <fo:list-item space-before="3pt">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>
+ <xsl:apply-templates select="@label"/>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ <xsl:apply-templates/>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+</xsl:template>
+
+</xsl:stylesheet>