xsl for-each: add code block every n rows?

前端 未结 3 584
执笔经年
执笔经年 2021-01-06 10:27

I am trying to transform a bit of xml which represents an image gallery into an html table. (it must be done with html and not with css). How do I add the row break

3条回答
  •  情话喂你
    2021-01-06 11:15

    How do I add the row break every six or so columns with xsl?

    In XSLT you don't!

    XSLT processes nodes, not tags.

    Here is the XSLT way of positional grouping:

    
     
     
    
     
      
       
      
     
    
     
      
        {gallery-image-alt}
      
     
    
     
    
    

    when this transformation is applied on the following XML document:

    
        
            http://server/picts/1
            Description 1
        
        
            http://server/picts/2
            Description 2
        
        
            http://server/picts/3
            Description 3
        
        
            http://server/picts/41
            Description 4
        
        
            http://server/picts/5
            Description 5
        
        
            http://server/picts/6
            Description 6
        
        
            http://server/picts/7
            Description 7
        
        
            http://server/picts/8
            Description 8
        
        
            http://server/picts/9
            Description 9
        
    
    

    the wanted, correct result is produced:

    
        
            Description 1
        
        
            Description 2
        
        
            Description 3
        
        
            Description 4
        
        
            Description 5
        
        
            Description 6
        
    
    
        
            Description 7
        
        
            Description 8
        
        
            Description 9
        
    
    

提交回复
热议问题