title: Generate xml from csv data in conformance with given xsd schema
body: <p>I have an xml schema and csv data to generate corresponding xml files.</p>
  
  <p>I found <strong><a href="http://msdn.microsoft.com/en-us/library/bb387090.aspx" rel="nofollow noreferrer">this</a></strong>, how to generate xml files from given CSV file. But with my schema, it's always the same mapping because of the  element. So the last 5 columns are mapped according to the DataType column.</p>
  
  <p>I could expand the code with case switch, and map every element accordingly in each case, but there should be a simpler way to do this. I am new to xml, need some help here.<br>
  <strong>P.S:</strong> I tried all the tools, commercial and free, that advertise mapping capabilities, and found nothing to do this. Also Excel does not work with a denormalized schema.  </p>
  
  <p>Any help appreciated, thanks<br>
  Update1: Tools: C# command line code should be the easiest.
  Update2: Objective is to generate xml with the specified schema, using data from the given csv file.</p>
  
  <p><strong>CSV data</strong></p>
  
  <pre><code>EntityName,FieldName,SQLType,DataType,Nullable,Caption,ColumnIndex,MinStringLength,MaxStringLength,D_Precision,D_Scale
  SOChemistryRequirement,CE_Min,"decimal(7, 5)",Decimal,TRUE,CE_Min,82,,,7,5
  SOChemistryRequirement,CE_Max,"decimal(7, 5)",Decimal,TRUE,CE_Max,83,,,7,5
  SOTestRequirement,Weldability,bit,bool,FALSE,Weldability,107,,,,
  SONumber,SONumber,varchar(6),string,FALSE,SONumber,0,,6,,
  </code></pre>
  
  <p><strong>schema definition:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema id="DataTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;!-- No empty string data type. --&gt;
  &lt;xs:simpleType name="NoEmptyString"&gt;
    &lt;xs:restriction base="xs:string"&gt;
    &lt;xs:minLength value="1" /&gt;
  &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;!-- Root element. --&gt;
  &lt;xs:element name="ExcelFile"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="SheetName" type="NoEmptyString" /&gt;
      &lt;xs:element name="CellRange" type="NoEmptyString" /&gt;
      &lt;!-- Definition of columns. --&gt;
      &lt;xs:element name="Columns"&gt;
        &lt;xs:complexType&gt;
          &lt;xs:sequence maxOccurs="unbounded"&gt;
            &lt;!-- Information about one column. --&gt;
            &lt;xs:element name="Column"&gt;
              &lt;xs:complexType&gt;
                &lt;xs:sequence&gt;
                  &lt;!-- Column index in excel file. --&gt;
                  &lt;xs:element name="ColumnIndex" type="xs:unsignedByte" /&gt;
                  &lt;!-- Caption for current column in grid in importing screen. --&gt;
                  &lt;xs:element name="Caption" type="xs:string" /&gt;
                  &lt;!-- Data type of current column. --&gt;
                  &lt;xs:element name="DataType"&gt;
                    &lt;xs:complexType&gt;
                      &lt;!-- It can be only one from following: --&gt;
                      &lt;xs:choice&gt;
                        &lt;xs:element name="Boolean"/&gt;
                        &lt;xs:element name="Int16"&gt;
                          &lt;xs:complexType&gt;
                            &lt;xs:sequence&gt;
                              &lt;xs:element name="MinValue" type="xs:short" minOccurs="0" /&gt;
                              &lt;xs:element name="MaxValue" type="xs:short" minOccurs="0" /&gt;
                            &lt;/xs:sequence&gt;
                          &lt;/xs:complexType&gt;
                        &lt;/xs:element&gt;
                        &lt;xs:element name="Int32"&gt;
                          &lt;xs:complexType&gt;
                            &lt;xs:sequence&gt;
                              &lt;xs:element name="MinValue" type="xs:int" minOccurs="0" /&gt;
                              &lt;xs:element name="MaxValue" type="xs:int" minOccurs="0" /&gt;
                            &lt;/xs:sequence&gt;
                          &lt;/xs:complexType&gt;
                        &lt;/xs:element&gt;
                        &lt;xs:element name="Int64"&gt;
                          &lt;xs:complexType&gt;
                            &lt;xs:sequence&gt;
                              &lt;xs:element name="MinValue" type="xs:long" minOccurs="0" /&gt;
                              &lt;xs:element name="MaxValue" type="xs:long" minOccurs="0" /&gt;
                            &lt;/xs:sequence&gt;
                          &lt;/xs:complexType&gt;
                        &lt;/xs:element&gt;
                        &lt;xs:element name="Decimal"&gt;
                          &lt;xs:complexType&gt;
                            &lt;xs:sequence&gt;
                              &lt;xs:element name="MinValue" type="xs:decimal" minOccurs="0" /&gt;
                              &lt;xs:element name="MaxValue" type="xs:decimal" minOccurs="0" /&gt;
                              &lt;xs:element name="Precision" type="xs:int" minOccurs="0" /&gt;
                              &lt;xs:element name="Scale" type="xs:int" minOccurs="0" /&gt;
                            &lt;/xs:sequence&gt;
                          &lt;/xs:complexType&gt;
                        &lt;/xs:element&gt;
                        &lt;xs:element name="DateTime"/&gt;
                        &lt;xs:element name="String"&gt;
                          &lt;xs:complexType&gt;
                            &lt;xs:sequence&gt;
                              &lt;xs:element name="MinLength" type="xs:int" minOccurs="0" /&gt;
                              &lt;xs:element name="MaxLength" type="xs:int" minOccurs="0" /&gt;
                            &lt;/xs:sequence&gt;
                          &lt;/xs:complexType&gt;
                        &lt;/xs:element&gt;
                        &lt;xs:element name="Custom"/&gt;
                      &lt;/xs:choice&gt;
                      &lt;/xs:complexType&gt;
                      &lt;/xs:element&gt;
                      &lt;!-- Can be NULL value? --&gt;
                      &lt;xs:element name="IsNullable" type="xs:boolean" /&gt;
                      &lt;!-- Entity name. Cannot be NULL. --&gt;
                      &lt;xs:element name="EntityName" type="NoEmptyString" /&gt;
                      &lt;!-- Field name. It can be NULL because of composite target field. --&gt;
                      &lt;xs:element name="FieldName" type="xs:string" /&gt;
                    &lt;/xs:sequence&gt;
                  &lt;/xs:complexType&gt;
                &lt;/xs:element&gt;
              &lt;/xs:sequence&gt;
            &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
        &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>