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"?>
<project xmlns:j="jelly:core">
<goal
name="pdf:init"
prereqs="xdoc:init">
<j:set var="docsXdocSrc"
value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.docs.src')}"/>
<j:set var="docsGenSrc"
value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.gen.docs')}"/>
<j:set var="docsPdf"
value="${maven.build.dir}/pdf"/>
<j:set var="docsToc"
value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.docs.src')}/navigation.xml"/>
<j:set var="confidential"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.confidential')}"/>
<j:set var="paperType"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.paperType')}"/>
<j:set var="companyName"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.companyName')}"/>
<j:set var="companyIncName"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.companyIncName')}"/>
<j:set var="publicationYear"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.copyrightYear')}"/>
<j:set var="coverProjectCompany"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.projectCompany')}"/>
<j:set var="coverProjectName"
value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.projectName')}"/>
<j:set var="coverType"
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
<goal name="pdf:init" prereqs="xdoc:init">
<j:set var="docsXdocSrc" value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.docs.src')}"/>
<j:set var="docsGenSrc" value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.gen.docs')}"/>
<j:set var="docsPdf" value="${maven.build.dir}/pdf"/>
<j:set var="docsToc" value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.docs.src')}/${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.navigationFile')}"/>
<j:set var="confidential" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.confidential')}"/>
<j:set var="paperType" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.paperType')}"/>
<j:set var="companyName" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.companyName')}"/>
<j:set var="companyIncName" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.companyIncName')}"/>
<j:set var="publicationYear" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.copyrightYear')}"/>
<j:set var="coverProjectCompany" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.projectCompany')}"/>
<j:set var="coverProjectName" value="${pom.getPluginContext('maven-pdf-plugin').getVariable('maven.pdf.cover.projectName')}"/>
<j:set var="coverType" 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 -->
${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">
<param name="basePath" expression="${docsPdf}"/>
<param name="confidential" expression="${confidential}"/>
<param name="paperType" expression="${paperType}"/>
<param name="companyName" expression="${companyName}"/>
<param name="companyIncName" expression="${companyIncName}"/>
<param name="publicationYear" expression="${publicationYear}"/>
<param name="coverProjectCompany" expression="${coverProjectCompany}"/>
<param name="coverProjectName" expression="${coverProjectName}"/>
<param name="coverType" expression="${coverType}"/>
<param name="coverVersion" expression="${coverVersion}"/>
<param name="coverDate" expression="${coverDate}"/>
<param name="companyLogo" expression="${companyLogo}"/>
<param name="projectLogo" expression="${projectLogo}"/>
<param name="imageDpi" expression="${imageDpi}"/>
<param name="debug" expression="${debug}"/>
</style>
</goal>
<goal
name="pdf"
prereqs="fo:fo,pdf:prepare,pdf:pdf"
description="Generate PDF project documentation"/>
<goal
name="pdf:prepare"
prereqs="pdf:init"
description="Stages all files needed to generate the PDF">
<!-- First, copy all of the generated xdocs -->
<copy todir="${docsPdf}">
<fileset dir="${docsGenSrc}" force="true">
<include name="**/*.*"/>
</fileset>
</copy>
<!-- Then, copy all of the user-supplied xdocs -->
<copy todir="${docsPdf}" force="true">
<fileset dir="${docsXdocSrc}">
<include name="**/*.*"/>
</fileset>
</copy>
<!-- Finally, copy the FOP config file and all of the fonts -->
<copy todir="${docsPdf}" force="true">
<fileset dir="${plugin.resources}">
<include name="userconfig.xml"/>
<include name="fonts/*.*"/>
</fileset>
</copy>
</goal>
<goal name="pdf:pdf" description="Generate PDF project documentation"
prereqs="pdf:prepare">
<echo>Generating ${docsPdf}/project.pdf ...</echo>
<echo>Config file: ${docsPdf}/userconfig.xml</echo>
<java classname="org.apache.fop.apps.Fop" fork="yes" failonerror="true" maxmemory="500m">
<classpath>
<pathelement location="${plugin.getDependencyPath('fop')}"/>
<pathelement location="${plugin.getDependencyPath('batik')}"/>
<pathelement location="${plugin.getDependencyPath('logkit')}"/>
<pathelement location="${plugin.getDependencyPath('avalon-framework')}"/>
<pathelement location="${plugin.getDependencyPath('xerces')}"/>
</classpath>
<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>
<param name="basePath" expression="${docsPdf}"/>
<param name="confidential" expression="${confidential}"/>
<param name="paperType" expression="${paperType}"/>
<param name="companyName" expression="${companyName}"/>
<param name="companyIncName" expression="${companyIncName}"/>
<param name="publicationYear" expression="${publicationYear}"/>
<param name="coverProjectCompany" expression="${coverProjectCompany}"/>
<param name="coverProjectName" expression="${coverProjectName}"/>
<param name="coverType" expression="${coverType}"/>
<param name="coverVersion" expression="${coverVersion}"/>
<param name="coverDate" expression="${coverDate}"/>
<param name="companyLogo" expression="${companyLogo}"/>
<param name="projectLogo" expression="${projectLogo}"/>
<param name="imageDpi" expression="${imageDpi}"/>
<param name="debug" expression="${debug}"/>
</style>
</goal>
<goal name="pdf" prereqs="fo:fo,pdf:prepare,pdf:pdf" description="Generate PDF project documentation"/>
<goal name="pdf:prepare" prereqs="pdf:init" description="Stages all files needed to generate the PDF">
<!-- First, copy all of the generated xdocs -->
<copy todir="${docsPdf}">
<fileset dir="${docsGenSrc}" force="true">
<include name="**/*.*"/>
</fileset>
</copy>
<!-- Then, copy all of the user-supplied xdocs -->
<copy todir="${docsPdf}" force="true">
<fileset dir="${docsXdocSrc}">
<include name="**/*.*"/>
</fileset>
</copy>
<!-- Finally, copy the FOP config file and all of the fonts -->
<copy todir="${docsPdf}" force="true">
<fileset dir="${plugin.resources}">
<include name="userconfig.xml"/>
<include name="fonts/*.*"/>
</fileset>
</copy>
</goal>
<goal name="pdf:pdf" description="Generate PDF project documentation" prereqs="pdf:prepare">
<echo>Generating ${docsPdf}/project.pdf ...</echo>
<echo>Config file: ${docsPdf}/userconfig.xml</echo>
<java classname="org.apache.fop.apps.Fop" fork="yes" failonerror="true" maxmemory="500m">
<classpath>
<pathelement location="${plugin.getDependencyPath('fop')}"/>
<pathelement location="${plugin.getDependencyPath('batik')}"/>
<pathelement location="${plugin.getDependencyPath('logkit')}"/>
<pathelement location="${plugin.getDependencyPath('avalon-framework')}"/>
<pathelement location="${plugin.getDependencyPath('xerces')}"/>
</classpath>
<arg value="-c"/>
<arg value="${docsPdf}/userconfig.xml"/>
<j:if test="${debug}"><arg value="-d"/></j:if>
<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>

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,230 +1,373 @@
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version='1.0'>
<!-- This is a dummy entry -->
<xsl:variable name="masklookup">----------111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"</xsl:variable>
<xsl:variable name="columnWidths"> 5? 5? 5? 5? 5? 5? 5? 5? 5? 5?</xsl:variable>
<xsl:template name="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="thead/tr[position()=$row]"/>
<xsl:variable name="currentCol"
select="thead/tr[position()=$row]/th[position()=$col]"/>
<!-- Determine the row/colspans for the current cell
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
<!-- This is a dummy entry -->
<xsl:variable name="masklookup">----------111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"</xsl:variable>
<xsl:variable name="columnWidths"> 5? 5? 5? 5? 5? 5? 5? 5? 5? 5?</xsl:variable>
<xsl:template name="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="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 -->
<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.
<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
<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),
<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
</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),
<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),
</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="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:variable>
<!-- Print debugging information -->
<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: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
<!-- 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: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>
</fo:table-column>
<!-- Loop to the next column -->
<xsl:choose>
<xsl:when test="$col &lt; $columns">
<xsl:call-template name="print-columns">
<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"/>
<xsl:with-param name="adjust" select="$adjust"/>
<xsl:with-param name="softColumns" select="$softColumns"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
</fo:table-column>
<!-- Loop to the next column -->
<xsl:choose>
<xsl:when test="$col &lt; $columns">
<xsl:call-template name="print-columns">
<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"/>
<xsl:with-param name="adjust" select="$adjust"/>
<xsl:with-param name="softColumns" select="$softColumns"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</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>

