From Arnaud Heritier :

plugin.jelly :
            code reformating,
            + debug mode corrected : uses correctly the project property �maven.pdf.debug� for the style task and the FO transformation,
            + uses a new property �maven.pdf.navigationFile� to specify a navigation file specific to the pdf doc.
plugin.properties :
            New property : �maven.pdf.navigationFile�
project.xml :
            code reformating,
fo-body.xslt :
            code reformating,
            + corrects some problem with external and internal links
            + write the link on the page when the navigation file points to an external link.
fo-table-column-widths.xslt, fo-tables.xslt :
            code reformating,
            + add the generation of tables with only tr/td and th.
project2fo.xslt :
            code reformating,
            + remove the generation of pages which are not hosted in the project.


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114603 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
evenisse 2004-01-21 09:14:44 +00:00
parent 6c0cd25761
commit afc1323fe1
8 changed files with 1666 additions and 1292 deletions

View File

@ -1,135 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:j="jelly:core"> <project xmlns:j="jelly:core">
<goal name="pdf:init" prereqs="xdoc:init">
<goal <j:set var="docsXdocSrc" value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.docs.src')}"/>
name="pdf:init" <j:set var="docsGenSrc" value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.gen.docs')}"/>
prereqs="xdoc:init"> <j:set var="docsPdf" value="${maven.build.dir}/pdf"/>
<j:set var="docsXdocSrc" <j:set var="docsToc" value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.docs.src')}/${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.navigationFile')}"/>
value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.docs.src')}"/> <j:set var="confidential" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.confidential')}"/>
<j:set var="docsGenSrc" <j:set var="paperType" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.paperType')}"/>
value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.gen.docs')}"/> <j:set var="companyName" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.companyName')}"/>
<j:set var="docsPdf" <j:set var="companyIncName" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.companyIncName')}"/>
value="${maven.build.dir}/pdf"/> <j:set var="publicationYear" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.copyrightYear')}"/>
<j:set var="docsToc" <j:set var="coverProjectCompany" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.projectCompany')}"/>
value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.docs.src')}/navigation.xml"/> <j:set var="coverProjectName" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.projectName')}"/>
<j:set var="confidential" <j:set var="coverType" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.type')}"/>
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.confidential')}"/> <j:set var="coverVersion" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.version')}"/>
<j:set var="paperType" <j:set var="coverDate" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.date')}"/>
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.paperType')}"/> <j:set var="projectLogo" value="${docsPdf}/images/${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.projectLogo')}"/>
<j:set var="companyName" <j:set var="companyLogo" value="${docsPdf}/images/${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.companyLogo')}"/>
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.companyName')}"/> <j:set var="imageDpi" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.imageDpi')}"/>
<j:set var="companyIncName" <j:set var="debug" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.debug')}"/>
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.companyIncName')}"/> <mkdir dir="${docsPdf}"/>
<j:set var="publicationYear" </goal>
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.copyrightYear')}"/> <goal name="fo" prereqs="fo:fo" description="Generate XSL:FO project documentation"/>
<j:set var="coverProjectCompany" <goal name="fo:fo" prereqs="pdf:prepare" description="Generate XSL:FO project documentation">
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.projectCompany')}"/> <echo>Generating ${docsDest}/project.fo ...</echo>
<j:set var="coverProjectName" <available file="${docsToc}" property="maven.fo.navigation.available"/>
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.projectName')}"/> <fail message="PDF generation cannot complete as ${docsToc} is missing" unless="maven.fo.navigation.available"/>
<j:set var="coverType" <!-- 'Major hack.' Stolen from the Latka plugin.jelly. All of this could be avoided by putting
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.type')}"/>
<j:set var="coverVersion"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.version')}"/>
<j:set var="coverDate"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.date')}"/>
<j:set var="projectLogo"
value="${docsPdf}/images/${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.projectLogo')}"/>
<j:set var="companyLogo"
value="${docsPdf}/images/${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.companyLogo')}"/>
<j:set var="imageDpi"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.imageDpi')}"/>
<j:set var="debug"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.debug')}"/>
<mkdir dir="${docsPdf}"/>
</goal>
<goal
name="fo"
prereqs="fo:fo"
description="Generate XSL:FO project documentation"/>
<goal name="fo:fo"
prereqs="pdf:prepare"
description="Generate XSL:FO project documentation">
<echo>Generating ${docsDest}/project.fo ...</echo>
<available file="${docsToc}"
property="maven.fo.navigation.available"/>
<fail message="PDF generation cannot complete as ${docsToc} is missing"
unless="maven.fo.navigation.available"/>
<!-- 'Major hack.' Stolen from the Latka plugin.jelly. All of this could be avoided by putting
xalan into $MAVEN_HOME/lib/endorsed directory in the distribution, but never mind --> xalan into $MAVEN_HOME/lib/endorsed directory in the distribution, but never mind -->
${systemScope.setProperty('javax.xml.transform.TransformerFactory','org.apache.xalan.processor.TransformerFactoryImpl')} ${systemScope.setProperty('javax.xml.transform.TransformerFactory','org.apache.xalan.processor.TransformerFactoryImpl')}
<style in="${docsToc}" out="${docsPdf}/project.fo" style="${plugin.resources}/project2fo.xslt" force="true"> <style in="${docsToc}" out="${docsPdf}/project.fo" style="${plugin.resources}/project2fo.xslt" force="true">
<param name="basePath" expression="${docsPdf}"/> <param name="basePath" expression="${docsPdf}"/>
<param name="confidential" expression="${confidential}"/> <param name="confidential" expression="${confidential}"/>
<param name="paperType" expression="${paperType}"/> <param name="paperType" expression="${paperType}"/>
<param name="companyName" expression="${companyName}"/> <param name="companyName" expression="${companyName}"/>
<param name="companyIncName" expression="${companyIncName}"/> <param name="companyIncName" expression="${companyIncName}"/>
<param name="publicationYear" expression="${publicationYear}"/> <param name="publicationYear" expression="${publicationYear}"/>
<param name="coverProjectCompany" expression="${coverProjectCompany}"/> <param name="coverProjectCompany" expression="${coverProjectCompany}"/>
<param name="coverProjectName" expression="${coverProjectName}"/> <param name="coverProjectName" expression="${coverProjectName}"/>
<param name="coverType" expression="${coverType}"/> <param name="coverType" expression="${coverType}"/>
<param name="coverVersion" expression="${coverVersion}"/> <param name="coverVersion" expression="${coverVersion}"/>
<param name="coverDate" expression="${coverDate}"/> <param name="coverDate" expression="${coverDate}"/>
<param name="companyLogo" expression="${companyLogo}"/> <param name="companyLogo" expression="${companyLogo}"/>
<param name="projectLogo" expression="${projectLogo}"/> <param name="projectLogo" expression="${projectLogo}"/>
<param name="imageDpi" expression="${imageDpi}"/> <param name="imageDpi" expression="${imageDpi}"/>
<param name="debug" expression="${debug}"/> <param name="debug" expression="${debug}"/>
</style> </style>
</goal> </goal>
<goal name="pdf" prereqs="fo:fo,pdf:prepare,pdf:pdf" description="Generate PDF project documentation"/>
<goal <goal name="pdf:prepare" prereqs="pdf:init" description="Stages all files needed to generate the PDF">
name="pdf" <!-- First, copy all of the generated xdocs -->
prereqs="fo:fo,pdf:prepare,pdf:pdf" <copy todir="${docsPdf}">
description="Generate PDF project documentation"/> <fileset dir="${docsGenSrc}" force="true">
<include name="**/*.*"/>
<goal </fileset>
name="pdf:prepare" </copy>
prereqs="pdf:init" <!-- Then, copy all of the user-supplied xdocs -->
description="Stages all files needed to generate the PDF"> <copy todir="${docsPdf}" force="true">
<!-- First, copy all of the generated xdocs --> <fileset dir="${docsXdocSrc}">
<copy todir="${docsPdf}"> <include name="**/*.*"/>
<fileset dir="${docsGenSrc}" force="true"> </fileset>
<include name="**/*.*"/> </copy>
</fileset> <!-- Finally, copy the FOP config file and all of the fonts -->
</copy> <copy todir="${docsPdf}" force="true">
<!-- Then, copy all of the user-supplied xdocs --> <fileset dir="${plugin.resources}">
<copy todir="${docsPdf}" force="true"> <include name="userconfig.xml"/>
<fileset dir="${docsXdocSrc}"> <include name="fonts/*.*"/>
<include name="**/*.*"/> </fileset>
</fileset> </copy>
</copy> </goal>
<!-- Finally, copy the FOP config file and all of the fonts --> <goal name="pdf:pdf" description="Generate PDF project documentation" prereqs="pdf:prepare">
<copy todir="${docsPdf}" force="true"> <echo>Generating ${docsPdf}/project.pdf ...</echo>
<fileset dir="${plugin.resources}"> <echo>Config file: ${docsPdf}/userconfig.xml</echo>
<include name="userconfig.xml"/> <java classname="org.apache.fop.apps.Fop" fork="yes" failonerror="true" maxmemory="500m">
<include name="fonts/*.*"/> <classpath>
</fileset> <pathelement location="${plugin.getDependencyPath('fop')}"/>
</copy> <pathelement location="${plugin.getDependencyPath('batik')}"/>
</goal> <pathelement location="${plugin.getDependencyPath('logkit')}"/>
<pathelement location="${plugin.getDependencyPath('avalon-framework')}"/>
<goal name="pdf:pdf" description="Generate PDF project documentation" <pathelement location="${plugin.getDependencyPath('xerces')}"/>
prereqs="pdf:prepare"> </classpath>
<echo>Generating ${docsPdf}/project.pdf ...</echo> <arg value="-c"/>
<echo>Config file: ${docsPdf}/userconfig.xml</echo> <arg value="${docsPdf}/userconfig.xml"/>
<java classname="org.apache.fop.apps.Fop" fork="yes" failonerror="true" maxmemory="500m"> <j:if test="${debug}"><arg value="-d"/></j:if>
<classpath> <arg value="-fo"/>
<pathelement location="${plugin.getDependencyPath('fop')}"/> <arg value="${docsPdf}/project.fo"/>
<pathelement location="${plugin.getDependencyPath('batik')}"/> <arg value="-pdf"/>
<pathelement location="${plugin.getDependencyPath('logkit')}"/> <arg value="${docsPdf}/project.pdf"/>
<pathelement location="${plugin.getDependencyPath('avalon-framework')}"/> <sysproperty key="javax.xml.transform.TransformerFactory" value="org.apache.xalan.processor.TransformerFactoryImpl"/>
<pathelement location="${plugin.getDependencyPath('xerces')}"/> </java>
</classpath> </goal>
<arg value="-c" />
<arg value="${docsPdf}/userconfig.xml" />
<arg value="-d" />
<arg value="-fo" />
<arg value="${docsPdf}/project.fo" />
<arg value="-pdf" />
<arg value="${docsPdf}/project.pdf"/>
<sysproperty key="javax.xml.transform.TransformerFactory" value="org.apache.xalan.processor.TransformerFactoryImpl"/>
</java>
</goal>
</project> </project>

