title: Xpath1.0 local-name() versus namespace in XSLT
body: <p>For some reason, when I am using proper XPath without <code>local-name()</code>, I am not getting any value.</p>
  
  <p>Non-working XPaths I have tried:</p>
  
  <ol>
  <li><code>//mon:ReturnUpdateRequest/urn:Header/urn:DocumentIdentifier/text()</code></li>
  <li><code>soapenv:Envelope/soapenv:Body/mon:ReturnUpdateRequest/urn:Header/urn:DocumentIdentifier/text()</code></li>
  </ol>
  
  <p>Both above expressions give the correct value in XPath tool and XMLspy.</p>
  
  <p>Working XPath using <code>local-name()</code>:</p>
  
  <pre><code>/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='ReturnUpdateRequest']/*[local-name()='Header']/*[local-name()='DocumentIdentifier']
  </code></pre>
  
  <p><strong>Input request:</strong></p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mon="Monsanto:ServiceReturnUpdate" xmlns:urn="urn:monsanto:uscomm:service:header"&gt;
      &lt;soapenv:Body&gt;
          &lt;mon:ReturnUpdateRequest Version="?"&gt;
              &lt;urn:Header&gt;
                  &lt;urn:DocumentIdentifier&gt;1013083&lt;/urn:DocumentIdentifier&gt;
                  &lt;urn:DocumentDateTime&gt;2015-06-11T17:46:11.092-03:00&lt;/urn:DocumentDateTime&gt;
                  &lt;urn:From&gt;
                      &lt;urn:PartnerName&gt;1013083&lt;/urn:PartnerName&gt;
                      &lt;urn:PartnerIdentifier type="SAP_ID"&gt;1013083&lt;/urn:PartnerIdentifier&gt;
                      &lt;!--Zero or more repetitions:--&gt;
                  &lt;/urn:From&gt;
                  &lt;!--Optional:--&gt;
                  &lt;urn:To&gt;
                      &lt;urn:PartnerName&gt;1013083&lt;/urn:PartnerName&gt;
                      &lt;urn:PartnerIdentifier type="SAP_ID"&gt;0001013083&lt;/urn:PartnerIdentifier&gt;
                      &lt;!--Zero or more repetitions:--&gt;
                  &lt;/urn:To&gt;
                  &lt;urn:DataSource&gt;APP&lt;/urn:DataSource&gt;
                  &lt;!--Optional:--&gt;
                  &lt;urn:SoftwareVersion&gt;?&lt;/urn:SoftwareVersion&gt;
              &lt;/urn:Header&gt;
          &lt;/mon:ReturnUpdateRequest&gt;
      &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p><strong>Code Snippet:</strong></p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mon="ServiceReturnDetail" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style"&gt;
      &lt;xsl:output method="xml" indent="yes"/&gt;
      &lt;xsl:template match="/"&gt;
          &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style"&gt;
              &lt;soapenv:Header/&gt;
              &lt;soapenv:Body&gt;
                  &lt;urn:YSdsaUsseedRetUpdate&gt;
                      &lt;IIdent&gt;
                          &lt;!--    &lt;xsl:value-of select="/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='ReturnUpdateRequest']/*[local-name()='Header']/*[local-name()='DocumentIdentifier']"/&gt;--&gt;
                          &lt;xsl:value-of select="//mon:ReturnUpdateRequest/urn:Header/urn:DocumentIdentifier/text()"/&gt;
                      &lt;/IIdent&gt;
                      &lt;ISrc&gt;
                          &lt;!--&lt;xsl:value-of select="/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='ReturnUpdateRequest']/*[local-name()='Header']/*[local-name()='DocumentDateTime']"/&gt;--&gt;
                          &lt;xsl:value-of select="/soapenv:Envelope/soapenv:Body/mon:ReturnUpdateRequest/urn:Header/urn:DocumentDateTime"/&gt;
                      &lt;/ISrc&gt;
                  &lt;/urn:YSdsaUsseedRetUpdate&gt;
              &lt;/soapenv:Body&gt;
          &lt;/soapenv:Envelope&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Where I am doing it wrong?</p>