--- maven-pdf-plugin-2.2.1-orig/plugin-resources/fo-body.xslt	2004-10-30 12:06:18.000000000 +0000
+++ maven-pdf-plugin-2.2.1/plugin-resources/fo-body.xslt	2005-06-08 17:43:52.552951512 +0000
@@ -54,6 +54,7 @@
   </xsl:template>
   <xsl:template name="body-chapter-heading">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <xsl:param name="chapter"/>
     <xsl:variable name="gutter">0.125</xsl:variable>
     <xsl:variable name="leftMargin">
@@ -81,7 +82,7 @@
         </fo:list-item>
       </fo:list-block>
     </fo:block>
-    <fo:block space-after.optimum="5em">
+    <fo:block space-after.optimum="0em">
       <!-- Add a rule underneath -->
       <fo:leader xsl:use-attribute-sets="chapter.rule"/>
     </fo:block>
@@ -89,15 +90,23 @@
   <!-- Templates for rendering xdoc tags -->
   <xsl:template match="document/body">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <xsl:apply-templates>
       <xsl:with-param name="chapterNumber">
         <xsl:value-of select="$chapterNumber"/>
       </xsl:with-param>
+      <xsl:with-param name="fileName">
+        <xsl:value-of select="$fileName"/>
+      </xsl:with-param>
     </xsl:apply-templates>
   </xsl:template>
   <xsl:template match="section">
     <xsl:param name="chapterNumber"/>
-    <fo:block xsl:use-attribute-sets="body.h1">
+    <xsl:param name="fileName"/>
+    <xsl:param name="transLink">
+        <xsl:value-of select="translate(@name,' ','_')"/>
+    </xsl:param>
+    <fo:block xsl:use-attribute-sets="body.h1" id="{$fileName}#{$transLink}">
       <xsl:value-of select="@name"/>
     </fo:block>
     <fo:block xsl:use-attribute-sets="body.text">
@@ -105,12 +114,19 @@
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:block>
   </xsl:template>
   <xsl:template match="subsection">
     <xsl:param name="chapterNumber"/>
-    <fo:block xsl:use-attribute-sets="body.h2">
+    <xsl:param name="fileName"/>
+    <xsl:param name="transLink">
+        <xsl:value-of select="translate(@name,' ','_')"/>
+    </xsl:param>
+    <fo:block xsl:use-attribute-sets="body.h2" id="{$fileName}#{$transLink}">
       <xsl:value-of select="@name"/>
     </fo:block>
     <fo:block xsl:use-attribute-sets="body.text">
@@ -118,6 +134,9 @@
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:block>
   </xsl:template>
@@ -141,47 +160,86 @@
   </xsl:template>
   <xsl:template match="p">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:block xsl:use-attribute-sets="body.text normal.paragraph">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:block>
   </xsl:template>
   <xsl:template match="source">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:block xsl:use-attribute-sets="body.source">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:block>
   </xsl:template>
   <xsl:template match="pre">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:block xsl:use-attribute-sets="body.source">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:block>
   </xsl:template>
+
   <xsl:template match="img[@src]">
+    <xsl:param name="fileName"/>
+    <xsl:param name="dirName">
+      <xsl:call-template name="substring-before-last">
+        <xsl:with-param name="text" select="$fileName"/>
+        <xsl:with-param name="chars">/</xsl:with-param>
+      </xsl:call-template>
+    </xsl:param>
+    <!-- Resolve the location of the image source relative to the location of the current document -->
+    <xsl:param name="ref" select="translate(normalize-space(@src),'\','/')"/>
     <xsl:variable name="source">
