I had done some playing around with alternate ways of XSD, Java Model conversion and runtime transformation of model..

Here is an approach that seemed very clean to me FWIW:
- Use XSD to specify API and documentation for XML forms. Specify as much as possible in XSD. - Use Jaxb to generate Java model for XSD. This could be cached so that XML Unmarshalling does not need to be done. Jaxb generates classes with inheritance structure that follows XSD. - Transform at runtime as needed. This could be done using proxies with flexible string expanders.

Also I had a need to use enumeration and multiple variants of 'form'(had extended widget-form.xsd to have more than 'form' top level element)

Inheritance and includes. This may be a way to have groups of attributes making it easy to see things together.
<xs:attributeGroups> can include other attribute groups.
Inheritance can be done in XSD as well.



There was one other thing that i was not sure about..
From Model POV. ModelFormField has one FieldInfo. Each of the field types e.g. Text, Image, Hidden etc. are subclasses of FieldInfo. Wondering why it is that way. Would it have been better to have Text, Image, Hidden etc. as subclass of ModelFormField in Java and

Similarily something like this from EmployeeForms.xml
<form name="AddEmployeeSkills" type="single" target="createEmployeeSkill" default-map-name="partySkill">
        <field name="partyId"><hidden/></field>
<field name="skillTypeId" tooltip="${uiLabelMap.CommonRequired}" widget-style="required">
            <drop-down>
<entity-options description="${description}" entity-name="SkillType">
                    <entity-order-by field-name="description"/>
                </entity-options>
            </drop-down>
        </field>
        <field name="yearsExperience"><text/></field>
        <field name="rating"><text/></field>
        <field name="skillLevel"><text/></field>
<field name="submitButton" title="${uiLabelMap.CommonCreate}" widget-style="smallSubmit"><submit button-type="button"/></field>
    </form>

May be expressed as
<form name="AddEmployeeSkills" type="single" target="createEmployeeSkill" default-map-name="partySkill">
        <hidden-field name="partyId"></field>
<drop-down-field name="skillTypeId" tooltip="${uiLabelMap.CommonRequired}" widget-style="required"> <entity-options description="${description}" entity-name="SkillType">
                    <entity-order-by field-name="description"/>
                </entity-options>
        </drop-down-field>
        <text-field name="yearsExperience"/>
        <text-field name="rating"/>
        <text-field name="skillLevel"/>
<submit-field name="submitButton" title="${uiLabelMap.CommonCreate}" widget-style="smallSubmit" submit button-type="button"/>
    </form>

It appears that given the one to one nature of ModelFormField and FieldInfo, it really is one object and FormFields are really specific types of fields. Inheritance in XSD can model this efficiently with Standard set of attributes in base class e.g. name, widget-style etc.

I hope this is somewhat useful in terms of ideas. I realize it is way off from current.

Harmeet

Reply via email to