title: Need to create HTML form dynamically given an XSD file
body: <p>I recently wrote another post on this same topic in which I was not very clear, so I decided to ask the same question and will delete my other question.</p>
  
  <p>I am currently working on a WCF RESTful web service that will be called from clients pages in an Iframe such as below.</p>
  
  <pre><code>&lt;iframe src="/URL_TO_THE_SERVICE/param1/param2/param3"/&gt;
  </code></pre>
  
  <p>Based on the parameters given in the URL, in my web service I am going to retrieve an xsd file from out database. From this xsd file, we need to stream back to the user calling the service the HTML text to generate a form in their iframe based on the XSD that was retrieved. I am using C# ASP.NET for my WCF RESTful Web service if that helps at all.</p>
  
  <p>Does anybody know solutions that I can use to do this, outside tools,etc?</p>
  
  <p>This is a sample XSD schema that I got, and this would need to be transformed into an HTML form on the fly. Is this even possible to automate?</p>
  
  <pre><code>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"       at tributeFormDefault="unqualified" elementFormDefault="qualified"&gt;
   &lt;xs:element name="Leads"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element maxOccurs="unbounded" name="Lead"&gt;
        &lt;xs:complexType&gt;
          &lt;xs:all&gt;
            &lt;xs:element name="FirstName" type="xs:string" minOccurs="1" /&gt;
            &lt;xs:element name="LastName" type="xs:string" minOccurs="1" /&gt;
            &lt;xs:element name="Address" type="xs:string" minOccurs="1" /&gt;
            &lt;xs:element name="City" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="State" minOccurs="1"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:enumeration value="AL" /&gt;
                  &lt;xs:enumeration value="AK" /&gt;
                  &lt;xs:enumeration value="AZ" /&gt;
                  &lt;xs:enumeration value="AR" /&gt;
                  &lt;xs:enumeration value="CA" /&gt;
                  &lt;xs:enumeration value="CO" /&gt;
                  &lt;xs:enumeration value="CT" /&gt;
                  &lt;xs:enumeration value="DE" /&gt;
                  &lt;xs:enumeration value="DC" /&gt;
                  &lt;xs:enumeration value="FL" /&gt;
                  &lt;xs:enumeration value="GA" /&gt;
                  &lt;xs:enumeration value="HI" /&gt;
                  &lt;xs:enumeration value="ID" /&gt;
                  &lt;xs:enumeration value="IL" /&gt;
                  &lt;xs:enumeration value="IN" /&gt;
                  &lt;xs:enumeration value="IA" /&gt;
                  &lt;xs:enumeration value="KS" /&gt;
                  &lt;xs:enumeration value="KY" /&gt;
                  &lt;xs:enumeration value="LA" /&gt;
                  &lt;xs:enumeration value="ME" /&gt;
                  &lt;xs:enumeration value="MD" /&gt;
                  &lt;xs:enumeration value="MA" /&gt;
                  &lt;xs:enumeration value="MI" /&gt;
                  &lt;xs:enumeration value="MN" /&gt;
                  &lt;xs:enumeration value="MS" /&gt;
                  &lt;xs:enumeration value="MO" /&gt;
                  &lt;xs:enumeration value="MT" /&gt;
                  &lt;xs:enumeration value="NE" /&gt;
                  &lt;xs:enumeration value="NV" /&gt;
                  &lt;xs:enumeration value="NH" /&gt;
                  &lt;xs:enumeration value="NJ" /&gt;
                  &lt;xs:enumeration value="NM" /&gt;
                  &lt;xs:enumeration value="NY" /&gt;
                  &lt;xs:enumeration value="NC" /&gt;
                  &lt;xs:enumeration value="ND" /&gt;
                  &lt;xs:enumeration value="OH" /&gt;
                  &lt;xs:enumeration value="OK" /&gt;
                  &lt;xs:enumeration value="OR" /&gt;
                  &lt;xs:enumeration value="PA" /&gt;
                  &lt;xs:enumeration value="RI" /&gt;
                  &lt;xs:enumeration value="SC" /&gt;
                  &lt;xs:enumeration value="SD" /&gt;
                  &lt;xs:enumeration value="TN" /&gt;
                  &lt;xs:enumeration value="TX" /&gt;
                  &lt;xs:enumeration value="UT" /&gt;
                  &lt;xs:enumeration value="VT" /&gt;
                  &lt;xs:enumeration value="VA" /&gt;
                  &lt;xs:enumeration value="WA" /&gt;
                  &lt;xs:enumeration value="WV" /&gt;
                  &lt;xs:enumeration value="WI" /&gt;
                  &lt;xs:enumeration value="WY" /&gt;
                  &lt;xs:enumeration value="PR" /&gt;
                  &lt;xs:enumeration value="NS" /&gt;
                  &lt;xs:enumeration value="Alabama" /&gt;
                  &lt;xs:enumeration value="Alaska" /&gt;
                  &lt;xs:enumeration value="Arizona" /&gt;
                  &lt;xs:enumeration value="Arkansas" /&gt;
                  &lt;xs:enumeration value="California" /&gt;
                  &lt;xs:enumeration value="Colorado" /&gt;
                  &lt;xs:enumeration value="Connecticut" /&gt;
                  &lt;xs:enumeration value="Delaware" /&gt;
                  &lt;xs:enumeration value="District of Columbia" /&gt;
                  &lt;xs:enumeration value="Florida" /&gt;
                  &lt;xs:enumeration value="Georgia" /&gt;
                  &lt;xs:enumeration value="Hawaii" /&gt;
                  &lt;xs:enumeration value="Idaho" /&gt;
                  &lt;xs:enumeration value="Illinois" /&gt;
                  &lt;xs:enumeration value="Indiana" /&gt;
                  &lt;xs:enumeration value="Iowa" /&gt;
                  &lt;xs:enumeration value="Kansas" /&gt;
                  &lt;xs:enumeration value="Kentucky" /&gt;
                  &lt;xs:enumeration value="Louisiana" /&gt;
                  &lt;xs:enumeration value="Maine" /&gt;
                  &lt;xs:enumeration value="Maryland" /&gt;
                  &lt;xs:enumeration value="Massachusetts" /&gt;
                  &lt;xs:enumeration value="Michigan" /&gt;
                  &lt;xs:enumeration value="Minnesota" /&gt;
                  &lt;xs:enumeration value="Mississippi" /&gt;
                  &lt;xs:enumeration value="Missouri" /&gt;
                  &lt;xs:enumeration value="Montana" /&gt;
                  &lt;xs:enumeration value="Nebraska" /&gt;
                  &lt;xs:enumeration value="Nevada" /&gt;
                  &lt;xs:enumeration value="New Hampshire" /&gt;
                  &lt;xs:enumeration value="New Jersey" /&gt;
                  &lt;xs:enumeration value="New Mexico" /&gt;
                  &lt;xs:enumeration value="New York" /&gt;
                  &lt;xs:enumeration value="North Carolina" /&gt;
                  &lt;xs:enumeration value="North Dakota" /&gt;
                  &lt;xs:enumeration value="Ohio" /&gt;
                  &lt;xs:enumeration value="Oklahoma" /&gt;
                  &lt;xs:enumeration value="Oregon" /&gt;
                  &lt;xs:enumeration value="Pennsylvania" /&gt;
                  &lt;xs:enumeration value="Rhode Island" /&gt;
                  &lt;xs:enumeration value="South Carolina" /&gt;
                  &lt;xs:enumeration value="South Dakota" /&gt;
                  &lt;xs:enumeration value="Tennessee" /&gt;
                  &lt;xs:enumeration value="Texas" /&gt;
                  &lt;xs:enumeration value="Utah" /&gt;
                  &lt;xs:enumeration value="Vermont" /&gt;
                  &lt;xs:enumeration value="Virginia" /&gt;
                  &lt;xs:enumeration value="Washington" /&gt;
                  &lt;xs:enumeration value="West Virginia" /&gt;
                  &lt;xs:enumeration value="Wisconsin" /&gt;
                  &lt;xs:enumeration value="Wyoming" /&gt;
                  &lt;xs:enumeration value="Puerto Rico" /&gt;
                  &lt;xs:enumeration value="No State" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="Zip" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="Email" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:pattern value="[a-zA-Z0-9_.]+@([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="PrimaryPhone" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:pattern value="\(?[0-9]{3,3}\)?\-?\s?[0-9]{3,3}-?[0-9]{4,4}" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="LoanAmount" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:pattern value="\$?[0-9,.]+" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="Balance" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:pattern value="\$?[0-9,.]+" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="LoanType" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:enumeration value="Refinance" /&gt;
                  &lt;xs:enumeration value="HELOC" /&gt;
                  &lt;xs:enumeration value="Second Mortgage" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="EstimatedValue" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:pattern value="\$?[0-9,.]+" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="LenderDate" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:pattern value="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="MobilePhone" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:pattern value="\(?[0-9]{3,3}\)?\-?\s?[0-9]{3,3}-?[0-9]{4,4}" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="OptOut" type="xs:boolean" minOccurs="0" /&gt;
            &lt;xs:element name="SendComments" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="VendorID" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:enumeration value="EB1234" /&gt;
                  &lt;xs:enumeration value="ER5678" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="CallTime" type="xs:dateTime" minOccurs="0" /&gt;
            &lt;xs:element name="AdSource" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="Result" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:enumeration value="C" /&gt;
                  &lt;xs:enumeration value="A" /&gt;
                  &lt;xs:enumeration value="N" /&gt;
                  &lt;xs:enumeration value="B" /&gt;
                  &lt;xs:enumeration value="W" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="Duration" type="xs:decimal" minOccurs="0" /&gt;
            &lt;xs:element name="ReviewStatus" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="SubID" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="Borrowers" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="Loans" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="Drivers" minOccurs="0"&gt;
              &lt;xs:complexType&gt;
                &lt;xs:sequence&gt;
                  &lt;xs:element maxOccurs="unbounded" name="Driver"&gt;
                    &lt;xs:complexType&gt;
                      &lt;xs:all&gt;
                        &lt;xs:element name="FirstName" type="xs:string" minOccurs="0" /&gt;
                        &lt;xs:element name="LastName" type="xs:string" minOccurs="0" /&gt;
                      &lt;/xs:all&gt;
                    &lt;/xs:complexType&gt;
                  &lt;/xs:element&gt;
                &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="DOB" type="xs:dateTime" minOccurs="0" /&gt;
            &lt;xs:element name="StandardAddress" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="StandardCity" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="StandardState" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:enumeration value="AL" /&gt;
                  &lt;xs:enumeration value="AK" /&gt;
                  &lt;xs:enumeration value="AZ" /&gt;
                  &lt;xs:enumeration value="AR" /&gt;
                  &lt;xs:enumeration value="CA" /&gt;
                  &lt;xs:enumeration value="CO" /&gt;
                  &lt;xs:enumeration value="CT" /&gt;
                  &lt;xs:enumeration value="DE" /&gt;
                  &lt;xs:enumeration value="DC" /&gt;
                  &lt;xs:enumeration value="FL" /&gt;
                  &lt;xs:enumeration value="GA" /&gt;
                  &lt;xs:enumeration value="HI" /&gt;
                  &lt;xs:enumeration value="ID" /&gt;
                  &lt;xs:enumeration value="IL" /&gt;
                  &lt;xs:enumeration value="IN" /&gt;
                  &lt;xs:enumeration value="IA" /&gt;
                  &lt;xs:enumeration value="KS" /&gt;
                  &lt;xs:enumeration value="KY" /&gt;
                  &lt;xs:enumeration value="LA" /&gt;
                  &lt;xs:enumeration value="ME" /&gt;
                  &lt;xs:enumeration value="MD" /&gt;
                  &lt;xs:enumeration value="MA" /&gt;
                  &lt;xs:enumeration value="MI" /&gt;
                  &lt;xs:enumeration value="MN" /&gt;
                  &lt;xs:enumeration value="MS" /&gt;
                  &lt;xs:enumeration value="MO" /&gt;
                  &lt;xs:enumeration value="MT" /&gt;
                  &lt;xs:enumeration value="NE" /&gt;
                  &lt;xs:enumeration value="NV" /&gt;
                  &lt;xs:enumeration value="NH" /&gt;
                  &lt;xs:enumeration value="NJ" /&gt;
                  &lt;xs:enumeration value="NM" /&gt;
                  &lt;xs:enumeration value="NY" /&gt;
                  &lt;xs:enumeration value="NC" /&gt;
                  &lt;xs:enumeration value="ND" /&gt;
                  &lt;xs:enumeration value="OH" /&gt;
                  &lt;xs:enumeration value="OK" /&gt;
                  &lt;xs:enumeration value="OR" /&gt;
                  &lt;xs:enumeration value="PA" /&gt;
                  &lt;xs:enumeration value="RI" /&gt;
                  &lt;xs:enumeration value="SC" /&gt;
                  &lt;xs:enumeration value="SD" /&gt;
                  &lt;xs:enumeration value="TN" /&gt;
                  &lt;xs:enumeration value="TX" /&gt;
                  &lt;xs:enumeration value="UT" /&gt;
                  &lt;xs:enumeration value="VT" /&gt;
                  &lt;xs:enumeration value="VA" /&gt;
                  &lt;xs:enumeration value="WA" /&gt;
                  &lt;xs:enumeration value="WV" /&gt;
                  &lt;xs:enumeration value="WI" /&gt;
                  &lt;xs:enumeration value="WY" /&gt;
                  &lt;xs:enumeration value="PR" /&gt;
                  &lt;xs:enumeration value="NS" /&gt;
                  &lt;xs:enumeration value="Alabama" /&gt;
                  &lt;xs:enumeration value="Alaska" /&gt;
                  &lt;xs:enumeration value="Arizona" /&gt;
                  &lt;xs:enumeration value="Arkansas" /&gt;
                  &lt;xs:enumeration value="California" /&gt;
                  &lt;xs:enumeration value="Colorado" /&gt;
                  &lt;xs:enumeration value="Connecticut" /&gt;
                  &lt;xs:enumeration value="Delaware" /&gt;
                  &lt;xs:enumeration value="District of Columbia" /&gt;
                  &lt;xs:enumeration value="Florida" /&gt;
                  &lt;xs:enumeration value="Georgia" /&gt;
                  &lt;xs:enumeration value="Hawaii" /&gt;
                  &lt;xs:enumeration value="Idaho" /&gt;
                  &lt;xs:enumeration value="Illinois" /&gt;
                  &lt;xs:enumeration value="Indiana" /&gt;
                  &lt;xs:enumeration value="Iowa" /&gt;
                  &lt;xs:enumeration value="Kansas" /&gt;
                  &lt;xs:enumeration value="Kentucky" /&gt;
                  &lt;xs:enumeration value="Louisiana" /&gt;
                  &lt;xs:enumeration value="Maine" /&gt;
                  &lt;xs:enumeration value="Maryland" /&gt;
                  &lt;xs:enumeration value="Massachusetts" /&gt;
                  &lt;xs:enumeration value="Michigan" /&gt;
                  &lt;xs:enumeration value="Minnesota" /&gt;
                  &lt;xs:enumeration value="Mississippi" /&gt;
                  &lt;xs:enumeration value="Missouri" /&gt;
                  &lt;xs:enumeration value="Montana" /&gt;
                  &lt;xs:enumeration value="Nebraska" /&gt;
                  &lt;xs:enumeration value="Nevada" /&gt;
                  &lt;xs:enumeration value="New Hampshire" /&gt;
                  &lt;xs:enumeration value="New Jersey" /&gt;
                  &lt;xs:enumeration value="New Mexico" /&gt;
                  &lt;xs:enumeration value="New York" /&gt;
                  &lt;xs:enumeration value="North Carolina" /&gt;
                  &lt;xs:enumeration value="North Dakota" /&gt;
                  &lt;xs:enumeration value="Ohio" /&gt;
                  &lt;xs:enumeration value="Oklahoma" /&gt;
                  &lt;xs:enumeration value="Oregon" /&gt;
                  &lt;xs:enumeration value="Pennsylvania" /&gt;
                  &lt;xs:enumeration value="Rhode Island" /&gt;
                  &lt;xs:enumeration value="South Carolina" /&gt;
                  &lt;xs:enumeration value="South Dakota" /&gt;
                  &lt;xs:enumeration value="Tennessee" /&gt;
                  &lt;xs:enumeration value="Texas" /&gt;
                  &lt;xs:enumeration value="Utah" /&gt;
                  &lt;xs:enumeration value="Vermont" /&gt;
                  &lt;xs:enumeration value="Virginia" /&gt;
                  &lt;xs:enumeration value="Washington" /&gt;
                  &lt;xs:enumeration value="West Virginia" /&gt;
                  &lt;xs:enumeration value="Wisconsin" /&gt;
                  &lt;xs:enumeration value="Wyoming" /&gt;
                  &lt;xs:enumeration value="Puerto Rico" /&gt;
                  &lt;xs:enumeration value="No State" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="StandardZip" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="IPAddress" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="LeadScore" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="AreaCode" type="xs:int" minOccurs="0" /&gt;
            &lt;xs:element name="SecondPhone" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:pattern value="\(?[0-9]{3,3}\)?\-?\s?[0-9]{3,3}-?[0-9]{4,4}" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="TestYesNoSubFields" type="xs:string" minOccurs="0" /&gt;
            &lt;xs:element name="Status" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:enumeration value="Pending" /&gt;
                  &lt;xs:enumeration value="Working" /&gt;
                  &lt;xs:enumeration value="Closed" /&gt;
                  &lt;xs:enumeration value="Dead" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="SalePrice" minOccurs="0"&gt;
              &lt;xs:simpleType&gt;
                &lt;xs:restriction base="xs:string"&gt;
                  &lt;xs:pattern value="\$?[0-9,.]+" /&gt;
                &lt;/xs:restriction&gt;
              &lt;/xs:simpleType&gt;
            &lt;/xs:element&gt;
          &lt;/xs:all&gt;
          &lt;xs:attribute name="reference" type="xs:string" use="optional" /&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="vid" type="xs:unsignedLong" use="required" /&gt;
    &lt;xs:attribute name="lid" type="xs:unsignedLong" use="required" /&gt;
    &lt;xs:attribute name="aid" type="xs:unsignedLong" use="optional" /&gt;
    &lt;xs:attribute name="password" type="xs:string" use="optional" /&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>Thanks</p>