Please enable JavaScript to view this site.

Altova XMLSpy 2020 Enterprise Edition

Grid View contains a special view called Database/Table View (hereafter called Table View), which is convenient for editing elements with multiple occurrences. Individual element types can be displayed as a table. When an element type is displayed as a table, its children (attributes and elements) are displayed as columns, and the occurrences themselves are displayed as rows.


To display an element type as a table, you select any one of the element type occurrences and click the Display as Table icon ic_disp_as_tbl in the toolbar (XML | Table | Display as table). This causes that element type to be displayed as a table. Descendant element types that have multiple occurrences are also displayed as tables. Table View is available in Enhanced Grid View, and can be used to edit any type of XML file (XML, XSD, XSL, etc.).


Advantages of Table View

Table View provides the following advantages:

You can drag-and-drop column headers to reposition the columns relative to each other. This means that, in the actual XML document, the relative position of child elements or attributes is modified for all the element occurrences that correspond to the rows of the table.

Tables can be sorted (in ascending or descending order) according to the contents of any column using XML | Table | Ascending Sort or Descending Sort.

Additional rows (i.e., element occurrences) can be appended or inserted using XML | Table | Insert Row.

You can copy-and-paste structured data to and from third party products

The familiar intelligent editing feature is active in Table View also.


Displaying an element type as a Table

To display the Person element type as a table:


1.In Grid View, select either of the Person elements by clicking on or near the Person text.


2.Select the menu option XML | Table | Display as table, or click the Display as Table ic_disp_as_tbl icon. Both Person elements are combined into a single table. The element and attribute names are now the column headers, and the element occurrences are the rows of the table.


3.Select the menu option View | Optimal widths, or click the Optimal Widths icon, ic_opt_widths to  optimize the column widths of the table.


Note:Table View can be toggled off for individual element types in the document by selecting that table (click the element name in the table) and clicking the Display As Table ic_disp_as_tbl icon. Note however that child elements which were displayed as tables will continue to be displayed as tables.


Entering content in Table View

To enter content for the second Person element, double-click in each of the table cells in the second row, and enter some data. Note, however, that PhoneExt must be an integer up to 99 in order for the file to be valid. The intelligent editing features are active also within cells of a table, so you can select options from dropdown lists where options are available (Boolean content and the enumerations for the Degree attribute).


Note:The Entry Helpers are active also for the elements and attributes displayed as a table. Double-clicking the Person entry in the Elements Entry Helper, for example, would add a new row to the table (i.e., a new occurrence of the Person element).


Copying XML data to and from third party products

You can copy spreadsheet-type data between third party products and XML documents in XMLSpy. This data can be used as XML data in XMLSpy and as data in the native format of the application copied to/from. In this section you will learn how to copy data to and from an Excel data sheet.


Do the following:


1.Click on the row label 1, hold down the Ctrl key, and click on row label 2. This selects both rows of the table.


2.Select the menu option Edit | Copy as Structured text. This command copies elements to the clipboard as they appear on screen.
3.Switch to Excel and paste (Ctrl+V) the XML data in an Excel worksheet.


4.Enter a new row of data in Excel. Make sure that you enter a three digit number for the PhoneExt element (say, 444).


5.Mark the table data in Excel, and press Ctrl+C to copy the data to the clipboard.
6.Switch back to XMLSpy.
7.Click in the top left data cell of the table in XMLSpy, and select Edit | Paste.


8.The updated table data is now visible in the table.
9.Change the uppercase boolean values TRUE and FALSE to lowercase true and false, respectively, using the menu option Edit | Replace (Ctrl+H).


Sorting the table by the contents of a column

A table in Table View can be sorted in ascending or descending order by any of its columns. In this case, we want to sort the Person table by last names.


To sort a table by the contents of a column:


1.Select the Last column by clicking in its header.


2.Select the menu option XML | Table | Ascending sort or click on the Ascending Sort icon ic_sort_a. The column, and the whole table with it, are now sorted alphabetically. The column remains highlighted.


The table is sorted not just in the display but also in the underlying XML document. That is, the order of the Person elements is changed so that they are now ordered alphabetically on the content of Last. (Click the Text tab if you wish to see the changes in Text View.)

3.Select the menu option XML | Validate or press F8. An error message appears indicating that the value '444' is not allowed for a PhoneExt element (see screenshot). The invalid PhoneExt element is highlighted .


Expand "Details" to see that PhoneExt is not valid because it is not less than or equal to the maximum value of 99. You can click on the links in the error message to jump to the spot in the XML file where the error was found. Since the value range we set for phone extension numbers does not cover this extension number, we have to modify the XML Schema so that this number is valid. You will do this in the next section.


© 2020 Altova GmbH