Is there a way in xsl 1.0 to mention the xpath expression as below, to get the value of node “a”
/Root/a - doesnt work
instead of
/Root/*[local-name() = 'a'] - this will work
This is my xml file
<Root xmlns:ns="http://abc">
<ns:a>value</ns:a>
</Root>
The reason am asking, in my xslt, in many lines, we specified the xpath expression as /Root/a (or other nodes), because the xml file did not have any namespaces before. However the xml file has namespaces now, we have to change everywhere, with *[local - name()]. Instead of that, is there a way to change my xsl, in one place, so that the earlier xpath expressions also work, even with namespace included xml?
If you are using XSLT 2.0, you can declare
xpath-default-namespace. In XSLT 1.0 is better to declare namespace prefix and use it in XPath expressions, than uselocal-name()function e.g.:In XPath: