Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8646093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:42:52+00:00 2026-06-12T12:42:52+00:00

I’m trying to customize DocBook XSL’s HTML output. <section> level X generates heading level

  • 0

I’m trying to customize DocBook XSL’s HTML output.

<section> level X generates heading level X + 1.

e.g. <sect1> -> <h2> but I work with <section> tags, not <sectX>. I understand why it happens but I would like to change this behavior so that section of a given level generates the same level heading. I tried studying the titlepage templates, but they don’t really make sense to me and I can’t find the actual code that generates the <hX> tags.

As an example, I have a docbook document that looks something like this:

<article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
[other namespace definitions]
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://docbook.org/ns/docbook docbook.xsd" version="5.0">
  <info>
    <title>Document Title</title>
    <orgname>Company</orgname>
  </info>
  <section>
    <title>INTRODUCTION</title>
    <section>
      <title>Overview</title>
      <para>This document defines [...]</para>
    </section>
    <section>
      <title>More Information</title>
      <para>[...]</para>
    </section>
    <section>
      <title>Aim</title>
      <para>This Document will be used to [...]</para>
      <table>
        [irrelevant table code]
      </table>
    </section>
    <section>
      <title>Related Documents</title>
      <para>[...]</para>
    </section>
  </section>
  <section>
    <title>ANOTHER SECTION</title>
    <para>This section provides [...]</para>
  </section>
</article>

This generates the following HTML code:

  <html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>Document Title</title>
  <meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1">
  <link rel="stylesheet" href="style.css" type="text/css">
  <link rel="stylesheet" href="print.css" type="text/css" media="print">
  <!--[if IE]>
          <link type="text/css" rel="stylesheet" href="ie.css">
          <![endif]-->
  </head>
  <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  <div class="article" title="Document Title">
    <div class="titlepage">
      <div>
        <div>
          <h1 class="title"><a name="d0e1"></a>Document Title</h1>
        </div>
      </div>
      <hr>
    </div>
    <div class="toc">
      <p>
        <b>Table of Contents</b>
      </p>
      <dl>
        <dt><span class="section"><a href="#d0e7">INTRODUCTION</a></span></dt>
        <dd>
        <dl>
          <dt><span class="section"><a href="#d0e10">Overview</a></span></dt>
          <dt><span class="section"><a href="#d0e15">More Information</a></span></dt>
          <dt><span class="section"><a href="#d0e20">Aim</a></span></dt>
          <dt><span class="section"><a href="#d0e48">Related Documents</a></span></dt>
        </dl>
        </dd>
        <dt><span class="section"><a href="#d0e53">ANOTHER SECTION</a></span></dt>
      </dl>
    </div>
    <div class="section" title="INTRODUCTION">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a name="d0e7"></a>INTRODUCTION</h2>
          </div>
        </div>
      </div>
      <div class="section" title="Overview">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a name="d0e10"></a>Overview</h3>
            </div>
          </div>
        </div>
        <p>
          This document defines [...]
        </p>
      </div>
      <div class="section" title="More Information">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a name="d0e15"></a>More Information</h3>
            </div>
          </div>
        </div>
        <p>
          [...]
        </p>
      </div>
      <div class="section" title="Aim">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a name="d0e20"></a>Aim</h3>
            </div>
          </div>
        </div>
        <p>
          This Document will be used to [...]
        </p>
        <div class="table">
          [irrelevant table code]
        </div>
        <br class="table-break">
      </div>
      <div class="section" title="Related Documents">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a name="d0e48"></a>Related Documents</h3>
            </div>
          </div>
        </div>
        <p>
          [...]
        </p>
      </div>
    </div>
    <div class="section" title="ANOTHER SECTION">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a name="d0e53"></a>ANOTHER SECTION</h2>
          </div>
        </div>
      </div>
      <p>
        This section provides [...]
      </p>
    </div>
  </div>
  </body>
  </html>

Thanks!

~Slampisko

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:42:53+00:00Added an answer on June 12, 2026 at 12:42 pm

    Create a customization of the template named “section.heading” in sections.xsl. Below is an excerpt from that template. You only need to change $level + 1 to $level.

    <!-- HTML H level is one higher than section level -->
    <xsl:variable name="hlevel">
      <xsl:choose>
        <!-- highest valid HTML H level is H6; so anything nested deeper
             than 5 levels down just becomes H6 -->
        <xsl:when test="$level &gt; 5">6</xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$level + 1"/>   
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:element name="h{$hlevel}">
      <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
      <xsl:if test="$css.decoration != '0'">
        <xsl:if test="$hlevel&lt;3">
          <xsl:attribute name="style">clear: both</xsl:attribute>
        </xsl:if>
      </xsl:if>
      <xsl:if test="$allow-anchors != 0 and $generate.id.attributes = 0">
        <xsl:call-template name="anchor">
          <xsl:with-param name="node" select="$section"/>
          <xsl:with-param name="conditional" select="0"/>
        </xsl:call-template>
      </xsl:if>
      <xsl:if test="$generate.id.attributes != 0 and not(local-name(.) = 'appendix')">
        <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
      </xsl:if>
      <xsl:copy-of select="$title"/>
    </xsl:element>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.