The XML | Check well-formedness (F7) command checks the active document for well-formedness by the definitions of the XML 1.0 specification. Every XML document must be well-formed. XMLSpy checks for well-formedness whenever a document is opened or saved, or when the view is changed from Text View to any other view. You can also check for well-formedness at any time while editing by using this command.
If the well-formedness check succeeds, a message is displayed in the Messages window (screenshot below).
If an error is encountered during the well-formedness check, a corresponding error message is displayed (screenshot below).
Based on information in the schema, options for a smart fix are also suggested if the well-formedness check was carried out in Text View or Grid View. To view a list of smart fix options, click the Show Smart Fix button (see screenshot above). A pane with suggested smart fix options appears in the Messages window (see screenshot below). Note that errors in the Messages window are displayed one error at a time.
In the Smart Fix pane, select one of the suggested smart fixes and click either the Fix + Validate button or the Fix button (see screenshot above). The error will be corrected with the smart fix. Alternatively, you can double-click the smart fix you want. This action either fixes the error, or fixes the error and validates the document, according to the option selected in the dropdown Options list. The Fix + Validate command is useful because the validator will now be able to validate beyond the fixed error and pick up the next well-formed error or validation error, if there is any.
To hide the Smart Fix pane, click the Hide Smart Fix button (see screenshot above).
|Note:||The Messages window has nine tabs. The validation result is always displayed in the active tab. So you can validate one XML document in Tab-1 and retain the result in that tab. To validate a second document, switch to Tab-2 (or Tab-3 if you like) before running the check. If you do not switch tabs, Tab-1 (or the active tab) will be overwritten with the results of the latest validation.|
Validating from the Project window
The Validate command can also be applied to a file, folder, or group of files in the active project. Select the required file or folder in the Project Window (by clicking on it). Then click XML | Validate or F8. Invalid files in a project will be opened and made active in the Main Window, and the File is not valid error message will be displayed.
|Note:||The Messages window has nine tabs. The result of the well-formed check is always displayed in the active tab. So you can check the well-formedness of one XML document in Tab-1 and retain the result in that tab. To check the well-formedness of a second document, switch to Tab-2 (or Tab-3 if you like) before running the check. If you do not switch tabs, Tab-1 (or the active tab) will be overwritten with the results of the latest check.|
It is generally not permitted to save a malformed XML document, but XMLSpy gives you a Save Anyway option. This is useful when you want to suspend your work temporarily (in a not well-formed condition) and resume it later.
|Note:||You can also use the Check well-formedness command on any file, folder, or group of files in the active project window. Click on the respective item, and then on the Check Well-Formedness icon.|