XSLT with XML source that has a default namespace set to xmlns

后端 未结 3 1605
情话喂你
情话喂你 2020-11-21 23:46

I have an XML document with a default namespace indicated at the root. Something like this:


   

        
3条回答
  •  天涯浪人
    2020-11-22 00:17

    You need to declare the namespace in your XSLT, and use it in XPath expressions. E.g.:

    
    
        ... 
    
    
    

    Note that you must provide some prefix if you want to refer to elements from that namespace in XPath. While you can just do xmlns="..." without the prefix, and it will work for literal result elements, it won't work for XPath - in XPath, an unprefixed name is always considered to be in namespace with blank URI, regardless of any xmlns="..." in scope.

提交回复
热议问题