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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:37:52+00:00 2026-05-26T10:37:52+00:00

I use XSLT to generate an HTML table using info from an XML file.

  • 0

I use XSLT to generate an HTML table using info from an XML file.
I want only 4 TD in every TR.

It works fine on Chrome and Safari. Not in Firefox. I understand that Firefox doesn’t support ‘disable-output-escaping’ so I know that is the problem (it just writes on the web page) . Is there another way to generate this kind of (simple) table with XSLT on client side?

My code looks like this:

<table>
<xsl:for-each select="movies/movie">
   <xsl:if test="(position() = 1) or ((position() mod 4) = 1)">
       <!-- This is a <tr> -->
      <xsl:text disable-output-escaping="yes">&lt;tr&gt;</xsl:text>
   </xsl:if>
   <td>
     <!-- Some stuff goes here. -->
   </td>
   <xsl:if test="((position() mod 4) = 0) or (position() = last())">
       <!-- This is a </tr> -->
      <xsl:text disable-output-escaping="yes">&lt;/tr&gt;</xsl:text>
   </xsl:if> 
</xsl:for-each>
</table>
  • 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-26T10:37:52+00:00Added an answer on May 26, 2026 at 10:37 am
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="/">
        <table>
          <xsl:apply-templates select="movies/movie[position() mod 4 = 1]"/>
        </table>
      </xsl:template>
    
      <xsl:template match="movie">
        <tr>
          <xsl:for-each select=". | following-sibling::movie[position() &lt; 4]">
            <td>
              <xsl:value-of select="."/>
            </td>
          </xsl:for-each>
        </tr>
      </xsl:template>
    
    </xsl:stylesheet>
    

    Input XML:

    <movies>
      <movie>a</movie>
      <movie>b</movie>
      <movie>c</movie>
      <movie>d</movie>
      <movie>e</movie>
      <movie>f</movie>
      <movie>g</movie>
      <movie>h</movie>
    </movies>
    

    Output XML:

    <table>
      <tr>
        <td>a</td>
        <td>b</td>
        <td>c</td>
        <td>d</td>
      </tr>
      <tr>
        <td>e</td>
        <td>f</td>
        <td>g</td>
        <td>h</td>
      </tr>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use SSRS to generate an XML file using XSLT. All is fine, except
I use this code to transform XML to HTML using XSLT template: string uri
I use VS 2008, .net 3.5 for generate page html using XSLT. I have
I'm trying to use XSLT text output to generate a file (in a file
I have an XML document with un-namespaced elements, and I want to use XSLT
I am trying to generate HTML which will display the data from XML through
For a given xml, I need to generate a html table to represent the
I needed to use XSL to generate simple plain text output from XML. Since
In my XSLT file. I use the document() function <xsl:variable name=Publicity select=document('./publicity.xml') /> and
The use of XSLT (XML Stylesheet Language Transform) has never seen the same popularity

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.