开发者

Need to create HTML form dynamically given an XSD file

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.

I am currently working on a WCF RESTful web service that will be called from clients pages in an Iframe such as below.

<iframe src="/URL_TO_THE_SERVICE/param1/param2/param3"/>

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.

Does anybody know solutions that I can use to do this, outside tools,etc?

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?

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"       at tributeFormDefault="unqualified" elementFormDefault="qualified">
 <xs:element name="Leads">
<xs:complexType>
  <xs:sequence>
    <xs:element maxOccurs="unbounded" name="Lead">
      <xs:complexType>
        <xs:all>
          <xs:element name="FirstName" type="xs:string" minOccurs="1" />
          <xs:element name="LastName" type="xs:string" minOccurs="1" />
          <xs:element name="Address" type="xs:string" minOccurs="1" />
          <xs:element name="City" type="xs:string" minOccurs="0" />
          <xs:element name="State" minOccurs="1">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="AL" />
                <xs:enumeration value="AK" />
                <xs:enumeration value="AZ" />
                <xs:enumeration value="AR" />
                <xs:enumeration value="CA" />
                <xs:enumeration value="CO" />
                <xs:enumeration value="CT" />
                <xs:enumeration value="DE" />
                <xs:enumeration value="DC" />
                <xs:enumeration value="FL" />
                <xs:enumeration value="GA" />
                <xs:enumeration value="HI" />
                <xs:enumeration value="ID" />
                <xs:enumeration value="IL" />
                <xs:enumeration value="IN" />
                <xs:enumeration value="IA" />
                <xs:enumeration value="KS" />
                <xs:enumeration value="KY" />
                <xs:enumeration value="LA" />
                <xs:enumeration value="ME" />
                <xs:enumeration value="MD" />
                <xs:enumeration value="MA" />
                <xs:enumeration value="MI" />
                <xs:enumeration value="MN" />
                <xs:enumeration value="MS" />
                <xs:enumeration value="MO" />
                <xs:enumeration value="MT" />
                <xs:enumeration value="NE" />
                <xs:enumeration value="NV" />
                <xs:enumeration value="NH" />
                <xs:enumeration value="NJ" />
                <xs:enumeration value="NM" />
                <xs:enumeration value="NY" />
                <xs:enumeration value="NC" />
                <xs:enumeration value="ND" />
                <xs:enumeration value="OH" />
                <xs:enumeration value="OK" />
                <xs:enumeration value="OR" />
                <xs:enumeration value="PA" />
                <xs:enumeration value="RI" />
                <xs:enumeration value="SC" />
                <xs:enumeration value="SD" />
                <xs:enumeration value="TN" />
                <xs:enumeration value="TX" />
                <xs:enumeration value="UT" />
                <xs:enumeration value="VT" />
                <xs:enumeration value="VA" />
                <xs:enumeration value="WA" />
                <xs:enumeration value="WV" />
                <xs:enumeration value="WI" />
                <xs:enumeration value="WY" />
                <xs:enumeration value="PR" />
                <xs:enumeration value="NS" />
                <xs:enumeration value="Alabama" />
                <xs:enumeration value="Alaska" />
                <xs:enumeration value="Arizona" />
                <xs:enumeration value="Arkansas" />
                <xs:enumeration value="California" />
                <xs:enumeration value="Colorado" />
                <xs:enumeration value="Connecticut" />
                <xs:enumeration value="Delaware" />
                <xs:enumeration value="District of Columbia" />
                <xs:enumeration value="Florida" />
                <xs:enumeration value="Georgia" />
                <xs:enumeration value="Hawaii" />
                <xs:enumeration value="Idaho" />
                <xs:enumeration value="Illinois" />
                <xs:enumeration value="Indiana" />
                <xs:enumeration value="Iowa" />
                <xs:enumeration value="Kansas" />
                <xs:enumeration value="Kentucky" />
                <xs:enumeration value="Louisiana" />
                <xs:enumeration value="Maine" />
                <xs:enumeration value="Maryland" />
                <xs:enumeration value="Massachusetts" />
                <xs:enumeration value="Michigan" />
                <xs:enumeration value="Minnesota" />
                <xs:enumeration value="Mississippi" />
                <xs:enumeration value="Missouri" />
                <xs:enumeration value="Montana" />
                <xs:enumeration value="Nebraska" />
                <xs:enumeration value="Nevada" />
                <xs:enumeration value="New Hampshire" />
                <xs:enumeration value="New Jersey" />
                <xs:enumeration value="New Mexico" />
                <xs:enumeration value="New York" />
                <xs:enumeration value="North Carolina" />
                <xs:enumeration value="North Dakota" />
                <xs:enumeration value="Ohio" />
                <xs:enumeration value="Oklahoma" />
                <xs:enumeration value="Oregon" />
                <xs:enumeration value="Pennsylvania" />
                <xs:enumeration value="Rhode Island" />
                <xs:enumeration value="South Carolina" />
                <xs:enumeration value="South Dakota" />
                <xs:enumeration value="Tennessee" />
                <xs:enumeration value="Texas" />
                <xs:enumeration value="Utah" />
                <xs:enumeration value="Vermont" />
                <xs:enumeration value="Virginia" />
                <xs:enumeration value="Washington" />
                <xs:enumeration value="West Virginia" />
                <xs:enumeration value="Wisconsin" />
                <xs:enumeration value="Wyoming" />
                <xs:enumeration value="Puerto Rico" />
                <xs:enumeration value="No State" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="Zip" type="xs:string" minOccurs="0" />
          <xs:element name="Email" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:pattern value="[a-zA-Z0-9_.]+@([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="PrimaryPhone" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:pattern value="\(?[0-9]{3,3}\)?\-?\s?[0-9]{3,3}-?[0-9]{4,4}" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="LoanAmount" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:pattern value="\$?[0-9,.]+" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="Balance" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:pattern value="\$?[0-9,.]+" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="LoanType" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="Refinance" />
                <xs:enumeration value="HELOC" />
                <xs:enumeration value="Second Mortgage" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="EstimatedValue" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:pattern value="\$?[0-9,.]+" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="LenderDate" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:pattern value="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="MobilePhone" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:pattern value="\(?[0-9]{3,3}\)?\-?\s?[0-9]{3,3}-?[0-9]{4,4}" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="OptOut" type="xs:boolean" minOccurs="0" />
          <xs:element name="SendComments" type="xs:string" minOccurs="0" />
          <xs:element name="VendorID" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="EB1234" />
                <xs:enumeration value="ER5678" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="CallTime" type="xs:dateTime" minOccurs="0" />
          <xs:element name="AdSource" type="xs:string" minOccurs="0" />
          <xs:element name="Result" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="C" />
                <xs:enumeration value="A" />
                <xs:enumeration value="N" />
                <xs:enumeration value="B" />
                <xs:enumeration value="W" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="Duration" type="xs:decimal" minOccurs="0" />
          <xs:element name="ReviewStatus" type="xs:string" minOccurs="0" />
          <xs:element name="SubID" type="xs:string" minOccurs="0" />
          <xs:element name="Borrowers" type="xs:string" minOccurs="0" />
          <xs:element name="Loans" type="xs:string" minOccurs="0" />
          <xs:element name="Drivers" minOccurs="0">
            <xs:complexType>
              <xs:sequence>
                <xs:element maxOccurs="unbounded" name="Driver">
                  <xs:complexType>
                    <xs:all>
                      <xs:element name="FirstName" type="xs:string" minOccurs="0" />
                      <xs:element name="LastName" type="xs:string" minOccurs="0" />
                    </xs:all>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
          <xs:element name="DOB" type="xs:dateTime" minOccurs="0" />
          <xs:element name="StandardAddress" type="xs:string" minOccurs="0" />
          <xs:element name="StandardCity" type="xs:string" minOccurs="0" />
          <xs:element name="StandardState" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="AL" />
                <xs:enumeration value="AK" />
                <xs:enumeration value="AZ" />
                <xs:enumeration value="AR" />
                <xs:enumeration value="CA" />
                <xs:enumeration value="CO" />
                <xs:enumeration value="CT" />
                <xs:enumeration value="DE" />
                <xs:enumeration value="DC" />
                <xs:enumeration value="FL" />
                <xs:enumeration value="GA" />
                <xs:enumeration value="HI" />
                <xs:enumeratio开发者_StackOverflow中文版n value="ID" />
                <xs:enumeration value="IL" />
                <xs:enumeration value="IN" />
                <xs:enumeration value="IA" />
                <xs:enumeration value="KS" />
                <xs:enumeration value="KY" />
                <xs:enumeration value="LA" />
                <xs:enumeration value="ME" />
                <xs:enumeration value="MD" />
                <xs:enumeration value="MA" />
                <xs:enumeration value="MI" />
                <xs:enumeration value="MN" />
                <xs:enumeration value="MS" />
                <xs:enumeration value="MO" />
                <xs:enumeration value="MT" />
                <xs:enumeration value="NE" />
                <xs:enumeration value="NV" />
                <xs:enumeration value="NH" />
                <xs:enumeration value="NJ" />
                <xs:enumeration value="NM" />
                <xs:enumeration value="NY" />
                <xs:enumeration value="NC" />
                <xs:enumeration value="ND" />
                <xs:enumeration value="OH" />
                <xs:enumeration value="OK" />
                <xs:enumeration value="OR" />
                <xs:enumeration value="PA" />
                <xs:enumeration value="RI" />
                <xs:enumeration value="SC" />
                <xs:enumeration value="SD" />
                <xs:enumeration value="TN" />
                <xs:enumeration value="TX" />
                <xs:enumeration value="UT" />
                <xs:enumeration value="VT" />
                <xs:enumeration value="VA" />
                <xs:enumeration value="WA" />
                <xs:enumeration value="WV" />
                <xs:enumeration value="WI" />
                <xs:enumeration value="WY" />
                <xs:enumeration value="PR" />
                <xs:enumeration value="NS" />
                <xs:enumeration value="Alabama" />
                <xs:enumeration value="Alaska" />
                <xs:enumeration value="Arizona" />
                <xs:enumeration value="Arkansas" />
                <xs:enumeration value="California" />
                <xs:enumeration value="Colorado" />
                <xs:enumeration value="Connecticut" />
                <xs:enumeration value="Delaware" />
                <xs:enumeration value="District of Columbia" />
                <xs:enumeration value="Florida" />
                <xs:enumeration value="Georgia" />
                <xs:enumeration value="Hawaii" />
                <xs:enumeration value="Idaho" />
                <xs:enumeration value="Illinois" />
                <xs:enumeration value="Indiana" />
                <xs:enumeration value="Iowa" />
                <xs:enumeration value="Kansas" />
                <xs:enumeration value="Kentucky" />
                <xs:enumeration value="Louisiana" />
                <xs:enumeration value="Maine" />
                <xs:enumeration value="Maryland" />
                <xs:enumeration value="Massachusetts" />
                <xs:enumeration value="Michigan" />
                <xs:enumeration value="Minnesota" />
                <xs:enumeration value="Mississippi" />
                <xs:enumeration value="Missouri" />
                <xs:enumeration value="Montana" />
                <xs:enumeration value="Nebraska" />
                <xs:enumeration value="Nevada" />
                <xs:enumeration value="New Hampshire" />
                <xs:enumeration value="New Jersey" />
                <xs:enumeration value="New Mexico" />
                <xs:enumeration value="New York" />
                <xs:enumeration value="North Carolina" />
                <xs:enumeration value="North Dakota" />
                <xs:enumeration value="Ohio" />
                <xs:enumeration value="Oklahoma" />
                <xs:enumeration value="Oregon" />
                <xs:enumeration value="Pennsylvania" />
                <xs:enumeration value="Rhode Island" />
                <xs:enumeration value="South Carolina" />
                <xs:enumeration value="South Dakota" />
                <xs:enumeration value="Tennessee" />
                <xs:enumeration value="Texas" />
                <xs:enumeration value="Utah" />
                <xs:enumeration value="Vermont" />
                <xs:enumeration value="Virginia" />
                <xs:enumeration value="Washington" />
                <xs:enumeration value="West Virginia" />
                <xs:enumeration value="Wisconsin" />
                <xs:enumeration value="Wyoming" />
                <xs:enumeration value="Puerto Rico" />
                <xs:enumeration value="No State" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="StandardZip" type="xs:string" minOccurs="0" />
          <xs:element name="IPAddress" type="xs:string" minOccurs="0" />
          <xs:element name="LeadScore" type="xs:string" minOccurs="0" />
          <xs:element name="AreaCode" type="xs:int" minOccurs="0" />
          <xs:element name="SecondPhone" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:pattern value="\(?[0-9]{3,3}\)?\-?\s?[0-9]{3,3}-?[0-9]{4,4}" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="TestYesNoSubFields" type="xs:string" minOccurs="0" />
          <xs:element name="Status" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="Pending" />
                <xs:enumeration value="Working" />
                <xs:enumeration value="Closed" />
                <xs:enumeration value="Dead" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="SalePrice" minOccurs="0">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:pattern value="\$?[0-9,.]+" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
        </xs:all>
        <xs:attribute name="reference" type="xs:string" use="optional" />
      </xs:complexType>
    </xs:element>
  </xs:sequence>
  <xs:attribute name="vid" type="xs:unsignedLong" use="required" />
  <xs:attribute name="lid" type="xs:unsignedLong" use="required" />
  <xs:attribute name="aid" type="xs:unsignedLong" use="optional" />
  <xs:attribute name="password" type="xs:string" use="optional" />
</xs:complexType>

Thanks


I don't know of any tools, but the key thing to remember is that XSD schema files are XML, which means you can either interpret and generate the HTML yourself based on the elements presented in your XSD, or you can use XSLT transformation to generate it. XSLT can either be done server side in code, or client side by the browser. To perform XSLT in the browser, you need to specify a declaration at the top of your resultant XML:

<?xml-stylesheet type="text/xsl" href="/path/to/html-transform.xsl"?>

Where html-transform.xsl is your XSLT transformation file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