View Single Post
  #3 (permalink)  
Old January 17th, 2017, 06:10 AM is offline
Registered User
Points: 44, Level: 1
Points: 44, Level: 1 Points: 44, Level: 1 Points: 44, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2017
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts

Below is the code snippet for getting required output. Looks working fine.
But I've to find out chapter title using on attribute value (linkend="CHAP_1").
In toc, there might be chance of missing chapter reference. In the toc section, if there is no reference for CHAP_3, then expected output should be as below.

Subject Areas
Business Questions
Duty Roles
Subject Areas

Business Questions

Job Roles

Duty Roles

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
<xsl:template match="/">
<title><xsl:value-of select="book/toc/title" /></title>
<xsl:apply-templates />
<xsl:template match="book">
<xsl:for-each select="chapter">
<li><a href="#{@id}"><xsl:value-of select="title"/></a><br/></li>

<xsl:template match="chapter">
<xsl:variable name="Id" select="@id"/>
<h2> <a name="{$Id}"><xsl:value-of select="title"/></a></h2>

Reply With Quote