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

  • Home
  • SEARCH
  • 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 159411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:51:16+00:00 2026-05-11T10:51:16+00:00

I am trying to traverse Docbook section nodes. Their structure are as follows: <sect1>

  • 0

I am trying to traverse Docbook section nodes. Their structure are as follows:

<sect1>    <sect2>       <sect3>          <sect4>             <sect5>             </sect5>          </sect4>       </sect3>    </sect2> </sect1> 

So sect1 only have sect2 inside, sect2 will only have sect3 inside, and so on. We can also have multiple sub nodes within a node; for instance multiple sect2 within a sect1.

Programatically I would iterate through them recursively using a counter for keeping track of which section the loop is at.

This time I have to use XSLT and to loop through it. Thus is there an equivalent way, or better way of doing this in XSLT?

Edit: I already have similar code as suggested by Willie, where I specify every sect node (sect1 to sect5). I am looking for solution where it loops determining the sect node by itself, and I won’t have to repeat code. I am aware that Docbook specs only allows up to 5 nested nodes.

  • 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. 2026-05-11T10:51:16+00:00Added an answer on May 11, 2026 at 10:51 am

    If you are doing the same processing to all sect{x} nodes, regardles of {x}, as you say in one of the comments, then the following is sufficient:

    <xsl:stylesheet version='1.0'  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>     <xsl:template match=      'sect1|sect2|sect3|sect4|sect5'>       <!-- Some processing here -->       <xsl:apply-templates/>     </xsl:template> </xsl:stylesheet> 

    If you really need to process in the same way many more elements having different names of the form ‘sect'{x} (let’s say x is in the range [1, 100]), then the following can be used:

    <xsl:stylesheet version='1.0'  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>     <xsl:template match=      '*[starts-with(name(), 'sect')       and         substring-after(name(), 'sect') >= 1       and         not(substring-after(name(), 'sect') > 101)        ]'>       <!-- Some processing here -->       <xsl:apply-templates/>     </xsl:template> </xsl:stylesheet> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to think of a way to traverse a hierarchical structure, like
I have a fully built generic Trie in java. I am trying to traverse
I have an XML document I'm trying to traverse, which is SDMX-compliant. Here's a
I am trying to traverse the nodes of the DevExpress.XtraTreeList.TreeList and it isn't working.
i am trying to traverse a given directory and create a list of files
I'm a newbie to selenium. I'm trying to traverse all the elements in a
i am trying to traverse an html document: <body class=style_0> <div> <div class=style_1>Pending Test
I'm trying to traverse an XML document and select certain node attributes. The XML
I'm trying to traverse an AJAX response, which contains a remote web page (an
I thought this would be pretty academic but its not. I'm trying to traverse

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.