empty cells in a row in a table - how can I hide them

View: New views
4 Messages — Rating Filter:   Alert me  

empty cells in a row in a table - how can I hide them

by jlr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a table that may have empty cells in a row, how can I hide them?  
Below is an example of my code.  I have stripped out all attributes thinking
that maybe something is causing the rows not to hide.  
I am very new at this stuff, so any comments is much appreciated.

Thanks much,
jlr

CODE:

   <fo:table-row  >
                   <fo:table-cell  border="solid black 0.5px" empty-cells="hide">
                        <fo:block >
                            <xsl:value-of select="header/column9"/>
                        </fo:block>                  
                  </fo:table-cell>
                  <fo:table-cell  border="solid black 0.5px" empty-cells="hide">
                        <fo:block >
                            <xsl:value-of select="header/column10"/>
                        </fo:block>                      
                  </fo:table-cell>                  
                   <fo:table-cell border="solid black 0.5px" empty-cells="hide">
                        <fo:block >
                            <xsl:value-of select="header/column11"/>
                        </fo:block>                      
                  </fo:table-cell>
                  <fo:table-cell border="solid black 0.5px" empty-cells="hide">
                        <fo:block>
                            <xsl:value-of select="header/column12"/>
                        </fo:block>                    
                  </fo:table-cell>                
               </fo:table-row>        

Re: empty cells in a row in a table - how can I hide them

by Tony Graham-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Thu, May 01 2008 23:16:42 +0100, jean.stachler@... wrote:
> I have a table that may have empty cells in a row, how can I hide them?  
> Below is an example of my code.  I have stripped out all attributes thinking
> that maybe something is causing the rows not to hide.  
> I am very new at this stuff, so any comments is much appreciated.

xsl:if is likely all that you need, but it would help if you could
provide a sample of your input XML, both for a row that has data and for
one that does not, so we can better work out how to help you.

Regards,


Tony Graham                         Tony.Graham@...
Director                                  W3C XSL FO SG Invited Expert
Menteith Consulting Ltd
XML, XSL and XSLT consulting, programming and training
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
Registered in Ireland - No. 428599   http://www.menteithconsulting.com
  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
xmlroff XSL Formatter                               http://xmlroff.org
xslide Emacs mode                  http://www.menteith.com/wiki/xslide
Unicode: A Primer                               urn:isbn:0-7645-4625-2


Re: empty cells in a row in a table - how can I hide them

by jlr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here is a copy of the XML data.  
The code below shows two rows of data, and three blank rows.
If it is possible, I do not want to show the rows with empty elements.

Below is the data for the XML file and further down is the .xsl code.

Thank you,
jlr

XML File shown below:

- <row>
  <column1>1</column1>
  <column2>1</column2>
  <column3>ea</column3>
  <column4>VFD for trolley panel so we can have a two speed control for north and south travel.</column4>
  <column5>2/23/2007</column5>
  <column6>950</column6>
  <column7>950</column7>
  <column8>Unknown</column8>
  </row>
- <row>
  <column1>2</column1>
  <column2>2</column2>
  <column3>ea</column3>
  <column4>VFD for trolley panel so we can have a two speed control for up and down travel.</column4>
  <column5>2/23/2007</column5>
  <column6>1650</column6>
  <column7>3300</column7>
  <column8>Unknown</column8>
  </row>
- <row>
  <column1 />
  <column2 />
  <column3 />
  <column4 />
  <column5 />
  <column6>0.0</column6>
  <column7>0.0</column7>
  <column8 />
  </row>
- <row>
  <column1 />
  <column2 />
  <column3 />
  <column4 />
  <column5 />
  <column6>0.0</column6>
  <column7>0.0</column7>
  <column8 />
  </row>
  <TotalTitle>Total:</TotalTitle>
  <FinalTotal>4250.0</FinalTotal>
 
