Text View presents the actual data and markup of XML files in an easy-to-follow structural layout, and provides schema-related intelligent editing features. Individual Text View features can be switched on and off in the Text View Settings dialog (View | Text View Settings, screenshot below).
The screenshot below shows the current XML file in Text View with features switched on according to the settings in the dialog above.
On the left are the three margins: (i) the line number margin, (ii) the bookmark margin (containing two blue bookmarks), and (iii) the source folding margin (which allows you to expand and collapse the display of XML elements).
Additionally, visual aids such as indentation guides, end-of-line markers, and whitespace markers can be switched on and off, by checking and unchecking, respectively, their check boxes in the Visual Aid pane of the Text View Settings dialog (see screenshot above). The screenshot above has indentation guides switched on, and shows one indentation guide, at the Address element.
|Note:||The Text View-related pretty-printing and bookmark features were covered in the earlier Text View Settings section of this tutorial.|
In this section, you will enter and edit data in Text View in order to become familiar with the features of Text View.
|Note:||Since the Validation on Modification feature is switched on by default, any validation error created during editing will be immediately flagged, with the error message/s being displayed in the Messages Window. Ignore these errors and messages for now. If you do not want background validation, you can switch off Validation on Modification in the Validation settings of the Options dialog. In the event you do this, note that you can always validate your document at any time (described in the next section of this tutorial).|
Do the following:
1.Select the menu item View | Text View, or click on the Text tab. You now see the XML document in its text form, with syntax coloring.
2.Place the text cursor after the end tag of the Address element, and press Enter to add a new line.
3.Enter the less-than angular bracket < at this position. A dropdown list of all elements allowed at that point (according to the schema) is displayed. Since only the Person element is allowed at this point, it will be the only element displayed in the list.
4.Select the Person entry. The Person element, as well as its attribute Manager, are inserted, with the cursor inside the value-field of the Manager attribute.
5.From the dropdown list that pops up for the Manager attribute, select true.
6.Move the cursor to the end of the line (using the End key if you like), and press the space bar. This opens a dropdown list containing a list of attributes allowed at that point. Also, in the Attributes Entry Helper, the available attributes are listed in red. The Manager attribute is grayed out because it has already been used.
7.Select Degree with the Down arrow key, and press Enter. This opens another list box, from which you can select one of the predefined enumerations (BA, MA, or PhD). (Enumerations are values that are allowed by the XML Schema.)
8.Select BA with the Down arrow key and confirm with Enter. Then move the cursor to the end of the line (with the End key), and press the space bar. Manager and Degree are now grayed out in the Attributes Entry Helper.
9.Select Programmer with the Down arrow key and press Enter.
10.Enter the letter "f" and press Enter.
11.Move the cursor to the end of the line (with the End key), and enter the greater-than angular bracket >. XMLSpy automatically inserts all the required child elements of Person. (Note that the optional Title element is not inserted.) Each element has start and end tags but no content.
You could now enter the Person data in Text View, but let's move to Grid View to see the flexibility of moving between views when editing a document.
To switch to Grid View, select the menu item View | Grid View, or click the Grid tab. The newly added child elements of Person are highlighted.
Now let us validate the document and correct any errors that the validation finds.