Validating an XML Document

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  User Guide and Reference > Editing Views > Text View >

Validating an XML Document

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

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).

TextViewValErrorIndicators

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 Find and Replace).

 

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.

TextViewValErrorSmartFix01

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

 

Note: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.

 


© 2019 Altova GmbH