CODE for .xsl file:    
<!--Item listing for detail rows of Detail table-->

        <fo:block  text-align="left">
          <fo:table table-layout="fixed" >                                          
          <fo:table-column column-width="15mm"/>
          <fo:table-column column-width="20mm"/>
          <fo:table-column column-width="14mm"/>
          <fo:table-column column-width="50mm"/>
          <fo:table-column column-width="18mm"/>
          <fo:table-column column-width="20mm"/>
          <fo:table-column column-width="24mm"/>
          <fo:table-column column-width="14mm"/>
           
          <fo:table-body>
              <xsl:for-each select="header/row">        
                  <fo:table-row border-after-style="double" >                  
                     <fo:table-cell  xsl:use-attribute-sets="cell-padding"  border="solid black 0.5px" >                      
                       <fo:block xsl:use-attribute-sets="detailtablecenter">                                  
                            <xsl:value-of select="column1"/>
                       </fo:block>      
                    </fo:table-cell>
                    <fo:table-cell  xsl:use-attribute-sets="cell-padding"  border="solid black 0.5px" >        
                       <fo:block xsl:use-attribute-sets="detailtablecenter">          
                         <xsl:value-of select="column2"/>
                       </fo:block>                
                    </fo:table-cell>
                    <fo:table-cell xsl:use-attribute-sets="cell-padding" border="solid black 0.5px" >                                        
                       <fo:block xsl:use-attribute-sets="detailtablecenter">        
                         <xsl:value-of select="column3"/>
                        </fo:block>  
                    </fo:table-cell>
                    <fo:table-cell xsl:use-attribute-sets="cell-padding" border="solid black 0.5px" >  
                        <fo:block xsl:use-attribute-sets="detailtableleft">        
                           <xsl:value-of select="column4"/>
                         </fo:block>                                  
                   </fo:table-cell>      
                   <fo:table-cell xsl:use-attribute-sets="cell-padding" border="solid black 0.5px" >                                                        
                        <fo:block xsl:use-attribute-sets="detailtablecenter">        
                            <xsl:value-of select="column5"/>
                        </fo:block>  
                   </fo:table-cell>
                   <fo:table-cell xsl:use-attribute-sets="numeric-cell" border="solid black 0.5px" >  
                       <xsl:variable name="q">
                            <xsl:value-of select="column6"/>
                      </xsl:variable>
                        <fo:block xsl:use-attribute-sets="detailtableright">                            
                                <xsl:value-of select="format-number($q,'$###,###,###.####')"/>                        
                     </fo:block>                                  
                 </fo:table-cell>                
                 <fo:table-cell  xsl:use-attribute-sets="numeric-cell"  border="solid black 0.5px" >      
                    <xsl:variable name="q">
                            <xsl:value-of select="column7"/>    
                    </xsl:variable>                                              
                     <fo:block xsl:use-attribute-sets="detailtableright">  
                           <xsl:value-of select="format-number($q,'$###,###,###.##')"/>                                            
                     </fo:block>  
                 </fo:table-cell>
                 <fo:table-cell xsl:use-attribute-sets="cell-padding" border="solid black 0.5px" >  
                     <fo:block xsl:use-attribute-sets="detailtablecenter">    
                          <xsl:value-of select="column8"/>                      
                     </fo:block>                                  
                </fo:table-cell>                          
             </fo:table-row>    
 <!--End of Item listing for detail rows of Detail table-->

            </xsl:for-each>
          </fo:table-body>
        </fo:table>
     </fo:block>        

Tony Graham-3 wrote:
On Thu, May 01 2008 23:16:42 +0100, jean.stachler@crown.com wrote:
> I have a table that may have empty cells in a row, how can I hide them?  
> Below is an example of my code.  I have stripped out all attributes thinking
> that maybe something is causing the rows not to hide.  
> I am very new at this stuff, so any comments is much appreciated.

xsl:if is likely all that you need, but it would help if you could
provide a sample of your input XML, both for a row that has data and for
one that does not, so we can better work out how to help you.

Regards,


Tony Graham                         Tony.Graham@MenteithConsulting.com
Director                                  W3C XSL FO SG Invited Expert
Menteith Consulting Ltd
XML, XSL and XSLT consulting, programming and training
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
Registered in Ireland - No. 428599   http://www.menteithconsulting.com
  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
xmlroff XSL Formatter                               http://xmlroff.org
xslide Emacs mode                  http://www.menteith.com/wiki/xslide
Unicode: A Primer                               urn:isbn:0-7645-4625-2

Re: empty cells in a row in a table - how can I hide them

by Tony Graham-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Mon, May 05 2008 00:03:02 +0100, jean.stachler@... wrote:
...

> - <row>
>   <column1>2</column1>
>   <column2>2</column2>
>   <column3>ea</column3>
>   <column4>VFD for trolley panel so we can have a two speed control for up
> and down travel.</column4>
>   <column5>2/23/2007</column5>
>   <column6>1650</column6>
>   <column7>3300</column7>
>   <column8>Unknown</column8>
>   </row>
> - <row>
>   <column1 />
>   <column2 />
>   <column3 />
>   <column4 />
>   <column5 />
>   <column6>0.0</column6>
>   <column7>0.0</column7>
>   <column8 />
>   </row>

...
>           <fo:table-body>
>               <xsl:for-each select="header/row">        

The thing to do is use a predicate so you only process the <row>
elements that have useful content.

There's many ways to do that.  I don't know what would make the most
sense to someone who understood the meaning of the data.  You can try:

   <xsl:for-each select="header/row[column1 != '']">

or:

   <xsl:for-each select="header/row[column1/text()]">

or:

   <xsl:for-each select="header/row[column6 != 0]">

Regards,


Tony Graham                         Tony.Graham@...
Director                                  W3C XSL FO SG Invited Expert
Menteith Consulting Ltd
XML, XSL and XSLT consulting, programming and training
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
Registered in Ireland - No. 428599   http://www.menteithconsulting.com
  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
xmlroff XSL Formatter                               http://xmlroff.org
xslide Emacs mode                  http://www.menteith.com/wiki/xslide
Unicode: A Primer                               urn:isbn:0-7645-4625-2