Move separator elements upwards in xml hierarchy

后端 未结 2 1281
耶瑟儿~
耶瑟儿~ 2021-01-03 11:49

I have an xml document with separators deep down in the hierarchy.


  
    
    
    

        
2条回答
  •  一生所求
    2021-01-03 12:24

    This stylesheet:

    
        
        
            
                
                    
                
                
            
        
        
            
                
            
        
    
    

    Output:

    
        
            
        
    
    
    
        
            
        
        
            
        
    
    
    
        
            
        
    
    

    Note: Grouping by following separator, adding last third level element for posible C without following separator.

    Edit: More pull style, more schema agnostic, this stylesheet:

    
        
        
        
            
                
            
            
        
        
            
                
            
        
    
    

    EDIT 2: More general solution (one thing I do not trust, ja!)

    
        
            
            
                
                    
                
            
            
                
            
        
        
            
            
                
                
                    
                        
                            
                        
                    
                
                
            
        
        
    
    

    Note: Mostly a fine grained traversal. A floor hierarchy rule (in this case root element) copying itself and separator (dummy node for last group without following separator) passing remainder separators to process first child with enough following separators to process. A modified fine grained traversal identity rule, copying itself and again processing first child and following sibling with enough following separators to process. At last, a separator rule breaking the process.

    Edit 3: Other more general solution, now with recursive identity rule

    
        
        
        
            
            
                
                    
                
            
        
        
            
            
                
                
                    
                        
                    
                
                
            
        
        
    
    

    Edit 4: Now just the same as before but with key test instead of node set intersection.

    
        
        
        
            
            
                
                    
                
            
        
        
            
            
                
                
                    
                        
                    
                
                
            
        
        
    
    

提交回复
热议问题