How to select the grandparent of a node using xslt

前端 未结 2 1566
悲&欢浪女
悲&欢浪女 2021-02-04 15:56

I\'m in a situation where I can only test for the child node, but I have to apply tags to the grandparent of this child node.

I\'ve tried using:



        
2条回答
  •  眼角桃花
    2021-02-04 16:08

    I've tried using:

     
    

    and:

    
    

    But neither works.

    Certainly it will not "work", because the instruction doesn't have a select attribute!

    You may pass parameters using children of the instruction, like this:

    
      
    
    

    For the select attribute of the Use:

    For a real grandparent:

    ../..
    

    for the closest ancestor element with name someName:

    ancestor::someName[1]
    

    for the closest ancestor element with name contained in the variable $ancName:

    ancestor::*[name()=$ancName][1]
    

提交回复
热议问题