Altova XMLSpy 2024 Enterprise Edition

Validating XML Documents

Home Prev Top Next

The XML | Validate (F8) command validates an XML document against an associated DTD, XML Schema, or other schema. If a document is valid, a successful-validation message is displayed in the Messages window. Otherwise, the causes of the error are displayed in the left-hand pane (see screenshot below). If a cause is selected in the left-hand pane, then smart fixes for it, if available, are displayed in the right-hand pane. Smart fix suggestions are based on information in the associated schema. To apply a smart fix, either (i) double-click it, or (ii) select it and click either the Fix or Fix + Validate options (see screenshot below).

Click to expand/collapse


Error indicators and smart fixes

Error indicators

In Text View, there are two additional indicators of a validation error (see screenshot below): (i) a red exclamation-mark icon in the line-numbering margin, and (ii) a red marker-square in the scroll bar (on the right of the window).


Note that the red marker-square appears on the left-hand side of the scroll bar (located at the right-hand side of the window; see screenshot above). This is mentioned because here because scroll bar displays two other kinds of marker-squares: (i) for highlighted text occurrences (brown, left-hand side of the scroll bar; see Navigating the Document); (ii) Find occurrences (brown, right-hand-side of the scroll bar; see the Find command).


Smart fixes

If a smart fix is available for an error, then a light bulb icon is shown on the line that generates the error (see screenshot below). When you place the mouse over icon, a popup appears that lists available smart fixes (see screenshot). Select a fix to apply it immediately.


Note the following points:


Validation error indicators and smart fixes are available for document types that can be validated in XMLSpy, for example JSON documents.

The validation error indicators and smart fixes described above are refreshed only when the XML | Validate (F8) command is executed; they are not updated in the background. So, after correcting an error, you must run the Validate (F8) command again to make sure that the error has indeed been fixed.


For more information about validating an XML document, see the description of the Validate command.


Validation and Schema Manager

If a document is validated against a schema that is not installed but is available via Schema Manager, then the installation via Schema Manager will be triggered automatically. However, if the schema package to be installed via Schema Manager contains namespace mappings, then there will be no automatic installation; in this case, you must start Schema Manager, select the package/s you want to install, and run the installation. If, after installation, XMLSpy is not able to correctly locate a schema component, then restart XMLSpy and try again.


Validate on editing

When the Validate on Edit mode is toggled on, well-formed checks and validation checks are carried out as you modify a document in Text View (and also in JSON Grid View). For validation to be carried out (additional to well-formed checks), a DTD or an XML Schema must be assigned to the XML document (a JSON Schema must be assigned to a JSON document). Errors are shown by error indicators (see above) in the left margin and on the lines containing the errors.


The Validate on Edit mode can be toggled on/off either (i) via the XML | Validate on Edit menu command, (ii) the Validate on Edit toolbar button, or (iii) via the On Edit option of the Validation settings of the Options dialog.


© 2018-2024 Altova GmbH