Using 'ppl-extensions.xsl' and common to both formatters.
authorTony Graham
Wed, 05 Mar 2014 22:10:27 +0000
changeset 38 0d3a1d7c9a15
parent 37 48816cea447e
child 39 6438ee017386
Using 'ppl-extensions.xsl' and common to both formatters.
FOPRunXSLTExt/examples/example3.xsl
FOPRunXSLTExt/examples/example3_saxon9_ahf.xsl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FOPRunXSLTExt/examples/example3.xsl	Wed Mar 05 22:10:27 2014 +0000
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ============================================================= -->
+<!-- FOPRunXSLTExt Saxon example 3                                 -->
+<!--                                                               -->
+<!-- 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" />
+
+
+<!-- ============================================================= -->
+<!-- KEYS                                                          -->
+<!-- ============================================================= -->
+
+<!-- All 'box' elements in source. -->
+<xsl:key name="boxes" match="box" use="true()" />
+
+<xsl:key name="blocks" match="block[exists(@prod-id)]" use="@prod-id" />
+
+
+<!-- ============================================================= -->
+<!-- STYLESHEET PARAMETERS                                         -->
+<!-- ============================================================= -->
+
+<!-- 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">
+  <!-- Save the FO tree in a variable. -->
+  <xsl:variable name="fo_tree">
+    <xsl:apply-templates select="/" />
+  </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="ipd"
+      select="ppl:block-ipd($block)"
+      as="xs:double" />
+
+  <xsl:variable
+      name="available-ipd"
+      select="ppl:block-available-ipd($block)"
+      as="xs:double" />
+
+  <xsl:variable name="overrides">
+    <overrides>
+      <xsl:if test="$ipd > $available-ipd">
+	<override id="{key('boxes', true())[1]/@id}" rotate="yes" />
+      </xsl:if>
+    </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>
\ No newline at end of file
--- a/FOPRunXSLTExt/examples/example3_saxon9_ahf.xsl	Wed Mar 05 22:08:41 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- ============================================================= -->
-<!-- FOPRunXSLTExt Saxon example 3                                 -->
-<!--                                                               -->
-<!-- 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:ppl="http://org.w3c.ppl.xslt/saxon-extension"
-    exclude-result-prefixes="xs ppl">
-
-<!-- Common templates for formatting FOPRunXSLTExt examples -->
-<xsl:import href="formatting.xsl" />
-
-<xsl:key name="boxes" match="box" 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">
-  <!-- Save the FO tree in a variable. -->
-  <xsl:variable name="fo_tree">
-    <xsl:apply-templates select="/" />
-  </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="area-tree"
-      select="ppl:area-tree($fo_tree)"
-      as="document-node()" />
-  <xsl:message select="$area-tree"/>
-
-  <xsl:variable name="overrides">
-    <overrides>
-      <xsl:for-each select="key('boxes', true())">
-	<xsl:variable name="id" select="@id" as="xs:string" />
-	<xsl:variable name="block"
-		      select="key('blocks', $id, $area-tree)[1]" />
-	<xsl:if test="$block/@ipd > $block/ancestor::flow/@ipd">
-	  <override id="{$id}" rotate="yes" />
-	</xsl:if>
-      </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>
\ No newline at end of file