title: Approach for performing XSLT transformation on SQL Server
body: <p>I am trying to perform XSLT transformation for converting a XML to different XML format. I am also using Xslt Extension Objects to perform data mapping operations during transformation. </p>
  
  <p>I have mentioned a cut down version of XML formats below. There is a mapping table which maps the Supplier Product Code with ProductID in my system. So while transforming I use the extension objects to do such mapping operations. </p>
  
  <p>This works well till the time I get a big XML document with couple of 1000's of detail nodes in it. In such scenario the extension object have performance impact.</p>
  
  <p>I was wondering whether I can shift XSLT transformation to SQL Server and handle the data mapping operation at the DB level rather than making individual DB call from Extension Objects? </p>
  
  <p><strong>Source XML Document</strong></p>
  
  <pre><code>&lt;SuppliersDocument&gt;
    &lt;SupplierProducts&gt;
      &lt;Product&gt;
        &lt;ProductCode&gt;A001&lt;/ProductCode&gt;
        &lt;UOM&gt;KG&lt;/UOM&gt;
      &lt;/Product&gt;
      &lt;Product&gt;
        &lt;ProductCode&gt;A002&lt;/ProductCode&gt;
        &lt;UOM&gt;ML&lt;/UOM&gt;
      &lt;/Product&gt;
      &lt;Product&gt;
        &lt;ProductCode&gt;A003&lt;/ProductCode&gt;
        &lt;UOM&gt;EA&lt;/UOM&gt;
      &lt;/Product&gt;
    &lt;/SupplierProducts&gt;
  &lt;/SuppliersDocument&gt;
  </code></pre>
  
  <p><strong>Target XML Document</strong></p>
  
  <pre><code>&lt;MyDocument&gt;
    &lt;Products&gt;
      &lt;Product&gt;
        &lt;ProductID&gt;998998&lt;/ProductID&gt;
        &lt;UnitOfMeasurementID&gt;1&lt;/UnitOfMeasurementID&gt;
      &lt;/Product&gt;
      &lt;Product&gt;
        &lt;ProductID&gt;885855&lt;/ProductID&gt;
        &lt;UnitOfMeasurementID&gt;2521&lt;/UnitOfMeasurementID&gt;
      &lt;/Product&gt;
      &lt;Product&gt;
        &lt;ProductID&gt;225235&lt;/ProductID&gt;
        &lt;UnitOfMeasurementID&gt;5542&lt;/UnitOfMeasurementID&gt;
      &lt;/Product&gt;
    &lt;/Products&gt;
  &lt;/MyDocument&gt;
  </code></pre>