Able to set page-width and page-height from importing stylesheet.
authorTony Graham
Fri, 25 Jul 2014 23:21:43 +0100
changeset 42 a39a8a638b3d
parent 41 61846273df58
child 43 7db8588cbd7d
Able to set page-width and page-height from importing stylesheet.
FOPRunXSLTExt/examples/formatting.xsl
--- a/FOPRunXSLTExt/examples/formatting.xsl	Wed Mar 05 22:13:08 2014 +0000
+++ b/FOPRunXSLTExt/examples/formatting.xsl	Fri Jul 25 23:21:43 2014 +0100
@@ -15,8 +15,28 @@
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     exclude-result-prefixes="xs">
 
+<!-- ============================================================= -->
+<!-- KEYS                                                          -->
+<!-- ============================================================= -->
+
 <xsl:key name="overrides" match="override" use="@id" />
 
+
+<!-- ============================================================= -->
+<!-- STYLESHEET PARAMETERS                                         -->
+<!-- ============================================================= -->
+
+<!-- Page height, if not using FO processor's default. -->
+<xsl:param name="page-height" select="()" as="xs:string?" />
+
+<!-- Page width, if not using FO processor's default. -->
+<xsl:param name="page-width" select="()" as="xs:string?" />
+
+
+<!-- ============================================================= -->
+<!-- STYLESHEET VARIABLES                                          -->
+<!-- ============================================================= -->
+
 <xsl:variable name="overrides">
   <no-overrides/>
 </xsl:variable>
@@ -25,6 +45,12 @@
   <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>
@@ -40,7 +66,7 @@
 <xsl:template match="header">
   <fo:block font-size="14pt" color="red"
 	    space-before="5mm" space-after="5mm">
-    <xsl:apply-templates/>
+   <xsl:apply-templates />
   </fo:block>
 </xsl:template>