xslt - adding every n node?

前端 未结 2 1064
粉色の甜心
粉色の甜心 2021-01-14 14:53

I found an elegant solution for that problem here: xsl for-each: add code block every n rows?

I\'d like to understand the xslt code and I was wondering if you could

2条回答
  •  不要未来只要你来
    2021-01-14 15:06

    Here is the complete code you were asking about. I happen to be the author, so let me explain:

     
      
      
    

    The following template overrides the XSLT built-in template for element nodes. It matches every 6k+1th gallery element. It cretes a tr element and inside its body puts the results of processing this gallery element togeether with the next 5. The processing is done in a special mode ("proc") to distinguish this from the default anonymous mode in which the XSLT built-in templates started and continue to operate.

      
       
        
       
      
    

    The following template is invoked in mode "proc" to process every gallery element in a group of 6 that should be in the same row.

     
       
        {gallery-image-alt} 
       
      
    

    The following template overrides the default processing of the XSLT built-in templates for all gallery elements, whose position is not of the type 6k+1 (they are not starting a new 6-tuple). It says simply not to do anything with any such element, because these elements are already processed in "proc" mode.

      
     
    

    You need to acquaint yourself with XSLT's processing model, default processing and built-in templates.

提交回复
热议问题