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 6948737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:51:44+00:00 2026-05-27T13:51:44+00:00

I need to render the following format in XSLT. I have a <xsl:for-each loop

  • 0

I need to render the following format in XSLT. I have a <xsl:for-each loop with 5 elements (Text1, Text2… Text5) and need to wrap an ul tag after every three elements. Any suggestions please?

<ul>
    <li>Text1</li>
    <li>Text2</li>
    <li>Text3</li>
</uL>
<ul>
    <li>Text4</li>
    <li>Text5</li>
</uL>
  • 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-05-27T13:51:45+00:00Added an answer on May 27, 2026 at 1:51 pm

    Good question, +1.

    This transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="thing[position() mod 3 = 1]">
      <ul>
       <xsl:apply-templates mode="inGrpoup" select=
        ".|following-sibling::*[not(position() > 2)]"/>
      </ul>
     </xsl:template>
    
     <xsl:template match="thing" mode="inGrpoup">
      <li><xsl:value-of select="."/></li>
     </xsl:template>
     <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    when applied on the following XML document:

    <things>
        <thing>1</thing>
        <thing>2</thing>
        <thing>3</thing>
        <thing>4</thing>
        <thing>5</thing>
        <thing>6</thing>
        <thing>7</thing>
        <thing>8</thing>
    </things>
    

    produces the wanted, correct result (things in groups of consecutive three):

    <ul>
       <li>1</li>
       <li>2</li>
       <li>3</li>
    </ul>
    <ul>
       <li>4</li>
       <li>5</li>
       <li>6</li>
    </ul>
    <ul>
       <li>7</li>
       <li>8</li>
    </ul>
    

    Explanation:

    1. Template pattern matching the first thing of a group of three thing elements.

    2. Using modes to process a group of thing elements (in a different way than the processing of the initial starting thing), once determined.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following g:render tag in a gsp page: <g:render template=/artist/rate model='[artistID: 1,
I have a report which is composed of several subreports. I need to render
I have an issue where I need to format html that's stored in a
I need to render the following form: One Radio must be followed by Data
I need to render quite alot (tens of thousands) images off-screen using OpenGL. I
I need to render JSON data in my JSPs for some AJAX requests. I'd
I need to render a partial view to a string within a controller action.
I'm writing a game in python with pygame and need to render text onto
I'm writing a retro type game for the iPhone, and need to render a
Why is there a need to explicitly call GridView.DataBind() to render the gridview. Why

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.