Reputation: 6673
I want to some dynamic control generation based on an XSD or DTD to be displayed on a form (WinForms) and the user can fill in values, probably mostly textboxes that will fill in attribute data and create legitimate fragments of XML to be inserted into an already existing XML file.
Is this doable - has anyone done this kind of thing before - if so what sort of design did you use?
Below is an example of the XSD:
<xs:element name="layer-config">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="dynamic-feature-layer"/>
<xs:element ref="dynamic-image-layer"/>
<xs:element ref="folder"/>
<xs:element ref="layer"/>
<xs:element ref="wms-layer"/>
</xs:choice>
<xs:attribute name="upload-can-drill-identify" type="BOOLEAN_TYPE" use="optional" default="true"/>
<xs:attribute name="upload-can-extract-excel" type="BOOLEAN_TYPE" use="optional" default="true"/>
<xs:attribute name="upload-can-extract-gml" type="BOOLEAN_TYPE" use="optional" default="true"/>
<xs:attribute name="upload-can-extract-kml" type="BOOLEAN_TYPE" use="optional" default="true"/>
<xs:attribute name="upload-can-find-by-attribute" type="BOOLEAN_TYPE" use="optional" default="true"/>
<xs:attribute name="upload-can-hide-labels" type="BOOLEAN_TYPE" use="optional" default="true"/>
<xs:attribute name="upload-can-identify" type="BOOLEAN_TYPE" use="optional" default="true"/>
<xs:attribute name="upload-can-select" type="BOOLEAN_TYPE" use="optional" default="true"/>
<xs:attribute name="upload-can-select-by-attribute" type="BOOLEAN_TYPE" use="optional" default="true"/>
<xs:attribute name="upload-can-symbolize" type="BOOLEAN_TYPE" use="optional" default="true"/>
<xs:attribute name="upload-can-symbolize-by-attribute" type="BOOLEAN_TYPE" use="optional" default="true"/>
</xs:complexType>
</xs:element>
I am thinking of doing this because I don't want to hard code rigidly to an already existing XML file in case it gets dropped or changed for something else - then you have to recode and recompile the whole thing and start again. It's also not that maintainable for end users either.
Upvotes: 2
Views: 387
Reputation: 58635
Yes, this is doable. Here are a few pointers:
Upvotes: 1