title: From SOAP to XML using XSLT
body: <p>So I'm trying to convert (Extract) all the elements within the body of a SOAP document into XML using XSLT. Here's my SOAP document (complete)</p>
  
     
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="dealercode.xsl"?&gt;
  
  &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;soap:Header&gt;
          &lt;AuthHeader xmlns="http://www.somedomain.com/"&gt;
              &lt;LogonID&gt;&lt;/LogonID&gt;
              &lt;Password&gt;&lt;/Password&gt;
          &lt;/AuthHeader&gt;
      &lt;/soap:Header&gt;
      &lt;soap:Body&gt;
          &lt;getDealerCodeById xmlns="http://www.somedomain.com/"&gt;
              &lt;BrokerCode&gt;{ssQuoterBrokerCode(app_id)}&lt;/BrokerCode&gt;
              &lt;IDNumber&gt;{dealerCode}&lt;/IDNumber&gt;
          &lt;/getDealerCodeById&gt;
      &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>And Here's my XSLT sheet.</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;?xml-stylesheet type="text/xsl" href="dealercode2soap.xsl"?&gt;
  
      &lt;xsl:template match="/*"&gt;
  &lt;xsl:value-of select="soap:Body/s:getDealerCodeById"
       xmlns:soap="http://www.w3.org/2001/12/soap-envelope" 
       xmlns:s="http://somedomainname/" /&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>But the output is not what I want. It is still parsing the whole SOAP document instead of just giving me the contents within the "soap:Body" elements and it I am also getting a warning of "unresolved namespace prefix soap"</p>
  
  <p>Where am I going wrong?</p>
  
  <p>EDIT: I managed to get it to work making use of a different block of code. See below</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0"
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
              xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
              xmlns ="http://www.somedomainename.com"&gt;
  
  &lt;xsl:template match="/"&gt;
      &lt;xsl:apply-templates select="soap:Envelope/soap:Body/*"/&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="@*|node()"&gt;
      &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="@*|node()"/&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p></p>
  
  <p>It now outputs in my browser the contents of the body section. The other most important thing I realized was that formatting was done on the server side but since I did not have access to the server at the time I had no idea whether my code was working or not. This is the desired output I was looking for (which was apparently working the whole time.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;getDealerCodeById xmlns="http:///" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
     &lt;BrokerCode&gt;{ssQuoterBrokerCode(app_id)}&lt;/BrokerCode&gt;
     &lt;IDNumber&gt;{dealerCode}&lt;/IDNumber&gt;
  &lt;/getDealerCodeById&gt;
  </code></pre>