View File

@ -10,6 +10,7 @@ maven.pdf.companyIncName=${pom.organization.name}
maven.pdf.copyrightYear=${pom.inceptionYear} maven.pdf.copyrightYear=${pom.inceptionYear}
maven.pdf.imageDpi=150 maven.pdf.imageDpi=150
maven.pdf.debug=false maven.pdf.debug=false
maven.pdf.navigationFile=navigation.xml
# Reserved for future use... # Reserved for future use...
maven.pdf.cover.projectCompany=${pom.organization.name} maven.pdf.cover.projectCompany=${pom.organization.name}
maven.pdf.cover.projectName=${pom.name} maven.pdf.cover.projectName=${pom.name}

View File

@ -1,91 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project> <project>
<extend>${basedir}/../project.xml</extend> <extend>${basedir}/../project.xml</extend>
<pomVersion>3</pomVersion> <pomVersion>3</pomVersion>
<groupId>maven</groupId> <groupId>maven</groupId>
<artifactId>maven-pdf-plugin</artifactId> <artifactId>maven-pdf-plugin</artifactId>
<id>maven-pdf-plugin</id> <id>maven-pdf-plugin</id>
<name>Maven PDF Plug-in</name> <name>Maven PDF Plug-in</name>
<currentVersion>2.0-SNAPSHOT</currentVersion> <currentVersion>2.0-SNAPSHOT</currentVersion>
<description/> <description/>
<shortDescription>Java Project Management Tools</shortDescription> <shortDescription>Java Project Management Tools</shortDescription>
<url>http://maven.apache.org/reference/plugins/pdf/</url> <url>http://maven.apache.org/reference/plugins/pdf/</url>
<siteDirectory>/www/maven.apache.org/reference/plugins/pdf/</siteDirectory> <siteDirectory>/www/maven.apache.org/reference/plugins/pdf/</siteDirectory>
<issueTrackingUrl>http://jira.codehaus.org/secure/BrowseProject.jspa?id=10356</issueTrackingUrl> <issueTrackingUrl>http://jira.codehaus.org/secure/BrowseProject.jspa?id=10356</issueTrackingUrl>
<repository> <repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/pdf/</connection> <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/pdf/</connection>
<url>http://cvs.apache.org/viewcvs/maven-plugins/pdf/</url> <url>http://cvs.apache.org/viewcvs/maven-plugins/pdf/</url>
</repository> </repository>
<developers> <developers>
<developer> <developer>
<name>dIon Gillard</name> <name>dIon Gillard</name>
<id>dion</id> <id>dion</id>
<email>dion@multitask.com.au</email> <email>dion@multitask.com.au</email>
<organization>Multitask Consulting</organization> <organization>Multitask Consulting</organization>
<roles> <roles>
<role>Documentation</role> <role>Documentation</role>
</roles> </roles>
</developer> </developer>
<developer> <developer>
<name>Jason van Zyl</name> <name>Jason van Zyl</name>
<id>jvanzyl</id> <id>jvanzyl</id>
<email>jason@zenplex.com</email> <email>jason@zenplex.com</email>
<organization>Zenplex</organization> <organization>Zenplex</organization>
<roles> <roles>
<role>Architect</role> <role>Architect</role>
<role>Release Manager</role> <role>Release Manager</role>
</roles> </roles>
</developer> </developer>
</developers> <developer>
<contributors> <name>Emmanuel Venisse</name>
<contributor> <id>evenisse</id>
<name>Andrew Jaquith</name> <email>emmanuel@venisse.net</email>
<email>arjaquith@mindspring.com</email> <organization></organization>
<organization>freshcookies.org</organization> <roles>
</contributor> <role>Java Developer</role>
</contributors> </roles>
<dependencies> </developer>
<dependency> </developers>
<groupId>fop</groupId> <contributors>
<artifactId>fop</artifactId> <contributor>
<version>0.20.5</version> <name>Andrew Jaquith</name>
</dependency> <email>arjaquith@mindspring.com</email>
<dependency> <organization>freshcookies.org</organization>
<groupId>batik</groupId> </contributor>
<artifactId>batik</artifactId> <contributor>
<version>1.5-fop-0.20-5</version> <name>Arnaud Heritier</name>
</dependency> <email></email>
<dependency> <organization></organization>
<groupId>logkit</groupId> </contributor>
<artifactId>logkit</artifactId> </contributors>
<version>1.0.1</version> <dependencies>
</dependency> <dependency>
<dependency> <groupId>fop</groupId>
<groupId>avalon-framework</groupId> <artifactId>fop</artifactId>
<artifactId>avalon-framework</artifactId> <version>0.20.5</version>
<version>4.0</version> </dependency>
</dependency> <dependency>
<dependency> <groupId>batik</groupId>
<groupId>xerces</groupId> <artifactId>batik</artifactId>
<artifactId>xerces</artifactId> <version>1.5-fop-0.20-5</version>
<version>2.3.0</version> </dependency>
<properties> <dependency>
<classloader>root</classloader> <groupId>logkit</groupId>
</properties> <artifactId>logkit</artifactId>
</dependency> <version>1.0.1</version>
<dependency> </dependency>
<groupId>xml-apis</groupId> <dependency>
<artifactId>xml-apis</artifactId> <groupId>avalon-framework</groupId>
<version>1.0.b2</version> <artifactId>avalon-framework</artifactId>
<properties> <version>4.0</version>
<classloader>root</classloader> </dependency>
</properties> <dependency>
</dependency> <groupId>xerces</groupId>
<dependency> <artifactId>xerces</artifactId>
<groupId>xalan</groupId> <version>2.3.0</version>
<artifactId>xalan</artifactId> <properties>
<version>2.4.1</version> <classloader>root</classloader>
</dependency> </properties>
</dependencies> </dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.0.b2</version>
<properties>
<classloader>root</classloader>
</properties>
</dependency>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>
</project> </project>

File diff suppressed because it is too large Load Diff

View File

