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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:05:38+00:00 2026-06-11T09:05:38+00:00

Using XSLT, I need to remove a complete table column (header + body cells)

  • 0

Using XSLT, I need to remove a complete table column (header + body cells) when a column contains only “0.00” or “-“.

i.e. If all the values in the cells of one or more columns are 0.00/- then the whole column(s) should be removed.

  • 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-06-11T09:05:39+00:00Added an answer on June 11, 2026 at 9:05 am

    I have assumed that you mean’t to say if all the data cells of the column are 0.00/- then remove it, not just one of them. If I have misunderstood, please advise and I will update the solution style-sheets accordingly.

    There are a lot of different ways and options to create tables, and so your solution will need to be adjusted to the type and structure of your table. Shown here is a solution for a simple form of table.

    XSLT 1.0 Solution

    This XSLT 1.0 style-sheet…

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
    <xsl:strip-space elements="*"/>
    
    <xsl:template name="ident" match="@*|node()">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
    </xsl:template>
    
    <xsl:template match="td">
      <xsl:variable name="col" select="count(preceding-sibling::td)+1" />
      <xsl:if test="../../tr/td[$col][. != '0.00'][. != '-']">
        <xsl:call-template name="ident" />
      </xsl:if>  
     </xsl:template>
    
    </xsl:stylesheet>
    

    …when applied to this input document…

    <table>
      <th>
        <td>Contestant</td><td>Score</td><td>Country</td>
      </th> 
      <tr>
        <td>Jack</td><td>0.00</td><td>AUS</td>
      </tr> 
      <tr>
        <td>Jill</td><td>-</td><td>-</td>
      </tr> 
    </table> 
    

    …will yield…

    <table>
      <th>
        <td>Contestant</td>
        <td>Country</td>
      </th>
      <tr>
        <td>Jack</td>
        <td>AUS</td>
      </tr>
      <tr>
        <td>Jill</td>
        <td>-</td>
      </tr>
    </table>
    

    Only one column is removed – the one with all “empty” non-header cells.

    XSLT 2.0 Solution

    And here is the XSLT 2.0 equivalent…

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
    <xsl:strip-space elements="*"/>
    
    <xsl:template match="@*|node()">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
    </xsl:template>
    
    <xsl:template match="td[ not(
      for $c in count(preceding-sibling::td)+1 return
        ../../tr/td[$c][.!='0.00'][.!= '-']  )]" />
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to transform one XML document into another using XSLT (for now from
I am trying to remove nodes from an XML file. Using just one XSLT
I need to perform a find and replace using XSLT 1.0 which is really
I am using xslt 2.0 for transforming one xml format to another xml format.But
I need to convert default mysql modtimes into UTC formated datetimes using xslt. I
I use SSRS to generate an XML file using XSLT. All is fine, except
I am traversing an XML file (that contains multiple tables) using XSLT. Part of
I'm using XSLT 1.0 and need to convert a date format from dd/mm/yyyy to
I need to make a CSV-parser using XSLT 1.0. I have tried a recursive
I'm using xslt to create onscreen pdf's from xml and I need to hide

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.