How to match and wrap identical and adjacent node together in XSLT 1.0?

前端 未结 2 1958
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-15 14:36

I have an XML file that look like this and I\'m trying to wrap \"Para_bb\" node that are adjacent to each other with a div.



        
2条回答
  •  没有蜡笔的小新
    2021-01-15 15:10

    One way to do this in XSLT 1.0 is to have a template that matches the first occurrence of each Para_bb element in a group

    
    

    Then you would call a new template, with a mode specified, just on this first element

        

    Then, in the template matching Para_bb with the mode specified, you would copy the element, and select the next sibling, but only if it is another Para_bb

    
        
        
    
    

    (Where the named template being called is the standard identity template)

    Try this XSLT

    
        
    
        
            

提交回复
热议问题