@ -1,230 +1,373 @@
<?xml version='1.0' encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
xmlns:fo="http://www.w3.org/1999/XSL/Format" version='1.0'> <!-- This is a dummy entry -->
<xsl:variable name="masklookup">----------111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"</xsl:variable>
<!-- This is a dummy entry --> <xsl:variable name="columnWidths"> 5? 5? 5? 5? 5? 5? 5? 5? 5? 5?</xsl:variable>
<xsl:variable name="masklookup">----------111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"</xsl:variable> <xsl:template name="calculate-column-widths">
<xsl:variable name="columnWidths"> 5? 5? 5? 5? 5? 5? 5? 5? 5? 5?</xsl:variable> <xsl:param name="row">1</xsl:param>
<xsl:param name="col">1</xsl:param>
<xsl:template name="calculate-column-widths"> <xsl:param name="mask"> ----------</xsl:param>
<xsl:param name="row">1</xsl:param> <xsl:param name="nextmask"> ----------</xsl:param>
<xsl:param name="col">1</xsl:param> <xsl:param name="widths" select="$columnWidths"/>
<xsl:param name="mask"> ----------</xsl:param> <!-- Get current row and column based on (row,col) parameters -->
<xsl:param name="nextmask"> ----------</xsl:param> <xsl:variable name="currentRow" select="thead/tr[position()=$row]"/>
<xsl:param name="widths" select="$columnWidths"/> <xsl:variable name="currentCol" select="thead/tr[position()=$row]/th[position()=$col]"/>
<!-- Get current row and column based on (row,col) parameters --> <!-- Determine the row/colspans for the current cell
<xsl:variable name="currentRow"
select="thead/tr[position()=$row]"/>
<xsl:variable name="currentCol"
select="thead/tr[position()=$row]/th[position()=$col]"/>
<!-- Determine the row/colspans for the current cell
If not specified, they default to 1 --> If not specified, they default to 1 -->
<xsl:variable name="colspan"> <xsl:variable name="colspan">
<xsl:choose> <xsl:choose>
<xsl:when test="$currentCol/@colspan"><xsl:value-of select="$currentCol/@colspan"/></xsl:when> <xsl:when test="$currentCol/@colspan">
<xsl:otherwise>1</xsl:otherwise> <xsl:value-of select="$currentCol/@colspan"/>
</xsl:choose> </xsl:when>
</xsl:variable> <xsl:otherwise>1</xsl:otherwise>
<xsl:variable name="rowspan"> </xsl:choose>
<xsl:choose> </xsl:variable>
<xsl:when test="$currentCol/@rowspan"><xsl:value-of select="$currentCol/@rowspan"/></xsl:when> <xsl:variable name="rowspan">
<xsl:otherwise>1</xsl:otherwise> <xsl:choose>
</xsl:choose> <xsl:when test="$currentCol/@rowspan">
</xsl:variable> <xsl:value-of select="$currentCol/@rowspan"/>
<!-- Based on the current row mask, determine where to insert the current cell mask --> </xsl:when>
<xsl:variable name="insmask-row"> <xsl:otherwise>1</xsl:otherwise>
<xsl:value-of select="substring($masklookup, $rowspan *10+1, $colspan)"/> </xsl:choose>
</xsl:variable> </xsl:variable>
<xsl:variable name="insmask-nextrow"> <!-- Based on the current row mask, determine where to insert the current cell mask -->
<xsl:value-of select="substring($masklookup, ($rowspan - 1)*10+1, $colspan)"/> <xsl:variable name="insmask-row">
</xsl:variable> <xsl:value-of select="substring($masklookup, $rowspan *10+1, $colspan)"/>
<xsl:variable name="ins"> </xsl:variable>
<xsl:value-of select="string-length(substring-before($mask,'-')) + 1"/> <xsl:variable name="insmask-nextrow">
</xsl:variable> <xsl:value-of select="substring($masklookup, ($rowspan - 1)*10+1, $colspan)"/>
<!-- If this cell has a width attribute, extract it and normalize to one column. </xsl:variable>
<xsl:variable name="ins">
<xsl:value-of select="string-length(substring-before($mask,'-')) + 1"/>
</xsl:variable>
<!-- If this cell has a width attribute, extract it and normalize to one column.
Also, pad it to three characters wide. If the current column is more than one Also, pad it to three characters wide. If the current column is more than one
column wide, append the padded width with a '?' so that it can be overridden. --> column wide, append the padded width with a '?' so that it can be overridden. -->
<xsl:variable name="cellwidthRaw"> <xsl:variable name="cellwidthRaw">
<xsl:choose> <xsl:choose>
<xsl:when test="$currentCol/@width"> <xsl:when test="$currentCol/@width">
<xsl:if test="contains($currentCol/@width,'%')"> <xsl:if test="contains($currentCol/@width,'%')">
<xsl:value-of select="substring-before($currentCol/@width,'%') div $colspan"/> <xsl:value-of select="substring-before($currentCol/@width,'%') div $colspan"/>
</xsl:if> </xsl:if>
</xsl:when> </xsl:when>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<xsl:variable name="cellwidth"> <xsl:variable name="cellwidth">
<xsl:if test="$cellwidthRaw &gt; 0"> <xsl:if test="$cellwidthRaw &gt; 0">
<xsl:choose> <xsl:choose>
<xsl:when test="$colspan = 1"> <xsl:when test="$colspan = 1">
<xsl:value-of select="concat(substring(' ', 1, 3 - string-length(round($cellwidthRaw))), round($cellwidthRaw), ' ')"/> <xsl:value-of select="concat(substring(' ', 1, 3 - string-length(round($cellwidthRaw))), round($cellwidthRaw), ' ')"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="concat(substring(' ', 1, 3 - string-length(round($cellwidthRaw))), round($cellwidthRaw), '?')"/> <xsl:value-of select="concat(substring(' ', 1, 3 - string-length(round($cellwidthRaw))), round($cellwidthRaw), '?')"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:if> </xsl:if>
</xsl:variable> </xsl:variable>
<!-- Create a width 'mask' that repeats the width string i times, where i is the <!-- Create a width 'mask' that repeats the width string i times, where i is the
number of columns spanned --> number of columns spanned -->
<xsl:variable name="cellwidthmaskRaw"> <xsl:variable name="cellwidthmaskRaw">
<xsl:value-of select="translate('abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd', 'abcd',$cellwidth)"/> <xsl:value-of select="translate('abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd', 'abcd',$cellwidth)"/>
</xsl:variable> </xsl:variable>
<xsl:variable name="cellwidthmask"> <xsl:variable name="cellwidthmask">
<xsl:value-of select="substring($cellwidthmaskRaw, 1, $colspan * 4)"/> <xsl:value-of select="substring($cellwidthmaskRaw, 1, $colspan * 4)"/>
</xsl:variable> </xsl:variable>
<!-- Insert the cell width, if supplied, into the registry --> <!-- Insert the cell width, if supplied, into the registry -->
<xsl:variable name="widths2"> <xsl:variable name="widths2">
<xsl:choose> <xsl:choose>
<xsl:when test="$cellwidthRaw &gt; 0 and substring($widths, ($ins - 2)*4+4, 1) = '?'"> <xsl:when test="$cellwidthRaw &gt; 0 and substring($widths, ($ins - 2)*4+4, 1) = '?'">
<xsl:value-of select="concat(substring($widths, 1, ($ins - 2)*4), <xsl:value-of select="concat(substring($widths, 1, ($ins - 2)*4),
$cellwidthmask, $cellwidthmask,
substring($widths, ($ins - 2 + $colspan)*4+1))"/> substring($widths, ($ins - 2 + $colspan)*4+1))"/>
</xsl:when> </xsl:when>
<xsl:otherwise><xsl:value-of select="$widths"/></xsl:otherwise> <xsl:otherwise>
</xsl:choose> <xsl:value-of select="$widths"/>
</xsl:variable> </xsl:otherwise>
<!-- Revise the the current row's mask by inserting </xsl:choose>
</xsl:variable>
<!-- Revise the the current row's mask by inserting
a digit j (repeated k times) into the first available space in the a digit j (repeated k times) into the first available space in the
mask. J represents the number of rowspans for the current cell mask. J represents the number of rowspans for the current cell
the supplied masks. We insert the same number of j into the next row's the supplied masks. We insert the same number of j into the next row's
mask also. --> mask also. -->
<xsl:variable name="mask2"> <xsl:variable name="mask2">
<xsl:value-of select="concat(substring($mask, 1, $ins - 1), <xsl:value-of select="concat(substring($mask, 1, $ins - 1),
$insmask-row, $insmask-row,
substring($mask, $ins + $colspan))"/> substring($mask, $ins + $colspan))"/>
</xsl:variable> </xsl:variable>
<xsl:variable name="nextmask2"> <xsl:variable name="nextmask2">
<xsl:value-of select="concat(substring($nextmask, 1, $ins - 1), <xsl:value-of select="concat(substring($nextmask, 1, $ins - 1),
$insmask-nextrow, $insmask-nextrow,
substring($nextmask, $ins + $colspan))"/> substring($nextmask, $ins + $colspan))"/>
</xsl:variable> </xsl:variable>
<!-- Print debugging information --> <!-- Print debugging information -->
<xsl:if test="$debug = 'true'">
<xsl:message>Cell (<xsl:value-of select="$row"/>,<xsl:value-of select="$col"/>) text()='<xsl:value-of select="normalize-space($currentCol)"/>' rowspan=<xsl:value-of select="$rowspan"/> colspan=<xsl:value-of select="$colspan"/> width=<xsl:value-of select="normalize-space($cellwidthRaw * $colspan)"/></xsl:message>
<xsl:message> Current cell mask : <xsl:value-of select="$mask"/>in <xsl:value-of select="$mask2"/>out</xsl:message>
<xsl:message> Next row mask : <xsl:value-of select="$nextmask"/>in <xsl:value-of select="$nextmask2"/>out</xsl:message>
<xsl:message> Estimated cell widths: <xsl:value-of select="$cellwidthmask"/></xsl:message>
<xsl:message> Cell widths so far : <xsl:value-of select="$widths2"/></xsl:message>
</xsl:if>
<!-- What to do next? -->
<xsl:choose>
<xsl:when test="thead/tr[position()=$row]/th[position()=$col+1]">
<xsl:call-template name="calculate-column-widths">
<xsl:with-param name="row" select="$row"/>
<xsl:with-param name="col" select="$col+1"/>
<xsl:with-param name="mask" select="$mask2"/>
<xsl:with-param name="nextmask" select="$nextmask2"/>
<xsl:with-param name="widths" select="$widths2"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="thead/tr[position()=$row+1]">
<xsl:call-template name="calculate-column-widths">
<xsl:with-param name="row" select="$row+1"/>
<xsl:with-param name="col" select="1"/>
<xsl:with-param name="mask" select="translate($mask2, '123456789', '-12345678')"/>
<xsl:with-param name="widths" select="$widths2"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="totals">
<xsl:with-param name="columns"
select="string-length(substring-before(concat($mask2,'-'),'-'))-1"/>
<xsl:with-param name="widths" select="$widths2"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="totals">
<xsl:param name="col">1</xsl:param>
<xsl:param name="columns">1</xsl:param>
<xsl:param name="widths"> 1?</xsl:param>
<xsl:param name="sumwidths">0</xsl:param>
<xsl:param name="softColumns">0</xsl:param>
<xsl:variable name="colwidth" select="substring($widths, ($col - 1)*4+1 , 3)"/>
<!-- If we find something ('?') in the 4th position, it's a soft column -->
<xsl:variable name="softColumn">
<xsl:choose>
<xsl:when test="normalize-space(substring($widths, ($col - 1)*4+4, 1))">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="leftover">
<xsl:choose>
<xsl:when test="$sumwidths &gt; 100">
<xsl:value-of select="0"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="100 - $sumwidths"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$col &lt;= $columns">
<xsl:call-template name="totals">
<xsl:with-param name="col" select="$col + 1"/>
<xsl:with-param name="columns" select="$columns"/>
<xsl:with-param name="widths" select="$widths"/>
<xsl:with-param name="sumwidths" select="$sumwidths + $colwidth"/>
<xsl:with-param name="softColumns" select="$softColumns + $softColumn"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:if test="$debug = 'true'"> <xsl:if test="$debug = 'true'">
<xsl:message>Columns= <xsl:value-of select="$columns"/> (<xsl:value-of select="$softColumns"/> resizable), width=<xsl:value-of select="$sumwidths"/>, leftover=<xsl:value-of select="$leftover"/></xsl:message> <xsl:message>Cell (<xsl:value-of select="$row"/>,<xsl:value-of select="$col"/>) text()='<xsl:value-of select="normalize-space($currentCol)"/>' rowspan=<xsl:value-of select="$rowspan"/> colspan=<xsl:value-of select="$colspan"/> width=<xsl:value-of select="normalize-space($cellwidthRaw * $colspan)"/>
</xsl:message>
<xsl:message> Current cell mask : <xsl:value-of select="$mask"/>in <xsl:value-of select="$mask2"/>out</xsl:message>
<xsl:message> Next row mask : <xsl:value-of select="$nextmask"/>in <xsl:value-of select="$nextmask2"/>out</xsl:message>
<xsl:message> Estimated cell widths: <xsl:value-of select="$cellwidthmask"/>
</xsl:message>
<xsl:message> Cell widths so far : <xsl:value-of select="$widths2"/>
</xsl:message>
</xsl:if> </xsl:if>
<xsl:call-template name="print-columns"> <!-- What to do next? -->
<xsl:with-param name="columns" select="$columns"/> <xsl:choose>
<xsl:with-param name="widths" select="$widths"/> <xsl:when test="thead/tr[position()=$row]/th[position()=$col+1]">
<xsl:with-param name="sumwidths" select="$sumwidths + $leftover"/> <xsl:call-template name="calculate-column-widths">
<xsl:with-param name="adjust" select="$leftover div $softColumns"/> <xsl:with-param name="row" select="$row"/>
<xsl:with-param name="softColumns" select="$softColumns"/> <xsl:with-param name="col" select="$col+1"/>
</xsl:call-template> <xsl:with-param name="mask" select="$mask2"/>
</xsl:otherwise> <xsl:with-param name="nextmask" select="$nextmask2"/>
</xsl:choose> <xsl:with-param name="widths" select="$widths2"/>
</xsl:template> </xsl:call-template>
</xsl:when>
<xsl:template name="print-columns"> <xsl:otherwise>
<xsl:param name="col">1</xsl:param> <xsl:choose>
<xsl:param name="columns">1</xsl:param> <xsl:when test="thead/tr[position()=$row+1]">
<xsl:param name="widths"> 1?</xsl:param> <xsl:call-template name="calculate-column-widths">
<xsl:param name="sumwidths">0</xsl:param> <xsl:with-param name="row" select="$row+1"/>
<xsl:param name="adjust">0</xsl:param> <xsl:with-param name="col" select="1"/>
<xsl:param name="softColumns">1</xsl:param> <xsl:with-param name="mask" select="translate($mask2, '123456789', '-12345678')"/>
<xsl:variable name="colwidth" select="substring($widths, ($col - 1)*4+1 , 3)"/> <xsl:with-param name="widths" select="$widths2"/>
<xsl:variable name="colwidth2"> </xsl:call-template>
<xsl:choose> </xsl:when>
<xsl:when test="normalize-space(substring($widths, ($col - 1)*4+4, 1))"> <xsl:otherwise>
<xsl:value-of select="$colwidth + $adjust"/> <xsl:call-template name="totals">
</xsl:when> <xsl:with-param name="columns" select="string-length(substring-before(concat($mask2,'-'),'-'))-1"/>
<xsl:otherwise> <xsl:with-param name="widths" select="$widths2"/>
<xsl:value-of select="$colwidth"/> </xsl:call-template>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:otherwise>
<!-- And now, the moment we've all been waiting for --> </xsl:choose>
<fo:table-column> </xsl:template>
<xsl:attribute name="column-width"> <xsl:template name="totals">
<xsl:value-of select="$colwidth2 div $sumwidths * $maxTableWidth"/>in <xsl:param name="col">1</xsl:param>
<xsl:param name="columns">1</xsl:param>
<xsl:param name="widths"> 1?</xsl:param>
<xsl:param name="sumwidths">0</xsl:param>
<xsl:param name="softColumns">0</xsl:param>
<xsl:variable name="colwidth" select="substring($widths, ($col - 1)*4+1 , 3)"/>
<!-- If we find something ('?') in the 4th position, it's a soft column -->
<xsl:variable name="softColumn">
<xsl:choose>
<xsl:when test="normalize-space(substring($widths, ($col - 1)*4+4, 1))">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="leftover">
<xsl:choose>
<xsl:when test="$sumwidths &gt; 100">
<xsl:value-of select="0"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="100 - $sumwidths"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$col &lt;= $columns">
<xsl:call-template name="totals">
<xsl:with-param name="col" select="$col + 1"/>
<xsl:with-param name="columns" select="$columns"/>
<xsl:with-param name="widths" select="$widths"/>
<xsl:with-param name="sumwidths" select="$sumwidths + $colwidth"/>
<xsl:with-param name="softColumns" select="$softColumns + $softColumn"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:if test="$debug = 'true'">
<xsl:message>Columns= <xsl:value-of select="$columns"/> (<xsl:value-of select="$softColumns"/> resizable), width=<xsl:value-of select="$sumwidths"/>, leftover=<xsl:value-of select="$leftover"/>
</xsl:message>
</xsl:if>
<xsl:call-template name="print-columns">
<xsl:with-param name="columns" select="$columns"/>
<xsl:with-param name="widths" select="$widths"/>
<xsl:with-param name="sumwidths" select="$sumwidths + $leftover"/>
<xsl:with-param name="adjust" select="$leftover div $softColumns"/>
<xsl:with-param name="softColumns" select="$softColumns"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="print-columns">
<xsl:param name="col">1</xsl:param>
<xsl:param name="columns">1</xsl:param>
<xsl:param name="widths"> 1?</xsl:param>
<xsl:param name="sumwidths">0</xsl:param>
<xsl:param name="adjust">0</xsl:param>
<xsl:param name="softColumns">1</xsl:param>
<xsl:variable name="colwidth" select="substring($widths, ($col - 1)*4+1 , 3)"/>
<xsl:variable name="colwidth2">
<xsl:choose>
<xsl:when test="normalize-space(substring($widths, ($col - 1)*4+4, 1))">
<xsl:value-of select="$colwidth + $adjust"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$colwidth"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- And now, the moment we've all been waiting for -->
<fo:table-column>
<xsl:attribute name="column-width"><xsl:value-of select="$colwidth2 div $sumwidths * $maxTableWidth"/>in
</xsl:attribute> </xsl:attribute>
</fo:table-column> </fo:table-column>
<!-- Loop to the next column --> <!-- Loop to the next column -->
<xsl:choose> <xsl:choose>
<xsl:when test="$col &lt; $columns"> <xsl:when test="$col &lt; $columns">
<xsl:call-template name="print-columns"> <xsl:call-template name="print-columns">
<xsl:with-param name="col" select="$col + 1"/> <xsl:with-param name="col" select="$col + 1"/>
<xsl:with-param name="columns" select="$columns"/> <xsl:with-param name="columns" select="$columns"/>
<xsl:with-param name="widths" select="$widths"/> <xsl:with-param name="widths" select="$widths"/>
<xsl:with-param name="sumwidths" select="$sumwidths"/> <xsl:with-param name="sumwidths" select="$sumwidths"/>
<xsl:with-param name="adjust" select="$adjust"/> <xsl:with-param name="adjust" select="$adjust"/>
<xsl:with-param name="softColumns" select="$softColumns"/> <xsl:with-param name="softColumns" select="$softColumns"/>
</xsl:call-template> </xsl:call-template>
</xsl:when> </xsl:when>
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
<!-- Calculate column widths for tables without thead -->
<xsl:template name="html-calculate-column-widths">
<xsl:param name="row">1</xsl:param>
<xsl:param name="col">1</xsl:param>
<xsl:param name="mask"> ----------</xsl:param>
<xsl:param name="nextmask"> ----------</xsl:param>
<xsl:param name="widths" select="$columnWidths"/>
<!-- Get current row and column based on (row,col) parameters -->
<xsl:variable name="currentRow" select="tr[position()=$row]"/>
<xsl:variable name="currentCol" select="tr[position()=$row]/th[position()=$col]|tr[position()=$row]/td[position()=$col]"/>
<!-- Determine the row/colspans for the current cell
If not specified, they default to 1 -->
<xsl:variable name="colspan">
<xsl:choose>
<xsl:when test="$currentCol/@colspan">
<xsl:value-of select="$currentCol/@colspan"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rowspan">
<xsl:choose>
<xsl:when test="$currentCol/@rowspan">
<xsl:value-of select="$currentCol/@rowspan"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Based on the current row mask, determine where to insert the current cell mask -->
<xsl:variable name="insmask-row">
<xsl:value-of select="substring($masklookup, $rowspan *10+1, $colspan)"/>
</xsl:variable>
<xsl:variable name="insmask-nextrow">
<xsl:value-of select="substring($masklookup, ($rowspan - 1)*10+1, $colspan)"/>
</xsl:variable>
<xsl:variable name="ins">
<xsl:value-of select="string-length(substring-before($mask,'-')) + 1"/>
</xsl:variable>
<!-- If this cell has a width attribute, extract it and normalize to one column.
Also, pad it to three characters wide. If the current column is more than one
column wide, append the padded width with a '?' so that it can be overridden. -->
<xsl:variable name="cellwidthRaw">
<xsl:choose>
<xsl:when test="$currentCol/@width">
<xsl:if test="contains($currentCol/@width,'%')">
<xsl:value-of select="substring-before($currentCol/@width,'%') div $colspan"/>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="cellwidth">
<xsl:if test="$cellwidthRaw &gt; 0">
<xsl:choose>
<xsl:when test="$colspan = 1">
<xsl:value-of select="concat(substring(' ', 1, 3 - string-length(round($cellwidthRaw))), round($cellwidthRaw), ' ')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(substring(' ', 1, 3 - string-length(round($cellwidthRaw))), round($cellwidthRaw), '?')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:variable>
<!-- Create a width 'mask' that repeats the width string i times, where i is the
number of columns spanned -->
<xsl:variable name="cellwidthmaskRaw">
<xsl:value-of select="translate('abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd', 'abcd',$cellwidth)"/>
</xsl:variable>
<xsl:variable name="cellwidthmask">
<xsl:value-of select="substring($cellwidthmaskRaw, 1, $colspan * 4)"/>
</xsl:variable>
<!-- Insert the cell width, if supplied, into the registry -->
<xsl:variable name="widths2">
<xsl:choose>
<xsl:when test="$cellwidthRaw &gt; 0 and substring($widths, ($ins - 2)*4+4, 1) = '?'">
<xsl:value-of select="concat(substring($widths, 1, ($ins - 2)*4),
$cellwidthmask,
substring($widths, ($ins - 2 + $colspan)*4+1))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$widths"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Revise the the current row's mask by inserting
a digit j (repeated k times) into the first available space in the
mask. J represents the number of rowspans for the current cell
the supplied masks. We insert the same number of j into the next row's
mask also. -->
<xsl:variable name="mask2">
<xsl:value-of select="concat(substring($mask, 1, $ins - 1),
$insmask-row,
substring($mask, $ins + $colspan))"/>
</xsl:variable>
<xsl:variable name="nextmask2">
<xsl:value-of select="concat(substring($nextmask, 1, $ins - 1),
$insmask-nextrow,
substring($nextmask, $ins + $colspan))"/>
</xsl:variable>
<!-- Print debugging information -->
<xsl:if test="$debug = 'true'">
<xsl:message>Cell (<xsl:value-of select="$row"/>,<xsl:value-of select="$col"/>) text()='<xsl:value-of select="normalize-space($currentCol)"/>' rowspan=<xsl:value-of select="$rowspan"/> colspan=<xsl:value-of select="$colspan"/> width=<xsl:value-of select="normalize-space($cellwidthRaw * $colspan)"/>
</xsl:message>
<xsl:message> Current cell mask : <xsl:value-of select="$mask"/>in <xsl:value-of select="$mask2"/>out</xsl:message>
<xsl:message> Next row mask : <xsl:value-of select="$nextmask"/>in <xsl:value-of select="$nextmask2"/>out</xsl:message>
<xsl:message> Estimated cell widths: <xsl:value-of select="$cellwidthmask"/>
</xsl:message>
<xsl:message> Cell widths so far : <xsl:value-of select="$widths2"/>
</xsl:message>
</xsl:if>
<!-- What to do next? -->
<xsl:choose>
<xsl:when test="tr[position()=$row]/th[position()=$col+1]|tr[position()=$row]/td[position()=$col+1]">
<xsl:call-template name="html-calculate-column-widths">
<xsl:with-param name="row" select="$row"/>
<xsl:with-param name="col" select="$col+1"/>
<xsl:with-param name="mask" select="$mask2"/>
<xsl:with-param name="nextmask" select="$nextmask2"/>
<xsl:with-param name="widths" select="$widths2"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="tr[position()=$row+1]">
<xsl:call-template name="html-calculate-column-widths">
<xsl:with-param name="row" select="$row+1"/>
<xsl:with-param name="col" select="1"/>
<xsl:with-param name="mask" select="translate($mask2, '123456789', '-12345678')"/>
<xsl:with-param name="widths" select="$widths2"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="totals">
<xsl:with-param name="columns" select="string-length(substring-before(concat($mask2,'-'),'-'))-1"/>
<xsl:with-param name="widths" select="$widths2"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View File

