Made index have long references
authorNigel Metheringham <nigel.metheringham@dev.intechnology.co.uk>
Wed, 7 Jul 2010 21:15:59 +0000 (22:15 +0100)
committerNigel Metheringham <nigel.metheringham@dev.intechnology.co.uk>
Wed, 7 Jul 2010 21:15:59 +0000 (22:15 +0100)
script/gen.pl
templates/wrapper.xsl

index 1b207935c56e6c968614d986618fff08df38d9d4..7bc1309cc995301d526b8eede24416561307aa4e 100755 (executable)
@@ -185,8 +185,12 @@ sub xref_fixup {
             }
             my $section_title = $section->findvalue('title');
 
             }
             my $section_title = $section->findvalue('title');
 
-            $index{$section_id} =
-              { chapter_id => $chapter_counter, chapter_title => $chapter_title, section_id => $section_counter };
+            $index{$section_id} = {
+                chapter_id    => $chapter_counter,
+                chapter_title => $chapter_title,
+                section_id    => $section_counter,
+                section_title => $section_title
+            };
         }
     }
     ## Build indexes as new chapters
         }
     }
     ## Build indexes as new chapters
@@ -198,7 +202,8 @@ sub xref_fixup {
         if ( exists $index{$linkend} ) {
             $xref->setAttribute( 'chapter_id',    $index{$linkend}{'chapter_id'} );
             $xref->setAttribute( 'chapter_title', $index{$linkend}{'chapter_title'} );
         if ( exists $index{$linkend} ) {
             $xref->setAttribute( 'chapter_id',    $index{$linkend}{'chapter_id'} );
             $xref->setAttribute( 'chapter_title', $index{$linkend}{'chapter_title'} );
-            $xref->setAttribute( 'section_id',    $index{$linkend}{'section_id'} ) if $index{$linkend}{'section_id'};
+            $xref->setAttribute( 'section_id',    $index{$linkend}{'section_id'} ) if ( $index{$linkend}{'section_id'} );
+            $xref->setAttribute( 'section_title', $index{$linkend}{'section_title'} ) if ( $index{$linkend}{'section_title'} );
             $xref->setAttribute( 'url',
                 sprintf( '%sch%02d.html', $prepend_chapter, $index{$linkend}{'chapter_id'} )
                   . ( $index{$linkend}{'section_id'} ? '#' . $linkend : '' ) );
             $xref->setAttribute( 'url',
                 sprintf( '%sch%02d.html', $prepend_chapter, $index{$linkend}{'chapter_id'} )
                   . ( $index{$linkend}{'section_id'} ? '#' . $linkend : '' ) );
@@ -271,6 +276,7 @@ sub build_indexes {
                           if ( $count++ );
                         my $xrefel = XML::LibXML::Element->new('xref');
                         $xrefel->setAttribute( linkend => $ref );
                           if ( $count++ );
                         my $xrefel = XML::LibXML::Element->new('xref');
                         $xrefel->setAttribute( linkend => $ref );
+                        $xrefel->setAttribute( longref => 1 );
                         $spara->appendChild($xrefel);
                     }
                 }
                         $spara->appendChild($xrefel);
                     }
                 }
index ba0c6345d141a99ef60e18ab63d68e38b40218df..c816ca2fa81c27c08d014f8a9e8a67af4dfd02fe 100644 (file)
          <a href="{@url}" title="{@chapter_id}. {@chapter_title}">
             <xsl:choose>
                <xsl:when test="@section_id">
          <a href="{@url}" title="{@chapter_id}. {@chapter_title}">
             <xsl:choose>
                <xsl:when test="@section_id">
-                  <xsl:value-of select="concat(@chapter_id,'.',@section_id)"/>
+                  <xsl:choose>
+                     <xsl:when test="@longref">
+                        <xsl:value-of select="concat(@chapter_id,'. ',@chapter_title,'[',@section_title,']')"/>
+                     </xsl:when>
+                     <xsl:otherwise>
+                        <xsl:value-of select="concat(@chapter_id,'.',@section_id)"/>
+                     </xsl:otherwise>
+                  </xsl:choose>
                </xsl:when>
                <xsl:otherwise>
                </xsl:when>
                <xsl:otherwise>
-                  <xsl:value-of select="@chapter_id"/>
+                  <xsl:choose>
+                     <xsl:when test="@longref">
+                        <xsl:value-of select="concat(@chapter_id,'. ',@chapter_title)"/>
+                     </xsl:when>
+                     <xsl:otherwise>
+                        <xsl:value-of select="@chapter_id"/>
+                     </xsl:otherwise>
+                  </xsl:choose>
                </xsl:otherwise>
             </xsl:choose>
          </a>
                </xsl:otherwise>
             </xsl:choose>
          </a>