title: Delphi - Transform Dataset to XML using xtr
body: <p>Need to export an XML from a Query Dataset based on an XTR generated from XMLMapper tool.</p>
  
  <p>I have the following:</p>
  
  <ul>
  <li>MSSQL database with Tables: Patients, PatientAllergies (1-n relation)</li>
  <li>Components: TFDConnection -> FDQueryPatients,FDQUeryPatientAllergies -> DSPPatients -> CDSPatients -> DSPatients</li>
  <li>I followed a tutorial to make the PatientAllergies a nested dataset inside the CDSPatients so that 1-n relation would show correctly.</li>
  <li>I created a transformation file xtr to transform the CDSPatients to XML, and everything shows correctly (<a href="https://drive.google.com/file/d/0B9Ilf-zNw3G7UVpfazB5YkRqSjA/view?usp=sharing" rel="nofollow noreferrer">XTR File</a>) (See picture)<a href="https://i.stack.imgur.com/yKmIn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yKmIn.jpg" alt="XMLMapper"></a></li>
  </ul>
  
  <p>Now how can I use this CDSet to output an xml using this xtr file created?
  I researched a lot and all tutorials show how to transform an existing XML file into Datapacket, or how to manipulate XML and apply updates using XMLTransformProvider. I DO NOT want to the provider of the CDSPatients to point to the XMLTransformProvider since I need it to point to the Query which fetches the data from DB.
  What I need is exactly what happens with the following, but programatically: When you select the Document in the XMLMapper, and save the document, the output is the XML file I need (See picture)
  <a href="https://i.stack.imgur.com/WzIqs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WzIqs.jpg" alt="enter image description here"></a></p>
  
  <p>Thanks</p>