Overview of the GenerateFormXML Code Sample
The GenerateFormXML application will convert your form to Nintex form XML that can be uploaded to a SharePoint list where you can define and create columns to bind to the form.
The sample demonstrates how to take input (in this case a bare-bones XML file), to create Nintex complex XML elements that describe valid XML for Nintex Forms.
Notes on Nintex Forms XML
The Nintex Forms XML is composed of three main types of XML fragments:
- The blank form
The blank Form is theForms XML without controls using a desktop layout. The desktop layout is 700 by 600 pixels wide.
- The control properties
Each control has a specific XML fragment that specifies the attributes of the control. The application is using the default settings and modifying a small subset for the generated form.
- The control layout
The control layout is created by creating an instance of the control layout class, serializing to as XML, updating the values of target nodes, and then inserting into the form control layout section of the Forms XML.
The control properties and layout are both used to define a single control. They are linked together with a control .Net Guid.
For more information about Nintex Forms XML, see XML Reference.
Process for Generating the Form XML
The application ingest the bare-bones XML, and then iterates over each control.
For each control:
- The application loads the height, width, the text element. For specific controls such as the ListBox, the application loads the list of options. For the image, the application loads the image URL. The application also generates a Guid to link the control properties to the control layout.
- The application then loads the XML fragment for the control properties, updates the values of the target XML elements, and then inserts into the control properties section.
- The application then creates a control layout object, updates the layout attributes, serializes the object, and inserts the XML into the control layout section.
- The last step of the control iteration is to update the x and y coordinates of the layout for the next control. The layout proceeds from right to left, starting at (0,0) and fitting each control to the prior until a row of controls reaches the right margin at 700 pixels. Then the layout routine advances to the next line. Note, the routine doesn't check for overlap along the y-axis which can result in overlapping controls.
When the application completes iterating over the control, the application turns the XML into turned into text, and removes a stray namespace fragment generated in the serializing the control layout object.
Finally, the form is saved to the target location.
Author a Bare-bones Form XML Document