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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:13:45+00:00 2026-05-31T03:13:45+00:00

Is it possible to have a for-each in which the counter is an attribute

  • 0

Is it possible to have a for-each in which the counter is an attribute value (not a node list)?
Here is what I am trying to do, handling colspan in tables (doesn’t work):

        <xsl:for-each select=".//tr[1]//td">
            <xsl:choose>
                <xsl:when test="@colspan">
                    <xsl:for-each select="@colspan">
                        <fo:table-column/>
                    </xsl:for-each>
                </xsl:when>
                <xsl:otherwise><fo:table-column/></xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>

Thanks!

  • 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-31T03:13:46+00:00Added an answer on May 31, 2026 at 3:13 am

    In XSLT 2.0:

    <xsl:for-each select="1 to xs:integer(@colspan)">
     <fo:table-column/>
    </xsl:for-each>
    

    In XSLT 1.0:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:fo="http://www.w3.org/1999/XSL/Format">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="table[@colspan]">
        <fo:table>
          <xsl:call-template name="generate"/>
        </fo:table>
     </xsl:template>
    
     <xsl:template name="generate">
      <xsl:param name="pTimes" select="@colspan"/>
    
      <xsl:if test="$pTimes > 0">
       <fo:table-column/>
    
       <xsl:call-template name="generate">
         <xsl:with-param name="pTimes" select="$pTimes -1"/>
       </xsl:call-template>
      </xsl:if>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the following XML document:

    <table colspan="3"/>
    

    the wanted, correct result is produced:

    <fo:table xmlns:fo="http://www.w3.org/1999/XSL/Format">
       <fo:table-column/>
       <fo:table-column/>
       <fo:table-column/>
    </fo:table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which I use to match fancybox possible elements: $('a.grouped_elements').each(function(){
Possible Duplicate: Retrieving the last record in each group I have two tables set
Is it possible to have list of key/value pairs within redis? or possibly a
Is it possible to have selective queries in PostgreSQL which select different tables/columns based
Is it possible to have multiple has_many :through relationships that pass through each other
In my understanding each applets are independent entities . Is it possible to have
Let's say I have n marbles, and each can be one of 8 possible
Is it possible have two projects with the same name in flex builder? Here
I have multiple large objects which each have about 60 strings. I have to
I was wondering if its possible, to loop through an array but have each

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.