-      <xsl:choose>
-        <xsl:when test="substring(normalize-space(@src),1,3) = '../'">
-          <xsl:value-of select="translate(substring-after(normalize-space(@src),'../'),'\','/')"/>
-        </xsl:when>
-        <xsl:when test="substring(normalize-space(@src),1,3) = '..\'">
-          <xsl:value-of select="translate(substring-after(normalize-space(@src),'..\'),'\','/')"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:value-of select="@src"/>
-        </xsl:otherwise>
-      </xsl:choose>
+        <xsl:choose>
+            <xsl:when test="starts-with($ref, './')">
+                <xsl:choose>
+                    <xsl:when test="string-length($dirName) = 0">
+                        <xsl:value-of select="substring-after($ref,'./')"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="concat($dirName, '/', substring-after($ref,'./'))"/>
+                    </xsl:otherwise>
+                </xsl:choose>
+            </xsl:when>
+            <xsl:when test="starts-with($ref, '../')">
+                <xsl:call-template name="resolveLink">
+                    <xsl:with-param name="dirName" select="$dirName"/>
+                    <xsl:with-param name="href" select="$ref"/>
+                </xsl:call-template>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:choose>
+                    <xsl:when test="string-length($dirName) = 0">
+                        <xsl:value-of select="$ref"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="concat($dirName, '/', $ref)"/>
+                    </xsl:otherwise>
+                </xsl:choose>
+            </xsl:otherwise>
+        </xsl:choose>
     </xsl:variable>
     <xsl:variable name="width">
       <xsl:value-of select="substring-before(concat(normalize-space(@width),'p'),'p') div $imageDpi"/>
@@ -224,156 +282,350 @@
   <!-- Templates for handling XHTML tags -->
   <xsl:template match="a[@href and (starts-with(@href, 'http') or starts-with(@href, 'mailto') or starts-with(@href, 'ftp'))]">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:basic-link external-destination="{@href}">
       <fo:inline xsl:use-attribute-sets="href.external">
         <xsl:apply-templates>
           <xsl:with-param name="chapterNumber">
             <xsl:value-of select="$chapterNumber"/>
           </xsl:with-param>
+          <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
         </xsl:apply-templates>
       </fo:inline>
     </fo:basic-link>
   </xsl:template>
   <xsl:template match="a[@href and starts-with(@href, '#')]">
     <xsl:param name="chapterNumber"/>
-    <fo:basic-link internal-destination="{$chapterNumber}{@href}{generate-id()}">
+    <xsl:param name="fileName"/>
+    <fo:basic-link internal-destination="{$fileName}{@href}">
       <fo:inline xsl:use-attribute-sets="href.internal">
         <xsl:apply-templates>
           <xsl:with-param name="chapterNumber">
             <xsl:value-of select="$chapterNumber"/>
           </xsl:with-param>
+          <xsl:with-param name="fileName">
+            <xsl:value-of select="$fileName"/>
+          </xsl:with-param>
         </xsl:apply-templates>
       </fo:inline>
     </fo:basic-link>
   </xsl:template>
   <xsl:template match="a[@href and not(starts-with(@href, 'http')) and not(starts-with(@href, 'mailto')) and not(starts-with(@href, 'ftp')) and not(starts-with(@href, '#'))]">
     <xsl:param name="chapterNumber"/>
-    <fo:basic-link internal-destination="{@href}{generate-id()}">
+    <xsl:param name="fileName"/>
+    <xsl:param name="dirName">
+      <xsl:call-template name="substring-before-last">
+        <xsl:with-param name="text" select="$fileName"/>
+        <xsl:with-param name="chars">/</xsl:with-param>
+      </xsl:call-template>
+    </xsl:param>
+    <!-- Resolve the location of the link relative to the location of the current document -->
+    <xsl:param name="ref" select="translate(normalize-space(@href),'\','/')"/>
+    <xsl:param name="href">
+        <xsl:choose>
+            <xsl:when test="starts-with($ref, './')">
+                <xsl:choose>
+                    <xsl:when test="string-length($dirName) = 0">
+                        <xsl:value-of select="substring-after($ref,'./')"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="concat($dirName, '/', substring-after($ref,'./'))"/>
+                    </xsl:otherwise>
+                </xsl:choose>
+            </xsl:when>
+            <xsl:when test="starts-with($ref, '../')">
+                <xsl:call-template name="resolveLink">
+                    <xsl:with-param name="dirName" select="$dirName"/>
+                    <xsl:with-param name="href" select="$ref"/>
+                </xsl:call-template>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:choose>
+                    <xsl:when test="string-length($dirName) = 0">
+                        <xsl:value-of select="$ref"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="concat($dirName, '/', $ref)"/>
+                    </xsl:otherwise>
+                </xsl:choose>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:param>
+    <fo:basic-link internal-destination="{$href}">
       <fo:inline xsl:use-attribute-sets="href.internal">
         <xsl:apply-templates>
           <xsl:with-param name="chapterNumber">
             <xsl:value-of select="$chapterNumber"/>
           </xsl:with-param>
