Has anyone ever tried to automatically build struts form elements based on a
schema?

Let me explain.

I have the following schema in demographics.xsd:
<xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema">
        <xsd:complexType name="demographics">
                <xsd:element name="firstname" type="firstname"/>
                <xsd:element name="lastname" type"lastname"/>
                <xsd:element name="age" type="age"/>
        </xsd:complexType>
        <xsd:simpleType name="firstname" base="xsd:string">
                <xsd:minOccurs="1"/>
                <xsd:maxOccurs="1"/>
                <xsd:pattern value="([A-Z]){1,20}"/>
        </xsd:simpleType>
        <xsd:simpleType name="lastname" base="xsd:string">
                <xsd:minOccurs="1"/>
                <xsd:maxOccurs="1"/>
                <xsd:pattern value="([A-Z]){1,20}"/>
        </xsd:simpleType>
        <xsd:simpleType name="age" base="xsd:string">
                <xsd:minOccurs="1"/>
                <xsd:maxOccurs="1"/>
                <xsd:pattern value="([0-9]){1,3}"/>
        </xsd:simpleType>
</xsd:schema>

Using XALAN & a stylesheet, I can transform it to something like: 
<table border="0" width="100%">
  <tr>
    <th align="right">
        <struts:message key="firstname"/>
    </th>
    <td align="left">
        <struts:text name="firstname" pattern="([A-Z]){1,20}" size="20"
maxlength="20"/>
    </td>
  </tr>
  <tr>
    <th align="right">
        <struts:message key="lastname"/>
    </th>
    <td align="left">
        <struts:text name="lastname" pattern="([A-Z]){1,20}" size="20"
maxlength="20"/>
    </td>
  </tr>
  <tr>
    <th align="right">
        <struts:message key="age"/>
    </th>
    <td align="left">
        <struts:text name="age" pattern="([0-9]){1,3}" size="3"
maxlength="3"/>
    </td>
  </tr><

What I'm interested in doing is creating a custom tag that takes in the
schema & generates the struts tags, then calls the struts taglibs and
processes them. Basically it is a recursive process. 

My custom tag would look something like:
<custom:databyschema name="demographics" schema="demographics.xsd"/>

The databyschema tag would execute XALAN, etc.

Any ideas?

Thanks.

Wayne
[EMAIL PROTECTED]

Reply via email to