XSLT Grouping Siblings

前端 未结 6 1320
滥情空心
滥情空心 2021-01-05 11:23

I am trying to group sibling data in an XML file.

Given :



    
             


        
6条回答
  •  悲哀的现实
    2021-01-05 12:01

    This is easy to do when the following is true (which I assume it is):

    • all s within a are unique
    • only the s right after a given belong to it
    • there is no without a element before it

    This XSLT 1.0 solution:

    
    
      
    
      
        
          
        
      
    
      
        
          
        
      
    
      
        
          
            
          
          
        
      
    
    
    

    produces:

    
      
        
          team a v team b
          team c v team d
        
        
          team e v team f
        
        
          team g v team h
          team i v team j
          team k v team l
        
        
    
    

    Note the use of an to match all s that belong to ("are preceded by") a given .

    A slightly shorter but less obvious solution would be a modified identity transform:

    
    
      
    
      
        
          
        
      
    
      
        
          
            
          
          
        
      
    
    
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题