@ -141,12 +141,221 @@ xmlns:fo="http://www.w3.org/1999/XSL/Format" version='1.0'>
<!-- Table rendering --> <!-- Table rendering -->
<!--
<xsl:template match="table[count(thead)=0]"> <xsl:template match="table[count(thead)=0]">
<fo:block xsl:use-attribute-sets="error.block"> <fo:block xsl:use-attribute-sets="error.block">
Warning: the supplied &lt;table&gt; did not contain a &lt;thead&gt; element. It was excluded from the generated XSL:FO file. Warning: the supplied &lt;table&gt; did not contain a &lt;thead&gt; element. It was excluded from the generated XSL:FO file.
</fo:block> </fo:block>
</xsl:template> </xsl:template>
-->
<!-- HTML tables generation without THEAD and TBODY -->
<xsl:template match="table[count(thead)=0]" name="html-find-max-columns">
<!-- Before we do anything, we need to scan the table to find the maximum span -->
<xsl:param name="row">1</xsl:param>
<xsl:param name="maxColumns">1</xsl:param>
<!-- Get current row based on $row parameter -->
<xsl:variable name="currentRow" select="tr[position()=$row]"/>
<!-- Calculate the number of columns in this row. This will be the number
of th cells that don't have @colspan attributes, plus the sum of all
@colspan attributes in th cells that have them.
This algorithm isn't foolproof, because table headers with overlapping
rowspans could hose the counting under certain conditions.
-->
<xsl:variable name="nColumns" select="count($currentRow/th) + count($currentRow/tr) + sum($currentRow/th/@colspan) + sum($currentRow/tr/@colspan) - count($currentRow/th/@colspan) - count($currentRow/tr/@colspan)"/>
<xsl:variable name="newMaxColumns">
<xsl:choose>
<xsl:when test="$nColumns &gt; $maxColumns"><xsl:value-of select="$nColumns"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$maxColumns"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Iterate through the template again if there are more rows -->
<xsl:choose>
<xsl:when test="tr[position()=$row+1]">
<xsl:call-template name="html-find-max-columns">
<xsl:with-param name="row" select="$row+1"/>
<xsl:with-param name="maxColumns" select="$newMaxColumns"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="html-print-table">
<xsl:with-param name="spacerSpanColumns" select="$newMaxColumns"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="table3" name="html-print-table">
<xsl:param name="spacerSpanColumns">1</xsl:param>
<xsl:comment> :::::: New table :::::: </xsl:comment>
<fo:block xsl:use-attribute-sets="table.padding">
<fo:table table-layout="fixed" table-omit-footer-at-break="false">
<!-- The next template calculates table column widths e.g.,...
<fo:table-column column-width="1.25in"/>
<fo:table-column column-width="5.0in"/>
-->
<xsl:call-template name="html-calculate-column-widths" />
<fo:table-header>
<!-- If there is a 'title' attribute, output a title row -->
<xsl:if test="@title">
<xsl:comment> This table has a @title, so add a row for it </xsl:comment>
<fo:table-row keep-together="always" keep-with-next="always">
<fo:table-cell number-columns-spanned="{$spacerSpanColumns}" xsl:use-attribute-sets="table.title.cell">
<fo:block xsl:use-attribute-sets="table.title.block"><xsl:value-of select="@title"/></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
</fo:table-header>
<!-- If there is a caption element, output a table-footer -->
<fo:table-footer>
<!-- If there is a caption, add it -->
<xsl:if test="caption">
<xsl:comment> This table has a caption, so add a row for it </xsl:comment>
<fo:table-row>
<fo:table-cell number-columns-spanned="{$spacerSpanColumns}" xsl:use-attribute-sets="table.footer.cell">
<fo:block xsl:use-attribute-sets="table.footer.block">
<xsl:value-of select="caption"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<!-- Put in a sequential table number -->
<!--
<fo:table-row>
<fo:table-cell number-columns-spanned="{$spacerSpanColumns}" xsl:use-attribute-sets="table.number.cell">
<fo:block xsl:use-attribute-sets="table.number.block">
Table <xsl:value-of select="count(preceding-sibling::table) + 1"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
-->
</fo:table-footer>
<!-- Process any tbody/tr or tr records -->
<fo:table-body>
<xsl:apply-templates select="tr" mode="html-table">
<xsl:with-param name="spacerSpanColumns" select="$spacerSpanColumns"/>
</xsl:apply-templates>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>
<xsl:template match="tr[th]" mode="html-table">
<xsl:comment> ::: Subheading row ::: </xsl:comment>
<!-- Changed from table.body.row (a bug!) -->
<fo:table-row xsl:use-attribute-sets="table.subheading.row">
<xsl:apply-templates select="th|td" mode="html-table"/>
</fo:table-row>
</xsl:template>
<xsl:template match="tr[last()]" mode="html-table">
<xsl:param name="spacerSpanColumns">1</xsl:param>
<xsl:variable name="nColumns" select="count(th|td) + sum(th/@colspan|td/@colspan) - count(th/@colspan|td/@colspan)"/>
<!-- Format the table row -->
<xsl:comment> ::: Table body row <xsl:value-of select="position()"/> (<xsl:value-of select="$nColumns"/> columns) ::: </xsl:comment>
<fo:table-row xsl:use-attribute-sets="table.body.row">
<xsl:apply-templates select="th|td" mode="html-table"/>
</fo:table-row>
<!-- Add a spacer/border row: last row rule -->
<xsl:comment> ::: Table row spacer for last row ::: </xsl:comment>
<fo:table-row keep-with-previous="always">
<fo:table-cell padding-after="3pt" number-columns-spanned="{$spacerSpanColumns}">
<fo:block line-height="1pt">
<xsl:comment> Ending border (solid rule) </xsl:comment>
<fo:leader xsl:use-attribute-sets="table.body.lastrule"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="tr" mode="html-table">
<xsl:param name="spacerSpanColumns">1</xsl:param>
<xsl:param name="nextRow" select="following-sibling::tr[1]"/>
<xsl:variable name="nColumns" select="count($nextRow/th | $nextRow/td)
+ sum($nextRow/th/@colspan |$nextRow/td/@colspan)
- count($nextRow/th/@colspan | $nextRow/td/@colspan)"/>
<!-- Table body rows work as follows:
- If the current row is not followed by a 'subheading' row,
add a bottom border
- If the current row is also the last row, add a
'final' bottom border, otherwise a 'normal' bottom border
- Otherwise, do not add a bottom border
- Process the row by building table cells one at a time
-->
<!-- Format the table row -->
<xsl:comment> ::: Table body row <xsl:value-of select="position()"/> (<xsl:value-of select="$nColumns"/> columns) ::: </xsl:comment>
<fo:table-row xsl:use-attribute-sets="table.body.row">
<xsl:apply-templates select="th|td" mode="html-table"/>
</fo:table-row>
<!-- Add in a spacer/border row -->
<xsl:comment> ::: Table row spacer for row <xsl:value-of select="position()"/> ::: </xsl:comment>
<fo:table-row keep-with-previous="always">
<fo:table-cell padding-after="3pt" number-columns-spanned="{$nColumns}">
<fo:block line-height="1pt">
<xsl:choose>
<!-- If next row contains a th; no border, 2pt padding, 1pt white rule -->
<xsl:when test="following-sibling::tr[1]/th">
<xsl:comment> Spacer only </xsl:comment>
<fo:leader xsl:use-attribute-sets="table.body.norule"/>
</xsl:when>
<!-- If a row follows; regular border -->
<xsl:when test="following-sibling::tr[1]">
<xsl:comment> Regular border (rule) </xsl:comment>
<fo:leader xsl:use-attribute-sets="table.body.rule"/>
</xsl:when>
<!-- Last row border -->
<xsl:otherwise>
<xsl:comment> Ending border (rule) </xsl:comment>
<fo:leader xsl:use-attribute-sets="table.body.lastrule"/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="th" mode="html-table">
<xsl:comment> : Table subheading cell : </xsl:comment>
<fo:table-cell xsl:use-attribute-sets="table.subheading.cell">
<xsl:apply-templates select="@colspan|@rowspan|@align" mode="html-table"/>
<fo:block xsl:use-attribute-sets="table.subheading.block">
<xsl:apply-templates/>
</fo:block>
</fo:table-cell>
</xsl:template>
<xsl:template match="td" mode="html-table">
<xsl:comment> : Table body cell <xsl:value-of select="position()"/> : </xsl:comment>
<fo:table-cell xsl:use-attribute-sets="table.body.cell">
<xsl:apply-templates select="@colspan|@rowspan|@align" mode="html-table"/>
<xsl:apply-templates select="*" mode="table"/>
<fo:block xsl:use-attribute-sets="table.body.block">
<xsl:apply-templates/>
</fo:block>
</fo:table-cell>
</xsl:template>
<xsl:template match="@align" mode="html-table">
<xsl:attribute name="text-align"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>
<xsl:template match="@colspan" mode="html-table">
<xsl:attribute name="number-columns-spanned"><xsl:value-of select="number(.)"/></xsl:attribute>
</xsl:template>
<xsl:template match="@rowspan" mode="html-table">
<xsl:attribute name="number-rows-spanned"><xsl:value-of select="number(.)"/></xsl:attribute>
</xsl:template>
<!-- HTML tables generation with THEAD and TBODY -->
<xsl:template match="table" name="find-max-columns"> <xsl:template match="table" name="find-max-columns">
<!-- Before we do anything, we need to scan the table to find the maximum span --> <!-- Before we do anything, we need to scan the table to find the maximum span -->
@ -405,4 +614,6 @@ xmlns:fo="http://www.w3.org/1999/XSL/Format" version='1.0'>
<xsl:attribute name="number-rows-spanned"><xsl:value-of select="number(.) * 2 - 1"/></xsl:attribute> <xsl:attribute name="number-rows-spanned"><xsl:value-of select="number(.) * 2 - 1"/></xsl:attribute>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View File