+          <xsl:with-param name="fileName">
+            <xsl:value-of select="$fileName"/>
+          </xsl:with-param>
         </xsl:apply-templates>
       </fo:inline>
     </fo:basic-link>
   </xsl:template>
+
+  <xsl:template name="resolveLink">
+    <xsl:param name="dirName"/>
+    <xsl:param name="href"/>
+    <xsl:choose>
+        <xsl:when test="starts-with($href, '../')">
+           <xsl:call-template name="resolveLink">
+               <xsl:with-param name="dirName">
+                    <xsl:call-template name="substring-before-last">
+                      <xsl:with-param name="text" select="$dirName"/>
+                      <xsl:with-param name="chars">/</xsl:with-param>
+                    </xsl:call-template>
+               </xsl:with-param>
+               <xsl:with-param name="href" select="substring-after($href,'../')"/>
+           </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:choose>
+            <xsl:when test="string-length($dirName) = 0">
+              <xsl:value-of select="$href"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:value-of select="concat($dirName, '/', $href)"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template name="substring-before-last">
+    <xsl:param name="text"/>
+    <xsl:param name="chars"/>
+    <xsl:choose>
+      <xsl:when test="string-length($text) = 0"/>
+      <xsl:when test="string-length($chars) = 0">
+        <xsl:value-of select="$text"/>
+      </xsl:when>
+      <xsl:when test="contains($text, $chars)">
+        <xsl:call-template name="substring-before-last-aux">
+          <xsl:with-param name="text" select="$text"/>
+          <xsl:with-param name="chars" select="$chars"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <!--<xsl:value-of select="$text"/>-->
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template name="substring-before-last-aux">
+    <xsl:param name="text"/>
+    <xsl:param name="chars"/>
+    <xsl:choose>
+      <xsl:when test="string-length($text) = 0"/>
+      <xsl:when test="contains($text, $chars)">
+        <xsl:variable name="after">
+          <xsl:call-template name="substring-before-last-aux">
+            <xsl:with-param name="text" select="substring-after($text, $chars)"/>
+            <xsl:with-param name="chars" select="$chars"/>
+          </xsl:call-template>
+        </xsl:variable>
+        <xsl:value-of select="substring-before($text, $chars)"/>
+        <xsl:if test="string-length($after) &gt; 0">
+          <xsl:value-of select="$chars"/>
+          <xsl:copy-of select="$after"/>
+        </xsl:if>
+      </xsl:when>
+      <xsl:otherwise/>
+    </xsl:choose>
+  </xsl:template>
+
   <xsl:template match="a[@name]">
     <xsl:param name="chapterNumber"/>
-    <fo:block id="{$chapterNumber}#{@name}{generate-id()}">
+    <xsl:param name="fileName"/>
+    <xsl:param name="name" select="translate(normalize-space(@name),'\','/')"/>
+    <fo:block id="{$fileName}#{$name}">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:block>
   </xsl:template>
   <xsl:template match="br">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:block/>
   </xsl:template>
   <xsl:template match="em | i">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:inline font-style="italic">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:inline>
   </xsl:template>
   <xsl:template match="b | strong[ancestor::table]">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:inline font-weight="bold">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:inline>
   </xsl:template>
   <xsl:template match="strong[ancestor::p|ancestor::li|ancestor::dl|ancestor::dt|ancestor::dd]">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:inline font-weight="bold" xsl:use-attribute-sets="body.strong">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:inline>
   </xsl:template>
   <xsl:template match="strong">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:inline font-weight="bold">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:inline>
   </xsl:template>
   <xsl:template match="sub">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:inline baseline-shift="sub">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:inline>
   </xsl:template>
   <xsl:template match="sup">
     <xsl:param name="chapterNumber"/>
