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

Ask A Question

Stats

  • Questions 253k
  • Answers 253k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think (like Ed said) I would resolve this by… May 13, 2026 at 9:56 am
  • Editorial Team
    Editorial Team added an answer The first which comes to mind is to have something… May 13, 2026 at 9:56 am
  • Editorial Team
    Editorial Team added an answer Because $(this) references to the <li> element, and by using… May 13, 2026 at 9:56 am

Related Questions

I am trying to traverse through a simple sitemap (adding and deleting elements on
i am trying to traverse a node attributes ..in below xml ,i need to
I am trying to traverse a task_struct's children in the linux kernel and get
i am trying to traverse a given directory and create a list of files

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.