Sometimes InfoPath doesn’t allow you to rename your main data source so you are stuck with a name that doesn’t necessarily match with the function of the form. This is very common for those of us that like to use Microsoft’s InfoPath templates as a head start. For example, a form designed based upon an InfoPath sample may include the "expenseReport" name. This is quite annoying especially when you need to compile the datasource with the "xsd /c" command and the output classname is less than helpful.
Below is the example of a form data source that was created using Microsoft’s “Expense Report” example form.
How to rename the your data source
- If this field is disabled when you open the properties window you will need to follow the steps shown below to rename the datasource
- Open your form
- Select file >> Save as Source Files
- Accept the signing message
- *** Close the form *** don’t skip this step
- Open the schema.xsd file from the location where you saved the source (if you don’t see the schema.xsd then your datasource is not complex so you can still rename it using the right mouse key >> properties)
- Locate the element as shown below and rename it (sorry but you shouldn’t rename any of the target namespaces or xsns)
- (update the <xs:element to match the name you would like without spaces
- Save the shema.xsd
- Open the original form and select Tools >> Convert Main Data Source
- Select the schema.xsd file you modified previously
- Choose No if InfoPath asks you "Do you want to add another XML Schema or XML document to the main data source?"
- Voila, your main Data Source’s top level element is renamed
Popularity: 3% [?]