}
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
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 : '' ) );
if ( $count++ );
my $xrefel = XML::LibXML::Element->new('xref');
$xrefel->setAttribute( linkend => $ref );
+ $xrefel->setAttribute( longref => 1 );
$spara->appendChild($xrefel);
}
}
<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: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>