title: MS SQLXML. Import XML with specified namespace
body: <p>I have to import XML data into a SQL Server database. I have the following XML (for example):</p>
  
  <pre><code>&lt;ROOT xmlns="http://www.w3.org/1999/xhtml"&gt;  
    &lt;Customer CustomerID="1" CompanyName="xyz" /&gt;
    &lt;Customer CustomerID="2" CompanyName="abc" /&gt;
  &lt;/ROOT&gt;
  </code></pre>
  
  <p>With the schema:</p>
  
  <pre><code>&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns:sql="urn:schemas-microsoft-com:mapping-schema"&gt;
    &lt;xsd:element name="Customer" sql:relation="Customers" &gt;
     &lt;xsd:complexType&gt;
       &lt;xsd:attribute name="CustomerID" type="xsd:string" /&gt;
       &lt;xsd:attribute name="CompanyName" type="xsd:string" /&gt;
      &lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p>And running standard MSDN (<a href="http://msdn.microsoft.com/ru-ru/library/ms172633.aspx" rel="nofollow">http://msdn.microsoft.com/ru-ru/library/ms172633.aspx</a>) VBScript <code>SQLXMLBulkLoad</code> will succeed, however no data will be loaded.</p>
  
  <p>If you delete the namespace reference (xmlns attribute), it will work.</p>
  
  <p>XSD doesn't allow you to map attribute 'xmlns', so <code>sql:mapped='false'</code> does not work here.</p>
  
  <p>Problem is, source XML cannot be changed, is it even possible to solve the issue using only XSD schema?</p>