Open source command line tool for Linux to diff XML files ignoring element order

后端 未结 6 1599
走了就别回头了
走了就别回头了 2021-02-04 09:57

Is there an open source command-line tool (for Linux) to diff XML files which ignores the element order?

Example input file a.xml:



        
6条回答
  •  耶瑟儿~
    2021-02-04 10:49

    if you wanted to take this to an arbitrary degree, you could implement something that walks the two trees together and decides along the way which elements "match" between the two documents. that'd let you implement the matching logic any way you want. here is an example in xslt 2.0:

    
    
        
    
        
    
        
            
                
                 
            
        
    
        
    
        
            
            
            
        
    
        
            
            
            
            
        
    
        
            
            
            
                
            
        
    
        
    
        
        
            
            
    
            
                
                    
                    
                
            
    
            
                
                    FAIL
                
                
                    PASS
                
            
    
        
    
        
        
            
            
                
                    
                
                
                    
                
                
                    
                
            
        
    
        
        
            
            
        
    
        
        
            
        
    
        
        
            
                
            
        
    
        
        
            
        
    
        
        
            
                
            
        
    
        
        
            
    
            
                
                    
                    
                
    
                
                    
                        
                    
                    
                        
                            
                            
                        
                    
                
            
    
        
    
        
        
            
            
            
    
            
                
                    
                    
                        
                            
                        
                    
    
                    
                        
                            
                            
                                
                                
                                
                            
                        
                        
                            
                                
                                
                                
                            
                        
                    
    
                
                
                    
                        
                    
                    
                        
                    
                
            
    
        
    
        
        
            
            
    
            
    
            
                
                    
                        
                            
                        
                    
    
                    
                        
                            
                                
                            
                        
                        
                            
                        
                    
                    
                        
                        
                    
                
                
                    
                
                
                    
                
            
    
        
    
    
    

    applied to this document (based on your test case), the result is PASS:

    
      
        
          
          
          
        
        
          
          
        
        
          
          
        
      
      
        
          
          
          
        
        
          
          
        
        
          
          
        
      
    
    

提交回复
热议问题