Increment a value in XSLT

后端 未结 4 988
深忆病人
深忆病人 2020-12-09 02:36

I\'m reasonably new to xlst and am confused as to whether there is any way to store a value and change it later, for example incrementing a variable in a loop.

I\'m

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 03:12

    XSLT is a functional language and among other things this means that variables in XSLT are immutable and once they have been defined their value cannot be changed.

    Here is how the same effect can be achieved in XSLT:

    
     
     
    
     
       
        
            
            
             
            
        
       
     
    
    

    when this transformation is applied on the following XML document:

    
     
      
      
      
      
      
     
    
    

    the result is:

    
        $i = 1
        $i = 2
        $i = 3
        $i = 4
        $i = 5
    
    

提交回复
热议问题