View File

@ -141,12 +141,221 @@ xmlns:fo="http://www.w3.org/1999/XSL/Format" version='1.0'>
<!-- Table rendering -->
<!--
<xsl:template match="table[count(thead)=0]">
<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.
</fo:block>
</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">
<!-- 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:template>
</xsl:stylesheet>

View File

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

View File

@ -1,169 +1,159 @@
<?xml version="1.0" encoding="UTF-8"?>
<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'>
<xsl:include href="fo-layouts.xslt" />
<xsl:include href="fo-cover.xslt" />
<xsl:include href="fo-toc.xslt" />
<xsl:include href="fo-body.xslt" />
<xsl:include href="fo-tables.xslt" />
<xsl:include href="fo-table-column-widths.xslt" />
<xsl:param name="basePath">.</xsl:param>
<xsl:param name="paperType">US</xsl:param>
<xsl:param name="companyName">The Jakarta Project</xsl:param>
<xsl:param name="companyIncName">Apache Software Foundation, Inc.</xsl:param>
<xsl:param name="confidential">false</xsl:param>
<xsl:param name="publicationYear">2003</xsl:param>
<xsl:param name="imageDpi">150</xsl:param>
<xsl:param name="companyLogo"/>
<xsl:param name="projectLogo"/>
<xsl:param name="coverProjectCompany">Apache Software Foundation</xsl:param>
<xsl:param name="coverProjectName">Jakarta Maven</xsl:param>
<xsl:param name="coverType">Project Documentation</xsl:param>
<xsl:param name="coverVersion">1.0</xsl:param>
<xsl:param name="coverDate">January 1, 1901</xsl:param>
<xsl:param name="debug"></xsl:param>
<!-- These next two variables are used in cheap-and-cheerful case conversions -->
<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: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">
<xsl:include href="fo-layouts.xslt"/>
<xsl:include href="fo-cover.xslt"/>
<xsl:include href="fo-toc.xslt"/>
<xsl:include href="fo-body.xslt"/>
<xsl:include href="fo-tables.xslt"/>
<xsl:include href="fo-table-column-widths.xslt"/>
<xsl:param name="basePath">.</xsl:param>
<xsl:param name="paperType">US</xsl:param>
<xsl:param name="companyName">The Jakarta Project</xsl:param>
<xsl:param name="companyIncName">Apache Software Foundation, Inc.</xsl:param>
<xsl:param name="confidential">false</xsl:param>
<xsl:param name="publicationYear">2003</xsl:param>
<xsl:param name="imageDpi">150</xsl:param>
<xsl:param name="companyLogo"/>
<xsl:param name="projectLogo"/>
<xsl:param name="coverProjectCompany">Apache Software Foundation</xsl:param>
<xsl:param name="coverProjectName">Jakarta Maven</xsl:param>
<xsl:param name="coverType">Project Documentation</xsl:param>
<xsl:param name="coverVersion">1.0</xsl:param>
<xsl:param name="coverDate">January 1, 1901</xsl:param>
<xsl:param name="debug">false</xsl:param>
<!-- These next two variables are used in cheap-and-cheerful case conversions -->
<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'">
&#8226; Proprietary and Confidential
</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>
<!-- Renders the xml xdoc document -->
<!-- Retrieve the xdoc file relative to the basePath;
<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"/>
<!-- 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 -->
<xsl:variable name="href" select="@href"/>
<xsl:variable name="documentName" select="substring-before( @href, '.html' )"/>
<xsl:variable name="documentPath" select="concat($basePath, $documentName, '.xml')"/>
<xsl:if test="normalize-space(@href)">
<xsl:if test="$debug = 'true'">
<xsl:message>
Href = <xsl:value-of select="$href"/></xsl:message>
<xsl:message>
Doc Name = <xsl:value-of select="$documentName"/></xsl:message>
<xsl:message>
Doc Path = <xsl:value-of select="$documentPath"/></xsl:message>
<xsl:message>Creating XSL:FO for <xsl:value-of select="$documentPath"/></xsl:message>
</xsl:if>
<fo:page-sequence master-reference="body" initial-page-number="{$pageStart}">
<!-- Render the header and footer -->
<xsl:call-template name="body-header">
<xsl:with-param name="headerText" select="concat($chapterNumber, ' ', translate(@name, $lc, $uc))"/>
</xsl:call-template>
<xsl:call-template name="body-footer">
<xsl:with-param name="footerText" select="translate($footerText, $lc, $uc)"/>
</xsl:call-template>
<fo:flow flow-name="xsl-region-body">
<!-- Render the chapter heading -->
<xsl:call-template name="body-chapter-heading">
<xsl:with-param name="chapterNumber"><xsl:value-of select="$chapterNumber"/></xsl:with-param>
<xsl:with-param name="chapter"><xsl:value-of select="@name" /></xsl:with-param>
</xsl:call-template>
<!-- Render the associated xdoc -->
<fo:block id="{@href}{generate-id()}">
<xsl:apply-templates select="document($documentPath)/document/body" />
</fo:block>
</fo:flow>
</fo:page-sequence>
</xsl:if>
</xsl:template>
<xsl:variable name="href" select="@href"/>
<xsl:variable name="documentName" select="substring-before( @href, '.html' )"/>
<xsl:variable name="documentPath" select="concat($basePath, $documentName, '.xml')"/>
<xsl:if test="normalize-space(@href)">
<xsl:if test="$debug = 'true'">
<xsl:message>Creating XSL:FO for <xsl:value-of select="$documentPath"/>
</xsl:message>
</xsl:if>
<fo:page-sequence master-reference="body" initial-page-number="{$pageStart}">
<!-- Render the header and footer -->
<xsl:call-template name="body-header">
<xsl:with-param name="headerText" select="concat($chapterNumber, ' ', translate(@name, $lc, $uc))"/>
</xsl:call-template>
<xsl:call-template name="body-footer">
<xsl:with-param name="footerText" select="translate($footerText, $lc, $uc)"/>
</xsl:call-template>
<fo:flow flow-name="xsl-region-body">
<!-- Render the chapter heading -->
<xsl:call-template name="body-chapter-heading">
<xsl:with-param name="chapterNumber">
<xsl:value-of select="$chapterNumber"/>
</xsl:with-param>
<xsl:with-param name="chapter">
<xsl:value-of select="@name"/>
</xsl:with-param>
</xsl:call-template>
<!-- Render the associated xdoc -->
<fo:block id="{@href}{generate-id()}">
<xsl:if test="not(starts-with($href, 'http'))">
<xsl:apply-templates select="document($documentPath)/document/body">
<xsl:with-param name="chapterNumber">
<xsl:value-of select="$chapterNumber"/>
</xsl:with-param>
</xsl:apply-templates>
</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>