Merged.
authorTony Graham
Mon, 02 Dec 2013 14:37:14 +0000
changeset 17 30e136c75630
parent 16 2fe56172c8cf (current diff)
parent 14 f9507e36d645 (diff)
child 18 28ef4f6455d4
Merged.
FOPRunXSLTExt/build-nonb.xml
FOPRunXSLTExt/examples/formatting.xsl
--- a/FOPRunXSLTExt/build-nonb.xml	Mon Dec 02 13:47:11 2013 +0000
+++ b/FOPRunXSLTExt/build-nonb.xml	Mon Dec 02 14:37:14 2013 +0000
@@ -3,7 +3,7 @@
 <project name="FOPRunXSLTExt-nonb" default="default" basedir=".">
     <description>Builds, tests, and runs the project FOPRunXSLTExt.</description>
 
-    <property name="zip.version" value="0.0.2" />
+    <property name="zip.version" value="0.0.3" />
 
     <import file="build.xml"/>
 
@@ -47,7 +47,7 @@
     <target name="zip.windows">
       <zip destfile="FOPRunXSLTExt-windows-${zip.version}.zip">
 	<zipfileset dir="examples"
-		    includes="runsaxon9he_fop10.bat FOPRunXSLTExt.jar README example1*.* out"
+		    includes="runsaxon9he_fop10.bat FOPRunXSLTExt.jar README example*.xml example*.xsl out"
 		    prefix="FOPRunXSLTExt-windows-${zip.version}" />
       </zip>
     </target>
--- a/FOPRunXSLTExt/examples/README	Mon Dec 02 13:47:11 2013 +0000
+++ b/FOPRunXSLTExt/examples/README	Mon Dec 02 14:37:14 2013 +0000
@@ -89,6 +89,18 @@
 
 Rotates a fixed-size box if it is too wide for the page.
 
+This is effectively a simplified version of requirement #10 from
+CustomerRequirements (on the 'ppl' wiki). That requirement is for
+knowing whether a table should be column-wide, page-wide, or rotated
+to to be page-high based on its formatted size. To do that, the
+stylesheet would have to get the sizes of the table when it's
+formatted to be column-wide, page-wide, and page-high and, based on
+those, decide which width and orientation to use for the table in the
+formatted result. This example reduces that to a single fixed-size
+block, analogous to the size of the formatted table, and the
+stylesheet just makes the single decision whether or not to rotate the
+block based on its formatted width.
+
 The <box> element in 'example3.xml' specifies its formatted height and
 width:
 
@@ -116,3 +128,29 @@
 Linux/Mac:
 
 ./runsaxon9he_fop10.sh example3.xml example3_saxon9_fop10.xsl out/example3_saxon9_fop10.fo out example3_saxon9_fop10.at
+
+
+Example 4 - List item label width
+---------------------------------
+
+Adjusts the lengths allowed for list items to exactly fit the
+formatted width of the list item labels.
+
+This demonstrates a solution to requirement #9, "Ability to modify
+label field width in a single list when labels are large", from
+http://www.w3.org/community/ppl/wiki/CustomerRequirements on the 'ppl'
+wiki.
+
+'example4.xml' includes two lists that, when transformed with
+'formatting.xsl' and formatted, have list item label widths that are
+either too wide or too narrow for the labels in the lists.
+
+When transformed with 'example4_saxon9_fop10.xsl' and formatted, the
+list item label widths are set based on the actual maximum formatted
+width of the labels in each list.  The 'example4_saxon9_fop10.xsl'
+stylesheet does this by constructing a test document containing just
+the list item label texts, using the extension function to format that
+and get the area tree, and determining the maximum widths from the
+area tree.  The document that is formatted mid-transform is, unlike in
+previous examples, a different document to the one used to produce the
+final output.
--- a/FOPRunXSLTExt/examples/example3.xml	Mon Dec 02 13:47:11 2013 +0000
+++ b/FOPRunXSLTExt/examples/example3.xml	Mon Dec 02 14:37:14 2013 +0000
@@ -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	Mon Dec 02 14:37:14 2013 +0000
@@ -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	Mon Dec 02 14:37:14 2013 +0000
@@ -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>