-    <fo:inline baseline-shift="sup">
+    <xsl:param name="fileName"/>
+    <fo:inline baseline-shift="super">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:inline>
   </xsl:template>
   <xsl:template match="tt|code">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:inline xsl:use-attribute-sets="body.pre">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:inline>
   </xsl:template>
+  <xsl:template match="code[@class='indent']">
+    <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
+    <fo:block xsl:use-attribute-sets="code.indent">
+      <xsl:apply-templates>
+        <xsl:with-param name="chapterNumber">
+          <xsl:value-of select="$chapterNumber"/>
+        </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
+      </xsl:apply-templates>
+    </fo:block>
+  </xsl:template>
   <xsl:template match="var">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:inline font-style="italic">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:inline>
   </xsl:template>
+  <xsl:template match="div">
+    <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
+      <xsl:apply-templates>
+        <xsl:with-param name="chapterNumber">
+          <xsl:value-of select="$chapterNumber"/>
+        </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
+      </xsl:apply-templates>
+  </xsl:template>
   <xsl:template match="big">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:inline font-size="larger">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:inline>
   </xsl:template>
   <xsl:template match="small">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:inline font-size="smaller">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:inline>
   </xsl:template>
   <xsl:template match="ul/ul | ul/ol | ol/ul | ol/ol">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:list-item xsl:use-attribute-sets="list.item">
       <fo:list-item-label>
         <fo:block/>
@@ -384,6 +636,9 @@
             <xsl:with-param name="chapterNumber">
               <xsl:value-of select="$chapterNumber"/>
             </xsl:with-param>
+            <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
           </xsl:apply-templates>
         </fo:block>
       </fo:list-item-body>
@@ -391,16 +646,21 @@
   </xsl:template>
   <xsl:template match="ul | ol">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:list-block xsl:use-attribute-sets="list">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:list-block>
   </xsl:template>
   <xsl:template match="ul/li">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:list-item xsl:use-attribute-sets="list.item">
       <fo:list-item-label>
         <fo:block>
@@ -415,6 +675,9 @@
             <xsl:with-param name="chapterNumber">
               <xsl:value-of select="$chapterNumber"/>
             </xsl:with-param>
+            <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
           </xsl:apply-templates>
         </fo:block>
       </fo:list-item-body>
@@ -422,6 +685,7 @@
   </xsl:template>
   <xsl:template match="ol/li">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:list-item xsl:use-attribute-sets="list.item">
       <fo:list-item-label>
         <fo:block>
@@ -434,6 +698,9 @@
             <xsl:with-param name="chapterNumber">
               <xsl:value-of select="$chapterNumber"/>
             </xsl:with-param>
+            <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
           </xsl:apply-templates>
         </fo:block>
       </fo:list-item-body>
@@ -441,31 +708,43 @@
   </xsl:template>
   <xsl:template match="dl">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:block xsl:use-attribute-sets="dl">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:block>
   </xsl:template>
   <xsl:template match="dt">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:block xsl:use-attribute-sets="dt">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:block>
   </xsl:template>
   <xsl:template match="dd">
     <xsl:param name="chapterNumber"/>
+    <xsl:param name="fileName"/>
     <fo:block xsl:use-attribute-sets="dd">
       <xsl:apply-templates>
         <xsl:with-param name="chapterNumber">
           <xsl:value-of select="$chapterNumber"/>
         </xsl:with-param>
+        <xsl:with-param name="fileName">
+          <xsl:value-of select="$fileName"/>
+        </xsl:with-param>
       </xsl:apply-templates>
     </fo:block>
   </xsl:template>

