Files for potential Balisage 2014 poster.
authorTony Graham
Fri, 25 Jul 2014 23:22:25 +0100
changeset 43 7db8588cbd7d
parent 42 a39a8a638b3d
child 44 902a8c95ed31
Files for potential Balisage 2014 poster.
FOPRunXSLTExt/examples/balisage2014.xml
FOPRunXSLTExt/examples/balisage2014.xsl
FOPRunXSLTExt/examples/ppl-logo.svg
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FOPRunXSLTExt/examples/balisage2014.xml	Fri Jul 25 23:22:25 2014 +0100
@@ -0,0 +1,30 @@
+<example name="Example 4">
+<header>Print and Page Layout Community Group XSLT Extensions <svg href="ppl-logo.svg" id="logo"/></header>
+
+<box id="box001" width="2267pt" height="600pt">
+<paragraph id="para001">The XSLT extension functions from the Print and Page Layout Community Group @ W3C allow you to run the XSL-FO formatter to get an area tree to do things like: adjust the start-indent of a fo:list-block based on the length of the longest fo:list-item-label; or size this text to be <font-size/> so it exactly fits this box.</paragraph>
+</box>
+<paragraph id="para002">The extension is available for Java and DotNet and uses either the Apache FOP XSL formatter or Antenna House AHF formatter to produce the area trees.</paragraph>
+<paragraph>The single Java jar file covers four combinations of XSLT processor and XSL-FO formatter:</paragraph>
+<list id="list001">
+  <item label="*">Saxon 9.5 and FOP</item>
+  <item label="*">Saxon 9.5 and Antenna House</item>
+  <item label="*">Xalan and FOP</item>
+  <item label="*">Xalan and Antenna House</item>
+</list>
+<paragraph>The DotNet version supports:</paragraph>
+
+<list id="list002">
+  <item label="*">DotNet 4.0 and FOP</item>
+  <item label="*">DotNet 4.0 and Antenna House</item>
+</list>
+
+<paragraph>API:</paragraph>
+<list id="list003">
+  <item label="ppl:area-tree($fo-tree as node()) as document-node()">Runs the XSL-FO formatter on $fo-tree to get an area tree.</item>
+  <item label="ppl:block-by-id($area-tree as document-node(), $id as string) as element()?">Returns the block area with ID $id.</item>
+  <item label="ppl:block-bpd($block as element()) as xs:double">Returns the block-progression-dimension of $block in points.</item>
+  <item label="ppl:block-bpd($block as element()) as xs:double">Returns the inline-progression-dimension of $block in points.</item>
+  <item label="ppl:block-available-ipd($block as element()) as xs:double">Returns the difference, in points, between the inline-progression-dimension of $block and the inline-progression-dimension of its ancestor reference area.</item>
+</list>
+</example>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FOPRunXSLTExt/examples/balisage2014.xsl	Fri Jul 25 23:22:25 2014 +0100
@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ============================================================= -->
+<!-- FOPRunXSLTExt Saxon example 5                                 -->
+<!--                                                               -->
+<!-- See http://www.w3.org/community/ppl/wiki/XSLTExtensions       -->
+<!--                                                               -->
+<!-- Requires Saxon 9.5 or later and FOP 1.0 or AHF 6.1            -->
+<!--                                                               -->
+<!-- Produced by the Print and Page Layout Community Group @ W3C   -->
+<!-- http://www.w3.org/community/ppl/                              -->
+<!-- ============================================================= -->
+<xsl:stylesheet
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    version="2.0"
+    xmlns:ppl="http://www.w3.org/community/ppl/ns/"
+    xmlns:fo="http://www.w3.org/1999/XSL/Format"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes="ppl xs">
+
+<!-- ============================================================= -->
+<!-- IMPORTS                                                       -->
+<!-- ============================================================= -->
+
+<!-- Print and Page Layout Community Group extensions. -->
+<xsl:import href="ppl-extensions.xsl" />
+
+<!-- Common templates for formatting FOPRunXSLTExt examples -->
+<xsl:import href="formatting.xsl" />
+
+<xsl:strip-space elements="example box" />
+
+<!-- ============================================================= -->
+<!-- KEYS                                                          -->
+<!-- ============================================================= -->
+
+<!-- All 'box' elements in source. -->
+<xsl:key name="boxes" match="box" use="true()" />
+
+
+<!-- ============================================================= -->
+<!-- STYLESHEET PARAMETERS                                         -->
+<!-- ============================================================= -->
+
+<!-- Initial font size. -->
+<xsl:param name="font-size" select="12" as="xs:double" />
+
+<!-- Allowed difference in height between outer box and formatted
+     paragraph text to be able to say paragraph fits within box and
+     stop further iterations. -->
+<xsl:param name="tolerance" select="1" as="xs:double" />
+
+<!-- Difference between font-size.minimum and font-size.maximum below
+     which it's not worth continuing. -->
+<xsl:param name="font-size-tolerance" select="0.01" as="xs:double" />
+
+
+<!-- ============================================================= -->
+<!-- STYLESHEET VARIABLES                                          -->
+<!-- ============================================================= -->
+
+<!-- A0, portrait, page size. -->
+<xsl:variable name="page-height" select="'1189mm'" as="xs:string" />
+<xsl:variable name="page-width" select="'841mm'" as="xs:string" />
+
+<!-- ============================================================= -->
+<!-- INITIAL TEMPLATE                                              -->
+<!-- ============================================================= -->
+
+<xsl:template name="main">
+  <xsl:message select="concat('tolerance: ', $tolerance)" />
+  <xsl:message select="concat('font-size-tolerance: ', $font-size-tolerance)" />
+
+  <!-- 'do-box' templates recursively calls itself until: the
+       formatted area fits within the box within $tolerance; the
+       change in $font-size between successive runs is less than
+       $font-size-tolerance; or $iteration-max iterations is
+       reached. -->
+  <xsl:call-template name="do-box">
+    <xsl:with-param name="font-size" select="$font-size" as="xs:double" tunnel="yes" />
+    <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 * 10" as="xs:double" tunnel="yes" />
+    <xsl:with-param name="iteration" select="1" as="xs:integer" />
+    <xsl:with-param name="iteration-max" select="30" as="xs:integer" tunnel="yes" />
+    <xsl:with-param name="tolerance" select="$tolerance" as="xs:double" tunnel="yes" />
+    <xsl:with-param name="font-size-tolerance" select="$font-size-tolerance" as="xs:double" tunnel="yes" />
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="do-box">
+  <xsl:param name="font-size" as="xs:double" tunnel="yes" />
+  <xsl:param name="font-size.minimum" as="xs:double" tunnel="yes" />
+  <xsl:param name="font-size.maximum" as="xs:double" tunnel="yes" />
+  <xsl:param name="iteration" select="1" as="xs:integer" />
+  <xsl:param name="iteration-max" select="5" as="xs:integer" tunnel="yes" />
+  <xsl:param name="tolerance" select="$tolerance" as="xs:double" tunnel="yes" />
+  <xsl:param name="font-size-tolerance" select="$font-size-tolerance" as="xs:double" tunnel="yes" />
+
+  <xsl:message>iteration = <xsl:value-of select="$iteration" /></xsl:message>
+  <xsl:message>font-size = <xsl:value-of select="$font-size" /></xsl:message>
+  <xsl:message>font-size.minimum = <xsl:value-of select="$font-size.minimum" /></xsl:message>
+  <xsl:message>font-size.maximum = <xsl:value-of select="$font-size.maximum" /></xsl:message>
+
+  <xsl:variable name="overrides">
+    <overrides>
+      <!-- Set the font size. -->
+      <xsl:for-each select="key('boxes', true())">
+        <xsl:variable name="id" select="@id" as="xs:string" />
+        <override id="{$id}" font-size="{$font-size}" />
+      </xsl:for-each>
+    </overrides>
+  </xsl:variable>
+
+  <!-- Save the FO tree in a variable. -->
+  <xsl:variable name="fo_tree">
+    <xsl:apply-templates select="/">
+      <xsl:with-param name="overrides" select="$overrides" as="document-node()" tunnel="yes" />
+    </xsl:apply-templates>
+  </xsl:variable>
+
+  <xsl:variable
+      name="area-tree"
+      select="ppl:area-tree($fo_tree)"
+      as="document-node()?" />
+
+  <xsl:variable
+      name="block"
+      select="ppl:block-by-id($area-tree, key('boxes', true())[1]/@id)"
+      as="element()" />
+
+  <xsl:variable
+      name="bpd"
+      select="ppl:block-bpd($block)"
+      as="xs:double" />
+
+  <xsl:variable
+      name="target-height"
+      select="xs:double(substring-before(key('boxes', true())[1]/@height, 'pt'))"
+      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 &lt; $tolerance">
+      <xsl:message>It fits.  Using <xsl:value-of select="$font-size" />.</xsl:message>
+      <xsl:apply-templates select="/">
+        <xsl:with-param
+            name="overrides"
+            select="$overrides"
+            as="document-node()"
+            tunnel="yes" />
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:when test="$font-size.maximum - $font-size.minimum &lt; $font-size-tolerance">
+      <xsl:message>Font size difference less than $font-size-tolerance.  Using <xsl:value-of select="$font-size" />.</xsl:message>
+      <xsl:apply-templates select="/">
+        <xsl:with-param
+            name="overrides"
+            select="$overrides"
+            as="document-node()"
+            tunnel="yes" />
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:when test="$iteration eq $iteration-max">
+      <xsl:message>Maximum iterations.  Using <xsl:value-of select="$font-size" />.</xsl:message>
+      <xsl:apply-templates select="/">
+        <xsl:with-param
+            name="overrides"
+            select="$overrides"
+            as="document-node()"
+            tunnel="yes" />
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:when test="$bpd > $target-height">
+      <xsl:call-template name="do-box">
+        <xsl:with-param
+            name="font-size"
+            select="($font-size + $font-size.minimum) div 2"
+            as="xs:double"
+            tunnel="yes" />
+        <xsl:with-param
+            name="font-size.maximum"
+            select="$font-size"
+            as="xs:double"
+            tunnel="yes" />
+        <xsl:with-param name="iteration" select="$iteration + 1" as="xs:integer" />
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:call-template name="do-box">
+        <xsl:with-param
+            name="font-size"
+            select="($font-size + $font-size.maximum) div 2"
+            as="xs:double"
+            tunnel="yes" />
+        <xsl:with-param
+            name="font-size.minimum"
+            select="$font-size"
+            as="xs:double"
+            tunnel="yes" />
+        <xsl:with-param name="iteration" select="$iteration + 1" as="xs:integer" />
+      </xsl:call-template>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+
+<xsl:template match="/">
+  <fo:root font-family="verdana, sans-serif" font-size="12pt">
+    <fo:layout-master-set>
+      <fo:simple-page-master master-name="test-page">
+        <xsl:if test="exists($page-height)">
+          <xsl:attribute name="page-height" select="$page-height"/>
+        </xsl:if>
+        <xsl:if test="exists($page-width)">
+          <xsl:attribute name="page-width" select="$page-width"/>
+        </xsl:if>
+        <fo:region-body margin="1in"/>
+      </fo:simple-page-master>
+    </fo:layout-master-set>
+
+    <fo:page-sequence master-reference="test-page">
+      <fo:flow flow-name="xsl-region-body">
+        <xsl:apply-templates/>
+        <fo:block-container
+            font-size="9pt"
+            axf:column-count="4"
+            xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions">
+	  <fo:block font-weight="bold"
+		    font-size="2em">XML</fo:block>
+          <fo:block linefeed-treatment="preserve"
+                    white-space-collapse="false"
+                    white-space-treatment="preserve">
+            <xsl:value-of select="unparsed-text(base-uri())" />
+          </fo:block>
+	  <fo:block font-weight="bold"
+		    font-size="2em">XSLT</fo:block>
+          <fo:block linefeed-treatment="preserve"
+                    white-space-collapse="false"
+                    white-space-treatment="preserve">
+            <xsl:value-of select="unparsed-text('')" />
+          </fo:block>
+        </fo:block-container>
+      </fo:flow>
+    </fo:page-sequence>
+  </fo:root>
+</xsl:template>
+
+<xsl:template match="header">
+  <fo:block font-size="14pt" color="red"
+	    space-before="5mm" space-after="5mm">
+   <xsl:apply-templates />
+  </fo:block>
+</xsl:template>
+
+<xsl:template match="svg">
+  <fo:instream-foreign-object id="{@id}" content-height="1em">
+    <xsl:copy-of select="document(@href)"/>
+  </fo:instream-foreign-object>
+</xsl:template>
+
+<xsl:template match="font-size">
+  <xsl:param name="font-size" as="xs:double" tunnel="yes" />
+
+  <xsl:value-of select="$font-size"/>
+  <xsl:text>pt</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FOPRunXSLTExt/examples/ppl-logo.svg	Fri Jul 25 23:22:25 2014 +0100
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 12.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 51448)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+	<!ENTITY ns_svg "http://www.w3.org/2000/svg">
+	<!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
+]>
+<svg  version="1.1" id="Layer_1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="94.064" height="94.352"
+	 viewBox="2.857 2.857 94.064 94.352" style="overflow:visible;enable-background:new 2.857 2.857 94.064 94.352;"
+	 xml:space="preserve">
+<title>W3C Community Groups Logo</title>
+<desc>
+	This is a symbol of unity and collaboration with diversity.  Four stylized human figures in a circle, with arms reaching out to one another, heads pointed outward, bodies tapering in toward the center of the circle.  The figures are different colors (light blue, pale green, red, and orange), and different sizes.  This image links back to the W3C Community Groups site.
+	</desc>
+<a xlink:href="http://www.w3.org/community/"  xlink:title="W3C Community Groups">
+	<g id="shadows">
+		<path style="fill:#FFFFFF;" d="M45.749,44.435c-0.035-11.319,1.114-21.53,1.114-21.53l-7.042-6.576c0,0,10.818-3.615,17.688-0.233
+			c2.646,6.666,13.805,6.143,13.805,6.143s8.22,4.31,11.213,12.771c-4.077-1.358-16.193-4.628-16.193-4.628
+			S54.323,34.022,45.749,44.435z"/>
+		<ellipse style="fill:#FFFFFF;" cx="69.106" cy="11.982" rx="9.976" ry="6.927"/>
+		<path style="fill:#FFFFFF;" d="M47.774,51.714c8.051,6.448,12.65,11.552,17.673,18.121c0.158,3.692-0.759,8.158-2.095,12.923
+			c8.517-2.692,14.23-9.505,14.23-9.505s-2.857-10.989,7.527-13.736c2.363-6.374,1.1-15.495-0.385-18.611
+			c-3.61,2.884-5.615,6.105-10,10.796C67.325,51.701,47.774,51.714,47.774,51.714z"/>
+		<circle style="fill:#FFFFFF;" cx="88.448" cy="70.079" r="8.473"/>
+		<path style="fill:#FFFFFF;" d="M40.989,52.593c-1.065,5.132-1.384,13.297,1.319,20.989c2.967,5.824,11.978,11.318,13.626,11.208
+			s-9.341,2.638-16.329-0.549c-1.471-3.297-5.427-7.802-12.46-6.593c-3.736-3.187-7.65-7.789-9.561-13.956
+			c3.517,1.099,6.367,3.024,11.648,3.296C33.865,62.684,40.989,52.593,40.989,52.593z"/>
+		<ellipse style="fill:#FFFFFF;" cx="29.725" cy="88.886" rx="7.748" ry="8.323"/>
+		<path style="fill:#FFFFFF;" d="M39.822,46.33L29.67,30.615c0.77-6.593,6.044-13.406,6.044-13.406
+			c-10.109,3.626-14.615,11.538-14.615,11.538c0.77,8.352-5.714,10.11-5.714,10.11c-2.528,8.242-0.55,16.594-0.55,16.594
+			c2.857-7.363,5.937-9.618,5.937-9.618L39.822,46.33z"/>
+		<ellipse style="fill:#FFFFFF;" cx="10.879" cy="29.956" rx="7.802" ry="7.143"/>
+	</g>
+	<g id="figures">
+		<path style="fill:#98C000;" d="M45.53,42.237c-0.035-11.319,1.114-21.53,1.114-21.53l-7.042-6.576c0,0,10.818-3.615,17.688-0.233
+			c2.646,6.666,13.805,6.143,13.805,6.143s8.22,4.31,11.213,12.771c-4.077-1.358-16.193-4.628-16.193-4.628
+			S54.104,31.824,45.53,42.237z"/>
+		<ellipse style="fill:#98C000;" cx="68.886" cy="9.784" rx="9.976" ry="6.927"/>
+		<path style="fill:#CE0005;" d="M47.554,49.517c8.051,6.448,12.65,11.552,17.673,18.121c0.158,3.692-0.759,8.158-2.095,12.923
+			c8.517-2.692,14.23-9.506,14.23-9.506s-2.857-10.989,7.527-13.736c2.363-6.374,1.099-15.495-0.385-18.611
+			c-3.61,2.884-5.615,6.105-10,10.796C67.106,49.503,47.554,49.517,47.554,49.517z"/>
+		<circle style="fill:#CE0005;" cx="88.229" cy="67.881" r="8.473"/>
+		<path style="fill:#F08400;" d="M40.769,50.396c-1.065,5.132-1.384,13.297,1.319,20.989c2.967,5.824,11.978,11.318,13.626,11.208
+			s-9.341,2.637-16.329-0.549c-1.471-3.297-5.427-7.802-12.46-6.593c-3.736-3.187-7.65-7.789-9.561-13.956
+			c3.517,1.099,6.367,3.024,11.648,3.296C33.646,60.486,40.769,50.396,40.769,50.396z"/>
+		<ellipse style="fill:#F08400;" cx="29.505" cy="86.688" rx="7.748" ry="8.323"/>
+		<path style="fill:#008EC1;" d="M39.602,44.132L29.45,28.417c0.77-6.593,6.044-13.407,6.044-13.407
+			c-10.109,3.626-14.615,11.539-14.615,11.539c0.77,8.352-5.714,10.11-5.714,10.11c-2.528,8.242-0.55,16.594-0.55,16.594
+			c2.857-7.363,5.937-9.618,5.937-9.618L39.602,44.132z"/>
+		<ellipse style="fill:#008EC1;" cx="10.659" cy="27.758" rx="7.802" ry="7.143"/>
+	</g>
+</a>
+<g>
+	<path style="fill:#FFFFFF;" d="M4.923,34.534l7.488-1.248v5.616c1.638-3.042,4.992-5.928,10.53-5.928
+		c9.282,0,14.898,7.878,14.898,17.472c0,10.452-6.552,19.656-17.784,19.656c-3.276,0-5.928-0.78-7.41-1.872v17.862L4.923,87.34
+		V34.534z M12.645,45.064V60.04c0,2.652,2.34,3.978,6.006,3.978c6.63,0,11.076-4.602,11.076-13.026
+		c0-7.332-3.354-11.622-8.112-11.622C16.935,39.37,13.659,43.583,12.645,45.064z"/>
+	<path style="fill:#FFFFFF;" d="M46.263,34.534l7.488-1.248v5.616c1.638-3.042,4.992-5.928,10.53-5.928
+		c9.282,0,14.898,7.878,14.898,17.472c0,10.452-6.552,19.656-17.784,19.656c-3.276,0-5.928-0.78-7.41-1.872v17.862l-7.722,1.248
+		V34.534z M53.985,45.064V60.04c0,2.652,2.34,3.978,6.006,3.978c6.63,0,11.076-4.602,11.076-13.026
+		c0-7.332-3.354-11.622-8.112-11.622C58.275,39.37,54.999,43.583,53.985,45.064z"/>
+	<path style="fill:#FFFFFF;" d="M87.759,14.645l7.722-1.248v55.77h-7.722V14.645z"/>
+</g>
+<g>
+	<path d="M2.911,32.522l7.488-1.248v5.616c1.638-3.042,4.992-5.928,10.53-5.928c9.282,0,14.898,7.878,14.898,17.472
+		c0,10.452-6.552,19.656-17.784,19.656c-3.276,0-5.928-0.78-7.41-1.872V84.08l-7.722,1.248V32.522z M10.634,43.053v14.976
+		c0,2.652,2.34,3.978,6.006,3.978c6.63,0,11.076-4.602,11.076-13.026c0-7.332-3.354-11.622-8.112-11.622
+		C14.924,37.358,11.648,41.571,10.634,43.053z"/>
+	<path d="M44.251,32.522l7.488-1.248v5.616c1.638-3.042,4.992-5.928,10.53-5.928c9.282,0,14.898,7.878,14.898,17.472
+		c0,10.452-6.552,19.656-17.784,19.656c-3.276,0-5.928-0.78-7.41-1.872V84.08l-7.722,1.248V32.522z M51.973,43.053v14.976
+		c0,2.652,2.34,3.978,6.006,3.978c6.63,0,11.076-4.602,11.076-13.026c0-7.332-3.354-11.622-8.112-11.622
+		C56.263,37.358,52.988,41.571,51.973,43.053z"/>
+	<path d="M85.747,12.633l7.722-1.248v55.77h-7.722V12.633z"/>
+</g>
+</svg>