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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:31:59+00:00 2026-05-14T19:31:59+00:00

How to use xsl:for-each in xslt to get value iteratively from an xml file

  • 0

How to use xsl:for-each in xslt to get value iteratively from an xml file and to dispaly it in table fromat

For example: the xml file is like

<order>
  <item name ="a"/>
  <item name ="b"/>  
  <item name ="c"/>
  <item name ="d"/>
  <item name ="e"/>
  <item name ="f"/>
  <item name ="g"/>
</order>

and the output should be

  a    b    c   d

  e    f    g

the loop should count the item and if it is divisble by 4 it

should close the current row and add a new row and so on..

i’m using the following xslt for this

but i can not display it in table format

   <xsl:template match="/">
    <html>
    <body>
     <xsl:call-template name ="incr">
        <xsl:with-param name ="value">1</xsl:with-param>
        <xsl:with-param name ="limit">
          <xsl:value-of select ="count(//item)"/>
        </xsl:with-param>
      </xsl:call-template>
  </body>
</html>
</xsl:template >
<xsl:template name="incr">
  <xsl:param name="value"/>
  <xsl:param name ="limit"/>
  <xsl:if test ="$value!=$limit+1">
    <xsl:value-of select ="//item[$value]/@name"/>
    <xsl:if test ="$value mod 4 =0">
      <br/>
      <br/>
    </xsl:if>
    <xsl:call-template name ="incr">
      <xsl:with-param name ="value" select ="$value+1"/>
      <xsl:with-param name ="limit" select ="$limit"/>
    </xsl:call-template>
  </xsl:if>

</xsl:template>

please help me to do this

Thanks in advance

  • 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-14T19:32:00+00:00Added an answer on May 14, 2026 at 7:32 pm
    <table> 
     <tr> 
      <xsl:for-each select="//order/item"> 
       <td> 
        <xsl:value-of select ="current()/@name"/> 
       </td> 
       <xsl:if test="position() mod 4 = 0"> 
        <xsl:text disable-output-escaping="yes"><![CDATA[</tr><tr>]]></xsl:text> 
       </xsl:if> 
      </xsl:for-each> 
     </tr> 
    </table> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use XSLT to generate an HTML table using info from an XML file.
I have an XSLT like below, and want to use apply-templates inside the xsl:for-each
I use a xsl tranform to convert a xml file to html in dotNet.
I have a xsl file where i need to use parameters from an external
I'm trying to retrieve the attribute value from an xsl:param and use it in
I'm new to XSLT. I know I need to use xsl:for-each-group, but I can't
Can i use a Select within a concat in xslt? eg <xsl:for-each select=root/OrderItems/lineitem> <xsl:element
I needed to use XSL to generate simple plain text output from XML. Since
I am trying to extract the forecast data from XML file to my XSLT
I'm trying to use XSL-stylesheets in order to transform some generated XML-data to HTML-output.

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.