XSLT group if condition is matched

后端 未结 1 1921
孤街浪徒
孤街浪徒 2021-01-28 03:29

INPUT:

  


    


    
             


        
1条回答
  •  说谎
    说谎 (楼主)
    2021-01-28 03:56

    I think it is better to prevent duplicates in MSTP and MSONPC and put them into one template where input parameter will be non-duplicated VRPlanId as in XSL below:

     
         
        
                 
                          
                                  
                
                              
                                       
                                      
                                                           
                                             
                 
                                    
                
                                
                                     
                                        
                                                           
                                             
            
             
                 
        
    
                
                        
                             
                                        
                                                                           
                            
                                                                                            
                                                                                   
                                                                
                        
                                           
                                               
                                                       
                                                                
                                                                                              
                                                                                               
                                                           
                                                                        
                                                                 
                                                                                                
                                                                                                                   
                                                                                                           
                                                                        
                                                                               
                                                       
                                                                  
                                       
                               
                                     
               
        
    
    

    You have edited your version of XML but in case of XML below:

    
    
    
        
    
    
        
            
                
                    
                        
                            
                        
                        
                            
                        
                        
                                                          
                                1                               
                                22
                                11310224                                
                                221 
                            
                            
                                1
                                22
                                11310224 
                                2211 
                            
                             
                                3 
                                
                                11310337 
                                 
                            
                             
                                2 
                                
                                11310281 
                                2221 
                            
                             
                                4 
                                33
                                11310281 
                                222221 
                            
                             
                                4 
                                331
                                11310281 
                                222221 
                            
                        
                    
                
            
        
    
    
    

    The result is:

    
    
        
            
                
                
            
        
        
            
                
                
            
        
    
    

    NOTE! In proposed XSL there is validation for empty values, if you will require include them just remove that validations.

    In case when it is required to use each attribute value in separate task tag then you can create task blocks structure in separate template and call it in parameters block as below:

     
         
        
                 
            
            
                
                              
                    
                        
                            
                                
                            
                                                                           
                                                           
                
                
                                
                    
                        
                                                                                 
                                
                            
                                        
                                                           
                            
                                                               
        
    
                
                        
                             
                     
                                                       
                                                                                        
                                                                                                                                                       
                                                                                                                   
                                                                                                 
                                                                                                
                                                                                                                   
                                                                                                           
                                                                        
                                                                               
                                                       
                                                                                                                                              
                               
                                     
               
        
    
    

    Then when you will check it with XML above the result will be as below:

    
    
        
            
                
                    
                    
                    
                
                
            
        
        
            
                
                
            
        
        
            
                
                    
                    
                    
                    
                
                
            
        
    
    

    Of course you can add blank values validation where it is required.

    Hope it will help with your case.

    0 讨论(0)
提交回复
热议问题