@ -1,216 +1,195 @@
<?xml version='1.0' encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
xmlns:fo="http://www.w3.org/1999/XSL/Format" version='1.0'> <!-- These attribute-sets are treated as 'styles,'
<!-- These attribute-sets are treated as 'styles,'
and are referenced in the templates below --> and are referenced in the templates below -->
<xsl:attribute-set name="toc.cell">
<xsl:attribute-set name="toc.cell"> <xsl:attribute name="display-align">after</xsl:attribute>
<xsl:attribute name="display-align">after</xsl:attribute> </xsl:attribute-set>
</xsl:attribute-set> <xsl:attribute-set name="toc.base.style">
<xsl:attribute name="font-family">Helvetica,sans-serif</xsl:attribute>
<xsl:attribute-set name="toc.base.style"> <xsl:attribute name="line-height">16pt</xsl:attribute>
<xsl:attribute name="font-family">Helvetica,sans-serif</xsl:attribute> <xsl:attribute name="text-align-last">start</xsl:attribute>
<xsl:attribute name="line-height">16pt</xsl:attribute> <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
<xsl:attribute name="text-align-last">start</xsl:attribute> </xsl:attribute-set>
<xsl:attribute name="wrap-option">no-wrap</xsl:attribute> <xsl:attribute-set name="toc.leader.style">
</xsl:attribute-set> <xsl:attribute name="leader-pattern">dots</xsl:attribute>
<xsl:attribute name="leader-pattern-width">5pt</xsl:attribute>
<xsl:attribute-set name="toc.leader.style"> <xsl:attribute name="color"><xsl:value-of select="$colorDarkGray"/></xsl:attribute>
<xsl:attribute name="leader-pattern">dots</xsl:attribute> </xsl:attribute-set>
<xsl:attribute name="leader-pattern-width">5pt</xsl:attribute> <xsl:attribute-set name="toc.number.style">
<xsl:attribute name="color"><xsl:value-of select="$colorDarkGray"/></xsl:attribute> <xsl:attribute name="font-size">9.5pt</xsl:attribute>
</xsl:attribute-set> <xsl:attribute name="text-align">end</xsl:attribute>
<xsl:attribute name="color"><xsl:value-of select="$colorMediumGray"/></xsl:attribute>
<xsl:attribute-set name="toc.number.style"> <xsl:attribute name="line-height">16pt</xsl:attribute>
<xsl:attribute name="font-size">9.5pt</xsl:attribute> <xsl:attribute name="end-indent">6pt</xsl:attribute>
<xsl:attribute name="text-align">end</xsl:attribute> </xsl:attribute-set>
<xsl:attribute name="color"><xsl:value-of select="$colorMediumGray"/></xsl:attribute> <xsl:attribute-set name="toc.h1.style" use-attribute-sets="toc.base.style">
<xsl:attribute name="line-height">16pt</xsl:attribute> <xsl:attribute name="font-size">12pt</xsl:attribute>
<xsl:attribute name="end-indent">6pt</xsl:attribute> <xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:attribute-set> <xsl:attribute name="space-before">18pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="toc.h1.style" use-attribute-sets="toc.base.style"> <xsl:attribute-set name="toc.h2.style" use-attribute-sets="toc.base.style">
<xsl:attribute name="font-size">12pt</xsl:attribute> <xsl:attribute name="font-size">9.5pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute> <xsl:attribute name="space-before">15pt</xsl:attribute>
<xsl:attribute name="space-before">18pt</xsl:attribute> <xsl:attribute name="space-before">3pt</xsl:attribute>
</xsl:attribute-set> </xsl:attribute-set>
<xsl:attribute-set name="toc.h3.style" use-attribute-sets="toc.base.style">
<xsl:attribute-set name="toc.h2.style" use-attribute-sets="toc.base.style"> <xsl:attribute name="font-size">9.5pt</xsl:attribute>
<xsl:attribute name="font-size">9.5pt</xsl:attribute> <xsl:attribute name="space-before">4pt</xsl:attribute>
<xsl:attribute name="space-before">15pt</xsl:attribute> </xsl:attribute-set>
<xsl:attribute name="space-before">3pt</xsl:attribute> <xsl:attribute-set name="toc.h4.style" use-attribute-sets="toc.base.style">
</xsl:attribute-set> <xsl:attribute name="font-size">9.5pt</xsl:attribute>
<xsl:attribute name="space-before">4pt</xsl:attribute>
<xsl:attribute-set name="toc.h3.style" use-attribute-sets="toc.base.style"> </xsl:attribute-set>
<xsl:attribute name="font-size">9.5pt</xsl:attribute> <!-- Templates for handling the TOC -->
<xsl:attribute name="space-before">4pt</xsl:attribute> <xsl:template name="fo-toc">
</xsl:attribute-set> <fo:page-sequence master-reference="toc" initial-page-number="1" format="i">
<!-- Render the header and footer -->
<xsl:attribute-set name="toc.h4.style" use-attribute-sets="toc.base.style"> <xsl:call-template name="body-header">
<xsl:attribute name="font-size">9.5pt</xsl:attribute> <xsl:with-param name="headerText" select="translate('Table of Contents', $lc, $uc)"/>
<xsl:attribute name="space-before">4pt</xsl:attribute> </xsl:call-template>
</xsl:attribute-set> <xsl:call-template name="body-footer">
<xsl:with-param name="footerText" select="translate($footerText, $lc, $uc)"/>
<!-- Templates for handling the TOC --> </xsl:call-template>
<fo:flow flow-name="xsl-region-body">
<xsl:template name="fo-toc"> <!-- Render the chapter heading -->
<fo:page-sequence master-reference="toc" initial-page-number="1" format="i"> <xsl:call-template name="body-chapter-heading">
<!-- Render the header and footer --> <xsl:with-param name="chapterNumber"/>
<xsl:call-template name="body-header"> <xsl:with-param name="chapter">Table of Contents</xsl:with-param>
<xsl:with-param name="headerText" select="translate('Table of Contents', $lc, $uc)"/> </xsl:call-template>
</xsl:call-template> <fo:table layout="fixed">
<xsl:call-template name="body-footer"> <fo:table-column column-width="0.25in"/>
<xsl:with-param name="footerText" select="translate($footerText, $lc, $uc)"/> <fo:table-column column-width="0.4in"/>
</xsl:call-template> <fo:table-column column-width="0.4in"/>
<fo:table-column column-width="{$maxBodyWidth - 1.25}in"/>
<fo:flow flow-name="xsl-region-body"> <fo:table-body>
<!-- Render the chapter heading --> <xsl:apply-templates mode="toc"/>
<xsl:call-template name="body-chapter-heading"> </fo:table-body>
<xsl:with-param name="chapterNumber"></xsl:with-param> </fo:table>
<xsl:with-param name="chapter">Table of Contents</xsl:with-param> </fo:flow>
</xsl:call-template> </fo:page-sequence>
<fo:table layout="fixed"> </xsl:template>
<fo:table-column column-width="0.25in"/> <xsl:template match="project/body/menu" mode="toc">
<fo:table-column column-width="0.4in"/> <fo:table-row keep-with-next="always">
<fo:table-column column-width="0.4in"/> <fo:table-cell xsl:use-attribute-sets="toc.cell">
<fo:table-column column-width="{$maxBodyWidth - 1.25}in"/> <fo:block xsl:use-attribute-sets="toc.number.style">
<fo:table-body> <xsl:number level="any" format="1" count="menu"/>
<xsl:apply-templates mode="toc"/> </fo:block>
</fo:table-body> </fo:table-cell>
</fo:table> <fo:table-cell xsl:use-attribute-sets="toc.cell" number-columns-spanned="3">
</fo:flow> <xsl:choose>
</fo:page-sequence> <xsl:when test="normalize-space(@href)">
</xsl:template> <fo:block xsl:use-attribute-sets="toc.h1.style" text-align-last="justify">
<fo:basic-link internal-destination="{@href}{generate-id()}">
<xsl:apply-templates select="@name"/>
<xsl:template match="project/body/menu" mode="toc"> </fo:basic-link>
<fo:table-row keep-with-next="always"> <fo:leader xsl:use-attribute-sets="toc.leader.style"/>
<fo:table-cell xsl:use-attribute-sets="toc.cell"> <fo:inline xsl:use-attribute-sets="page.number">
<fo:block xsl:use-attribute-sets="toc.number.style"> <fo:page-number-citation ref-id="{@href}{generate-id()}"/>
<xsl:number level="any" format="1" count="menu"/> </fo:inline>
</fo:block> </fo:block>
</fo:table-cell> </xsl:when>
<fo:table-cell xsl:use-attribute-sets="toc.cell" number-columns-spanned="3"> <xsl:otherwise>
<xsl:choose> <fo:block xsl:use-attribute-sets="toc.h1.style">
<xsl:when test="normalize-space(@href)"> <xsl:apply-templates select="@name"/>
<fo:block xsl:use-attribute-sets="toc.h1.style" text-align-last="justify"> </fo:block>
<fo:basic-link internal-destination="{@href}{generate-id()}"> </xsl:otherwise>
<xsl:apply-templates select="@name"/> </xsl:choose>
</fo:basic-link> </fo:table-cell>
<fo:leader xsl:use-attribute-sets="toc.leader.style"/> </fo:table-row>
<fo:inline xsl:use-attribute-sets="page.number"> <xsl:apply-templates mode="toc"/>
<fo:page-number-citation ref-id="{@href}{generate-id()}"/> </xsl:template>
</fo:inline> <xsl:template match="project/body/menu/item" mode="toc">
</fo:block> <fo:table-row keep-with-next="always">
</xsl:when> <fo:table-cell xsl:use-attribute-sets="toc.cell">
<xsl:otherwise> <fo:block xsl:use-attribute-sets="toc.number.style">
<fo:block xsl:use-attribute-sets="toc.h1.style"> <xsl:number count="menu"/>.<xsl:number count="menu/item"/>
<xsl:apply-templates select="@name"/> </fo:block>
</fo:block> </fo:table-cell>
</xsl:otherwise> <fo:table-cell xsl:use-attribute-sets="toc.cell" number-columns-spanned="3">
</xsl:choose> <xsl:choose>
</fo:table-cell> <xsl:when test="normalize-space(@href)">
</fo:table-row> <fo:block xsl:use-attribute-sets="toc.h2.style" text-align-last="justify">
<xsl:apply-templates mode="toc" /> <fo:basic-link internal-destination="{@href}{generate-id()}">
</xsl:template> <xsl:apply-templates select="@name"/>
</fo:basic-link>
<xsl:template match="project/body/menu/item" mode="toc"> <fo:leader xsl:use-attribute-sets="toc.leader.style"/>
<fo:table-row keep-with-next="always"> <fo:inline xsl:use-attribute-sets="page.number">
<fo:table-cell xsl:use-attribute-sets="toc.cell"> <fo:page-number-citation ref-id="{@href}{generate-id()}"/>
<fo:block xsl:use-attribute-sets="toc.number.style"> </fo:inline>
<xsl:number count="menu"/>.<xsl:number count="menu/item"/> </fo:block>
</fo:block> </xsl:when>
</fo:table-cell> <xsl:otherwise>
<fo:table-cell xsl:use-attribute-sets="toc.cell" number-columns-spanned="3"> <fo:block xsl:use-attribute-sets="toc.h2.style">
<xsl:choose> <xsl:apply-templates select="@name"/>
<xsl:when test="normalize-space(@href)"> </fo:block>
<fo:block xsl:use-attribute-sets="toc.h2.style" text-align-last="justify"> </xsl:otherwise>
<fo:basic-link internal-destination="{@href}{generate-id()}"> </xsl:choose>
<xsl:apply-templates select="@name"/> </fo:table-cell>
</fo:basic-link> </fo:table-row>
<fo:leader xsl:use-attribute-sets="toc.leader.style"/> <xsl:apply-templates mode="toc"/>
<fo:inline xsl:use-attribute-sets="page.number"> </xsl:template>
<fo:page-number-citation ref-id="{@href}{generate-id()}"/> <xsl:template match="project/body/menu/item/item" mode="toc">
</fo:inline> <fo:table-row>
</fo:block> <fo:table-cell/>
</xsl:when> <fo:table-cell xsl:use-attribute-sets="toc.cell">
<xsl:otherwise> <fo:block xsl:use-attribute-sets="toc.number.style">
<fo:block xsl:use-attribute-sets="toc.h2.style"> <xsl:number count="menu"/>.<xsl:number count="menu/item"/>.<xsl:number count="menu/item/item"/>
<xsl:apply-templates select="@name"/> </fo:block>
</fo:block> </fo:table-cell>
</xsl:otherwise> <fo:table-cell xsl:use-attribute-sets="toc.cell" number-columns-spanned="2">
</xsl:choose> <xsl:choose>
</fo:table-cell> <xsl:when test="normalize-space(@href)">
</fo:table-row> <fo:block xsl:use-attribute-sets="toc.h3.style" text-align-last="justify">
<xsl:apply-templates mode="toc" /> <fo:basic-link internal-destination="{@href}{generate-id()}">
</xsl:template> <xsl:apply-templates select="@name"/>
</fo:basic-link>
<xsl:template match="project/body/menu/item/item" mode="toc"> <fo:leader xsl:use-attribute-sets="toc.leader.style"/>
<fo:table-row> <fo:inline xsl:use-attribute-sets="page.number">
<fo:table-cell /> <fo:page-number-citation ref-id="{@href}{generate-id()}"/>
<fo:table-cell xsl:use-attribute-sets="toc.cell"> </fo:inline>
<fo:block xsl:use-attribute-sets="toc.number.style"> </fo:block>
<xsl:number count="menu"/>.<xsl:number count="menu/item"/>.<xsl:number count="menu/item/item"/> </xsl:when>
</fo:block> <xsl:otherwise>
</fo:table-cell> <fo:block xsl:use-attribute-sets="toc.h3.style">
<fo:table-cell xsl:use-attribute-sets="toc.cell" number-columns-spanned="2"> <xsl:apply-templates select="@name"/>
<xsl:choose> </fo:block>
<xsl:when test="normalize-space(@href)"> </xsl:otherwise>
<fo:block xsl:use-attribute-sets="toc.h3.style" text-align-last="justify"> </xsl:choose>
<fo:basic-link internal-destination="{@href}{generate-id()}"> </fo:table-cell>
<xsl:apply-templates select="@name"/> </fo:table-row>
</fo:basic-link> <xsl:apply-templates mode="toc"/>
<fo:leader xsl:use-attribute-sets="toc.leader.style"/> </xsl:template>
<fo:inline xsl:use-attribute-sets="page.number"> <xsl:template match="project/body/menu/item/item/item" mode="toc">
<fo:page-number-citation ref-id="{@href}{generate-id()}"/> <fo:table-row>
</fo:inline> <fo:table-cell/>
</fo:block> <fo:table-cell/>
</xsl:when> <fo:table-cell xsl:use-attribute-sets="toc.cell">
<xsl:otherwise> <fo:block xsl:use-attribute-sets="toc.number.style">
<fo:block xsl:use-attribute-sets="toc.h3.style"> <xsl:number count="menu"/>.<xsl:number count="menu/item"/>.<xsl:number count="menu/item/item"/>.<xsl:number count="menu/item/item/item"/>
<xsl:apply-templates select="@name"/> </fo:block>
</fo:block> </fo:table-cell>
</xsl:otherwise> <fo:table-cell xsl:use-attribute-sets="toc.cell">
</xsl:choose> <xsl:choose>
</fo:table-cell> <xsl:when test="normalize-space(@href)">
</fo:table-row> <fo:block xsl:use-attribute-sets="toc.h3.style" text-align-last="justify">
<xsl:apply-templates mode="toc" /> <fo:basic-link internal-destination="{@href}{generate-id()}">
</xsl:template> <xsl:apply-templates select="@name"/>
</fo:basic-link>
<xsl:template match="project/body/menu/item/item/item" mode="toc"> <fo:leader xsl:use-attribute-sets="toc.leader.style"/>
<fo:table-row> <fo:inline xsl:use-attribute-sets="page.number">
<fo:table-cell /> <fo:page-number-citation ref-id="{@href}{generate-id()}"/>
<fo:table-cell /> </fo:inline>
<fo:table-cell xsl:use-attribute-sets="toc.cell"> </fo:block>
<fo:block xsl:use-attribute-sets="toc.number.style"> </xsl:when>
<xsl:number count="menu"/>.<xsl:number count="menu/item"/>.<xsl:number count="menu/item/item"/>.<xsl:number count="menu/item/item/item"/> <xsl:otherwise>
</fo:block> <fo:block xsl:use-attribute-sets="toc.h3.style">
</fo:table-cell> <xsl:apply-templates select="@name"/>
<fo:table-cell xsl:use-attribute-sets="toc.cell"> </fo:block>
<xsl:choose> </xsl:otherwise>
<xsl:when test="normalize-space(@href)"> </xsl:choose>
<fo:block xsl:use-attribute-sets="toc.h3.style" text-align-last="justify"> </fo:table-cell>
<fo:basic-link internal-destination="{@href}{generate-id()}"> </fo:table-row>
<xsl:apply-templates select="@name"/> <xsl:apply-templates mode="toc"/>
</fo:basic-link> </xsl:template>
<fo:leader xsl:use-attribute-sets="toc.leader.style"/>
<fo:inline xsl:use-attribute-sets="page.number">
<fo:page-number-citation ref-id="{@href}{generate-id()}"/>
</fo:inline>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:block xsl:use-attribute-sets="toc.h3.style">
<xsl:apply-templates select="@name"/>
</fo:block>
</xsl:otherwise>
</xsl:choose>
</fo:table-cell>
</fo:table-row>
<xsl:apply-templates mode="toc" />
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View File

