XSLT remove child element based on parent-child element's value

后端 未结 1 1708
深忆病人
深忆病人 2021-01-23 15:52

I am trying to use the some what same logic that is used in here https://stackoverflow.com/a/10629806/662877

to a different XML but not getting the intended output.

1条回答
  •  梦谈多话
    2021-01-23 16:39

    The problem is here:

    *[../TERR='KHM6']/CreatePaymentItems
    

    This matches the CreatePaymentItems child of an element that has a sibling TERR with value "KHM6".

    But all siblings of TERR in the provided XML document are child-less.

    Here is the transformation you want:

    
     
     
    
     
         
           
         
     
    
     
    
    

    when applied on the provided XML document (corrected to be well-formed):

    
        
            
                
                    4
                    R2293416
                    3335889530
                    05/03/2012
                    4NZ3330000010
                    599.99
                    599.99
                    1
                    43.65
                    1
                    KHM6
                
            
            
                4
                R2293416
                2293416
            
            
                
                    TOTM
                    4
                    R2293416
                    05/03/2012
                    645.03
                    2293416
                
            
            
                4
                R2293416
                61261585
            
        
    
    

    the wanted, correct result is produced:

    
       
          
             
                4
                R2293416
                3335889530
                05/03/2012
                4NZ3330000010
                599.99
                599.99
                1
                43.65
                1
                KHM6
             
          
          
             4
             R2293416
             2293416
          
       
    
    

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