What is the difference between name() and local-name()?

前端 未结 1 1273
死守一世寂寞
死守一世寂寞 2020-12-08 18:26

I don\'t really understand the difference between the XPath functions name and local-name.

Could you give an example of a situation where they would differ?

1条回答
  •  被撕碎了的回忆
    2020-12-08 18:57

    With the XML being

    
    

    the stylesheet

    
    
      
    
      
        
        
      
    
    
    

    outputs

    html
    x:html
    

    So the local-name() result is without any prefix, the name() result might include a prefix.

    In your sample with a default namespace declaration no prefix is present, therefore name() and local-name() give the same result.

    0 讨论(0)
提交回复
热议问题