XSLT : Looping from 1 to 60

后端 未结 5 1206
刺人心
刺人心 2020-12-05 09:34

What is the best way to loop in XSLT from 1 to 60? I research in net, there are some templates to do this, is there any other way for example like a built-in function?

5条回答
  •  一生所求
    2020-12-05 10:03

    The problem with simple recursion when processing long sequences is that often the space for the call stack becomes insufficient and the processing ends due to stack overflow. This typically happens with sequence length >= 1000.

    A general technique to avoid this (implementable with any XSLT processor, even if it doesn't recognize tail-recursion) is DVC (Divide and Conquer) style recursion.

    Here is an example of a transformation that successfully prints the numbers from 1 to 1000000 (1M):

    
         
    
         
          
            
            
          
         
    
         
          
          
    
          
           
            
              
              
    
            
            
              
              
               
               
              
              
               
               
              
            
           
          
         
    
    

    When applied on any XML document (not used) this transformation produces the wanted result -- all the numbers from 1 to 1000000.

    You can use/adapt this transformation for any task that needs to "do something N times".

提交回复
热议问题