Tuesday, 7 October 2014

Redesign/Optimize XML File (Hoping for some help soon!)



I would really appreciate some help in trying to re-design this particular module that I am working on.


Currently we have a smart client which displays a tabbed form as shown in the attached picture. Of the three tabs displayed ( General Dependencies , PDF's and Statements) I am working on the PDF tab which displays the columns(as shown in attached image). enter image description here


Of all the columns displayed, the first two columns displayed (the PDF type and Description ) are dynamic columns. In the sense these columns are added to the grid after reading an xml file. I have attached the xml file as well. Since the XML file design is not optimal I have been asked to re-design the XML file.


The current XML file has the following elements as shown below.



<Returns>
<Return Name="1120">
<BinaryAttachment SchemaFileName="BinaryAttachment.xsd" SchemaVersion="2013v3.1">
<PdfType caption="PDF Type" visible="true" controlType="ItemLookUpEdit" columnWidth="180" editable="true">
<Options>
<Option>
<Value ParentNodePath="ReturnData" ParentSchemaFileName="ReturnData1120.xsd">8838 Signature Document</Value>
<Fields>
<Field name="Description" editable="false" value="8838 Signature Document"/>
</Fields>
</Option>
<Option>
<Value ParentNodePath="ReturnData" ParentSchemaFileName="ReturnData1120.xsd">1111 Signature Document</Value>
<Fields>
<Field name="Description" editable="false" value="1111 Signature Document"/>
</Fields>
</Option>
<Option>
<Value ParentNodePath="ReturnData" ParentSchemaFileName="ReturnData1120.xsd">Return Attachment - Corporate Nonrecognition Provisions</Value>
<Fields>
<Field name="Description" controlType="ItemLookUpEdit">
<Options>
<Option editable="true" pdfRequiredFileNameRegEx="^332Stmt.{0,53}\.pdf$" pdfRequiredFileNameErrorMessage="The PDF name should start with 332Stmt." value="Sec 332 Stmt {EntityName}"/>
<Option editable="true" pdfRequiredFileNameRegEx="^1\.351\-3\(a\)Stmt.{0,46}\.pdf$" pdfRequiredFileNameErrorMessage="The PDF name should start with 1.351-3(a)Stmt." value="1.351-3(a) Stmt"/>
<Option editable="true" pdfRequiredFileNameRegEx="^1\.361\-5\(a\)Stmt.{0,46}\.pdf$" pdfRequiredFileNameErrorMessage="The PDF name should start with 1.361-5(a)Stmt." value="1.361-3(b) Stmt"/>
</Options>
</Field>
</Fields>
</Option>
<Options>
</PdfType>
<Description caption="Description" visible="true" controlType="text" columnWidth="150" maxLength="128"/>
<Immarsat visible="false" maxLength="64"/>
</BinaryAttachment>
</Return>
<Returns>


As you can see, PdfType, Description and Immarsat are the three columns that need to be added to display dynamically. But since Immarsat is not visible it will not be displayed. Now the first column the PdfType is a controlType of "ItemLookUpEdit", it is a combobox which displays all the options underneath it. In this case it will display the options 8838 Signature Document,8453 Signature Document and Return Attachment - Corporate Nonrecognition Provisions.


Now it gets a little hairy here. Now each of the options for example "8838 Signature Document" has the following field



<Option>
<Value ParentNodePath="ReturnData" ParentSchemaFileName="ReturnData1120.xsd">8838 Signature Document</Value>
<Fields>
<Field name="Description" editable="false" value="8838-Signature Document Only"/>
</Fields>
</Option>


The field element described above is "Description" which is nothing but the second dynamic column being added to the form. By making it a part of the field element we basically telling the program that if the user chooses the "8838 Signature Document" option displayed in the drop down of the PdfType column, the Description coulmn (which is also a dynamically added column) will display the value "8838-Signature Document Only" and is not editiable.


Similarly if we look at the next option



<Option>
<Value ParentNodePath="ReturnData" ParentSchemaFileName="ReturnData1120.xsd">1111 Signature Document</Value>
<Fields>
<Field name="Description" editable="true" value="1111-Signature Document"/>
</Fields>
</Option>


it basically says if the user chooses the "1111 Signature Document" option displayed in the drop down of the PdfType column, the Description coulmn (which is also a dynamically added column) will display the value "1111-Signature Document" and IS editiable.


Finally the following option gets even more tricky


Return Attachment - Corporate Nonrecognition Provisions


If the user chooses the "Return Attachment - Corporate Nonrecognition Provisions" option, the column Description (which is also a dynamically added column) will display a combobox whihc in turn will display a list of options in the drop down which in this case would be the follwoing options.


Sec 332 Stmt 1.351-3(a) Stmt 1.361-3(b) Stmt


Once any of these options are choosen, this will in turn drive the use the regular expression associated with each of the choosen option and use the regex to check to see if the value in the Pdf Name column matches it. If it does not then the value in the "pdfRequiredFileNameErrorMessage" is displayed. NOTE: Pdf Name column is not a dynamic column, it is a fixed column.


Since the xml structure defined here is very complicated, and there are dependencies between differnt dynamically added columns and between a dynamically added column and a static column, I request your help in coming up with a better XML desgin to accomplish the following.


Using the XML file, the user should be able to accomplish the following


a. Should be able to configure columns on PDF screen i.e. add new columns to xml and it should display new columns in the form. b. Should be able to give a caption for the new column (can use the existing caption attribute) c. Should be able to make it visible or hide (can use the existing visible attribute) d. Should be able to specify default values (based on Pdf type) e. Should be able to enable/disable (based on Pdf type) f. Should be able to give a fixed value for a field. Validate with actual value and display error if mismatches. g. Should be able to validate a field (regex or whatever other means) h. Should be able to create additional schema elements values based on column value.


Which the current XML does, but is clunky and very hard to read. I would be very very greatful if you can at least help me by giving a road map as to how to proceed with the new XML design.


Hoping for some help!!


AJ


No comments:

Post a Comment