Hi all,
I have an xml file that I am trying to run through XSLT, but the namespace on some of my source objects are causing the xslt to not find the node. Can't I tell xslt to ignore the namespace
xml file snippet:
<Shipping xmlns="http://soa.channeladvisor.com/webservices/">
<NameTitle>Mr.</NameTitle>
<FirstName>John</FirstName>
<LastName>Doe</LastName>
</Shipping>
xslt snippet:
<xsl:value-of select="ShippingInfo/NameTitle" />
If I delete the namespace from the Shipping node, my xslt works fine. But of course I don't have control over the xml to remove the namespace in production.
Thanks!
I have an xml file that I am trying to run through XSLT, but the namespace on some of my source objects are causing the xslt to not find the node. Can't I tell xslt to ignore the namespace
xml file snippet:
<Shipping xmlns="http://soa.channeladvisor.com/webservices/">
<NameTitle>Mr.</NameTitle>
<FirstName>John</FirstName>
<LastName>Doe</LastName>
</Shipping>
xslt snippet:
<xsl:value-of select="ShippingInfo/NameTitle" />
If I delete the namespace from the Shipping node, my xslt works fine. But of course I don't have control over the xml to remove the namespace in production.
Thanks!

ignoring namespaces in xslt
baswegan2
This is a FAQ. In XPath unprefixed names belong always to no-namespace.
For more information see:
http://msdn.microsoft.com/vstudio/default.aspx pull=/library/en-us/dnxml/html/XpthXSLTNS.asp
Cheers,
Dimitre Novatchev
Mainiac007
If you have a default namespace declaration (i.e. xmlns="someURL") in the input XML then you need to declare a prefix for that namespace in your stylesheet e.g.
<xsl:stylesheet xmlns:xsl="http:///www.w3.org/1999/XSL/Transform" xmlns:ca="http://soa.channeladvisor.com/webservices/" version="1.0">
and use that prefix in XPath expressions and match patterns e.g.
<xsl:value-of select="ca:ShippingInfo/ca:NameTitle"/>
So choose a prefix as you like, declare and use it in your stylesheet and all is fine. No change to the input XML is needed.
stswordman
Thanks Martin,
Had seen examples but never got the namespace going before the NameTitle also. Works great!
Greg