@ -1,169 +1,159 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/TR/2001/REC-SVG-20010904" version="1.0">
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:include href="fo-layouts.xslt"/>
xmlns:fo="http://www.w3.org/1999/XSL/Format" <xsl:include href="fo-cover.xslt"/>
xmlns:svg="http://www.w3.org/TR/2001/REC-SVG-20010904" version='1.0'> <xsl:include href="fo-toc.xslt"/>
<xsl:include href="fo-body.xslt"/>
<xsl:include href="fo-layouts.xslt" /> <xsl:include href="fo-tables.xslt"/>
<xsl:include href="fo-cover.xslt" /> <xsl:include href="fo-table-column-widths.xslt"/>
<xsl:include href="fo-toc.xslt" /> <xsl:param name="basePath">.</xsl:param>
<xsl:include href="fo-body.xslt" /> <xsl:param name="paperType">US</xsl:param>
<xsl:include href="fo-tables.xslt" /> <xsl:param name="companyName">The Jakarta Project</xsl:param>
<xsl:include href="fo-table-column-widths.xslt" /> <xsl:param name="companyIncName">Apache Software Foundation, Inc.</xsl:param>
<xsl:param name="basePath">.</xsl:param> <xsl:param name="confidential">false</xsl:param>
<xsl:param name="paperType">US</xsl:param> <xsl:param name="publicationYear">2003</xsl:param>
<xsl:param name="companyName">The Jakarta Project</xsl:param> <xsl:param name="imageDpi">150</xsl:param>
<xsl:param name="companyIncName">Apache Software Foundation, Inc.</xsl:param> <xsl:param name="companyLogo"/>
<xsl:param name="confidential">false</xsl:param> <xsl:param name="projectLogo"/>
<xsl:param name="publicationYear">2003</xsl:param> <xsl:param name="coverProjectCompany">Apache Software Foundation</xsl:param>
<xsl:param name="imageDpi">150</xsl:param> <xsl:param name="coverProjectName">Jakarta Maven</xsl:param>
<xsl:param name="companyLogo"/> <xsl:param name="coverType">Project Documentation</xsl:param>
<xsl:param name="projectLogo"/> <xsl:param name="coverVersion">1.0</xsl:param>
<xsl:param name="coverProjectCompany">Apache Software Foundation</xsl:param> <xsl:param name="coverDate">January 1, 1901</xsl:param>
<xsl:param name="coverProjectName">Jakarta Maven</xsl:param> <xsl:param name="debug">false</xsl:param>
<xsl:param name="coverType">Project Documentation</xsl:param> <!-- These next two variables are used in cheap-and-cheerful case conversions -->
<xsl:param name="coverVersion">1.0</xsl:param> <xsl:variable name="lc">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:param name="coverDate">January 1, 1901</xsl:param> <xsl:variable name="uc">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<xsl:param name="debug"></xsl:param> <xsl:variable name="footerText">&#169;<xsl:value-of select="$publicationYear"/>
<!-- These next two variables are used in cheap-and-cheerful case conversions --> <xsl:value-of select="concat(' ',$companyIncName)"/> &#8226; All rights reserved
<xsl:variable name="lc">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="uc">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<xsl:variable name="footerText">&#169;<xsl:value-of select="$publicationYear"/>
<xsl:value-of select="concat(' ',$companyIncName)"/> &#8226; All rights reserved
<xsl:if test="$confidential = 'true'"> <xsl:if test="$confidential = 'true'">
&#8226; Proprietary and Confidential &#8226; Proprietary and Confidential
</xsl:if> </xsl:if>
</xsl:variable>
<xsl:variable name="colorDarkGray">#454545</xsl:variable>
<xsl:variable name="colorMediumGray">#A9A9A9</xsl:variable>
<xsl:variable name="colorLightGray">#D3D3D3</xsl:variable>
<!--
<xsl:variable name="colorWarmGrey11">#504b42</xsl:variable>
-->
<xsl:variable name="colorWarmGrey11">#4b4542</xsl:variable>
<xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="no"/>
<!--
<xsl:param name="debug">true</xsl:param>
-->
<!-- Error style -->
<xsl:attribute-set name="error.block" use-attribute-sets="base.block">
<xsl:attribute name="font-size">8pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="color">red</xsl:attribute>
<xsl:attribute name="border-style">solid</xsl:attribute>
<xsl:attribute name="border-width">0.5pt</xsl:attribute>
<xsl:attribute name="border-color">red</xsl:attribute>
<xsl:attribute name="padding">0.75em</xsl:attribute>
<xsl:attribute name="start-indent">inherited-property-value(start-indent) + 2.5em</xsl:attribute>
<xsl:attribute name="end-indent">inherited-property-value(end-indent) + 3em</xsl:attribute>
</xsl:attribute-set>
<!-- Templates -->
<xsl:template match="/">
<xsl:apply-templates select="project" />
</xsl:template>
<xsl:template match="project">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:call-template name="fo-layouts" />
<xsl:apply-templates />
</fo:root>
</xsl:template>
<xsl:template match="project/body">
<!-- Custom cover pages will be included in a future version -->
<xsl:call-template name="fo-cover" />
<!--
<xsl:call-template name="fo-cover-inside" />
-->
<xsl:call-template name="fo-toc" />
<xsl:apply-templates />
</xsl:template>
<xsl:template match="project/body/menu">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="project/body/menu/item">
<!-- Renders the xml xdoc document -->
<xsl:call-template name="render-xdoc">
<xsl:with-param name="chapterNumber"><xsl:number count="menu" />.<xsl:number count="menu/item" /></xsl:with-param>
</xsl:call-template>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="project/body/menu/item/item">
<!-- Renders the xml xdoc document -->
<xsl:call-template name="render-xdoc">
<xsl:with-param name="chapterNumber"><xsl:number count="menu" />.<xsl:number count="menu/item" />.<xsl:number count="menu/item/item" /></xsl:with-param>
</xsl:call-template>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="project/body/menu/item/item/item">
<!-- Renders the xml xdoc document -->
<xsl:call-template name="render-xdoc">
<xsl:with-param name="chapterNumber"><xsl:number count="menu"/>.<xsl:number count="menu/item"/>.<xsl:number count="menu/item/item"/>.<xsl:number count="menu/item/item/item"/></xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="render-xdoc">
<xsl:param name="chapterNumber">Foo</xsl:param>
<!-- Set the page number to start at. Normally this is 'auto'
unless we are at the very first xdoc, in which case we reset it to 1 -->
<xsl:variable name="pageStart">
<xsl:choose>
<xsl:when test="normalize-space(translate($chapterNumber,'1.',' '))">
<xsl:text>auto</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>1</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable> </xsl:variable>
<!-- Renders the xml xdoc document --> <xsl:variable name="colorDarkGray">#454545</xsl:variable>
<!-- Retrieve the xdoc file relative to the basePath; <xsl:variable name="colorMediumGray">#A9A9A9</xsl:variable>
<xsl:variable name="colorLightGray">#D3D3D3</xsl:variable>
<!-- <xsl:variable name="colorWarmGrey11">#504b42</xsl:variable> -->
<xsl:variable name="colorWarmGrey11">#4b4542</xsl:variable>
<xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="no"/>
<!-- Error style -->
<xsl:attribute-set name="error.block" use-attribute-sets="base.block">
<xsl:attribute name="font-size">8pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="color">red</xsl:attribute>
<xsl:attribute name="border-style">solid</xsl:attribute>
<xsl:attribute name="border-width">0.5pt</xsl:attribute>
<xsl:attribute name="border-color">red</xsl:attribute>
<xsl:attribute name="padding">0.75em</xsl:attribute>
<xsl:attribute name="start-indent">inherited-property-value(start-indent) + 2.5em</xsl:attribute>
<xsl:attribute name="end-indent">inherited-property-value(end-indent) + 3em</xsl:attribute>
</xsl:attribute-set>
<!-- Templates -->
<xsl:template match="/">
<xsl:apply-templates select="project"/>
</xsl:template>
<xsl:template match="project">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:call-template name="fo-layouts"/>
<xsl:apply-templates/>
</fo:root>
</xsl:template>
<xsl:template match="project/body">
<!-- Custom cover pages will be included in a future version -->
<xsl:call-template name="fo-cover"/>
<!-- <xsl:call-template name="fo-cover-inside" /> -->
<xsl:call-template name="fo-toc"/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="project/body/menu">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="project/body/menu/item">
<!-- Renders the xml xdoc document -->
<xsl:call-template name="render-xdoc">
<xsl:with-param name="chapterNumber">
<xsl:number count="menu"/>.<xsl:number count="menu/item"/>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="project/body/menu/item/item">
<!-- Renders the xml xdoc document -->
<xsl:call-template name="render-xdoc">
<xsl:with-param name="chapterNumber">
<xsl:number count="menu"/>.<xsl:number count="menu/item"/>.<xsl:number count="menu/item/item"/>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="project/body/menu/item/item/item">
<!-- Renders the xml xdoc document -->
<xsl:call-template name="render-xdoc">
<xsl:with-param name="chapterNumber">
<xsl:number count="menu"/>.<xsl:number count="menu/item"/>.<xsl:number count="menu/item/item"/>.<xsl:number count="menu/item/item/item"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="render-xdoc">
<xsl:param name="chapterNumber">Foo</xsl:param>
<!-- Set the page number to start at. Normally this is 'auto'
unless we are at the very first xdoc, in which case we reset it to 1 -->
<xsl:variable name="pageStart">
<xsl:choose>
<xsl:when test="normalize-space(translate($chapterNumber,'1.',' '))">
<xsl:text>auto</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>1</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Renders the xml xdoc document -->
<!-- Retrieve the xdoc file relative to the basePath;
the name is the href, but substitute .xml as the suffix --> the name is the href, but substitute .xml as the suffix -->
<xsl:variable name="href" select="@href"/> <xsl:variable name="href" select="@href"/>
<xsl:variable name="documentName" select="substring-before( @href, '.html' )"/> <xsl:variable name="documentName" select="substring-before( @href, '.html' )"/>
<xsl:variable name="documentPath" select="concat($basePath, $documentName, '.xml')"/> <xsl:variable name="documentPath" select="concat($basePath, $documentName, '.xml')"/>
<xsl:if test="normalize-space(@href)"> <xsl:if test="normalize-space(@href)">
<xsl:if test="$debug = 'true'"> <xsl:if test="$debug = 'true'">
<xsl:message> <xsl:message>Creating XSL:FO for <xsl:value-of select="$documentPath"/>
Href = <xsl:value-of select="$href"/></xsl:message> </xsl:message>
<xsl:message> </xsl:if>
Doc Name = <xsl:value-of select="$documentName"/></xsl:message> <fo:page-sequence master-reference="body" initial-page-number="{$pageStart}">
<xsl:message> <!-- Render the header and footer -->
Doc Path = <xsl:value-of select="$documentPath"/></xsl:message> <xsl:call-template name="body-header">
<xsl:message>Creating XSL:FO for <xsl:value-of select="$documentPath"/></xsl:message> <xsl:with-param name="headerText" select="concat($chapterNumber, ' ', translate(@name, $lc, $uc))"/>
</xsl:if> </xsl:call-template>
<fo:page-sequence master-reference="body" initial-page-number="{$pageStart}"> <xsl:call-template name="body-footer">
<!-- Render the header and footer --> <xsl:with-param name="footerText" select="translate($footerText, $lc, $uc)"/>
<xsl:call-template name="body-header"> </xsl:call-template>
<xsl:with-param name="headerText" select="concat($chapterNumber, ' ', translate(@name, $lc, $uc))"/> <fo:flow flow-name="xsl-region-body">
</xsl:call-template> <!-- Render the chapter heading -->
<xsl:call-template name="body-footer"> <xsl:call-template name="body-chapter-heading">
<xsl:with-param name="footerText" select="translate($footerText, $lc, $uc)"/> <xsl:with-param name="chapterNumber">
</xsl:call-template> <xsl:value-of select="$chapterNumber"/>
<fo:flow flow-name="xsl-region-body"> </xsl:with-param>
<!-- Render the chapter heading --> <xsl:with-param name="chapter">
<xsl:call-template name="body-chapter-heading"> <xsl:value-of select="@name"/>
<xsl:with-param name="chapterNumber"><xsl:value-of select="$chapterNumber"/></xsl:with-param> </xsl:with-param>
<xsl:with-param name="chapter"><xsl:value-of select="@name" /></xsl:with-param> </xsl:call-template>
</xsl:call-template> <!-- Render the associated xdoc -->
<!-- Render the associated xdoc --> <fo:block id="{@href}{generate-id()}">
<fo:block id="{@href}{generate-id()}"> <xsl:if test="not(starts-with($href, 'http'))">
<xsl:apply-templates select="document($documentPath)/document/body" /> <xsl:apply-templates select="document($documentPath)/document/body">
</fo:block> <xsl:with-param name="chapterNumber">
</fo:flow> <xsl:value-of select="$chapterNumber"/>
</fo:page-sequence> </xsl:with-param>
</xsl:if> </xsl:apply-templates>
</xsl:template> </xsl:if>
<xsl:if test="starts-with($href, 'http')">
<fo:basic-link external-destination="{@href}">
<fo:inline xsl:use-attribute-sets="href"><xsl:value-of select="$href"/></fo:inline>
</fo:basic-link>
</xsl:if>
</fo:block>
</fo:flow>
</fo:page-sequence>
</xsl:if>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>