XSLT & XSL-FO: Creating a table with multiple rows?

前端 未结 2 1739
隐瞒了意图╮
隐瞒了意图╮ 2021-01-27 03:34

I\'m fairly new to XSLT and I am stuck with a problem where I have an Element with an unknown amount of children, and I need to display these children in a table such that there

2条回答
  •  隐瞒了意图╮
    2021-01-27 04:15

    The previous answers are way to complicated for what should be (and is) easy. Recursion is not required for such a simple thing.

    In XSL FO you do not need to structure tables with rows. You can use the attribute "ends-row" to specify that you are ending a row and starting a new one. You can easily adapt this simple example and even pass in the "number of columns" (see the mod 5 ... which means after every fifth one start a new row ... change to 4 or 8 or whatever you wish) ... You would just create the structure for the table (fo:table and fo:table-body) outside of this. Inside the table body just put cells as children like this template does:

      
        
        
            
                true
            
            
                
            
        
    
    

    So putting this into a simple example with your data ... see below. Formats your XML into five columns per row.

    
    
        
            
                
                    
                    
                    
                
            
            
                
        
                
            
        
    
        
            
                
                    
                
            
        
        
            
            
                
                    true
                
                
                    
                
            
        
    
    
    

提交回复
热议问题