Table View is integrated in the Grid View and allows you to view recurring elements in table form. Table View is different from the normal Grid View in that it creates a column for each child-type of the element displayed as a table. You can then modify properties for entire columns or selections. For instance, consider the following XML document:
The document element is article, and article has the following sequence of child elements: one title element, four sect1 elements, and one appendix element. Each sect1 and appendix element has one title element followed by any number of para or simpara elements. The normal Grid View of this document is as follows:
Now here is the Table View of this document—more correctly, that of the article element. (To get this view: select the article element in normal Grid View (by clicking on it) and click the Display as Table icon . Alternatively, select the menu item XML | Table | Display as Table (F12).)
Notice that each child element of article (the element displayed as a table)—that is, title, sect1, and appendix—has been assigned a column and that each occurrence of each child-type is listed in the appropriate column. Note also that the table structure extends only to the child level (the sect1 elements themselves are not displayed as a table). In order to display sect1 elements as a table, select any of the sect1 elements in the sect1 column, and click . The sect1 elements are now displayed in a table (see screenshot below): each of their child elements is assigned a column in the sect1 table.
In each column, if a child element (title, simpara, or para) exists for one of the four occurrences of sect1, then that cell has a white background (e.g. simpara in the first sect1). If a child does not exist for an occurrence then the corresponding cell has a gray background (e.g. para in first sect1). It should be apparent, therefore, that columns were assigned by taking a union of all child elements of all sect1 occurrences, and creating a column for each unique child-type.
|Note:||Attributes are also considered child nodes, and columns are also created for attributes. You can switch between normal Grid View and Table View by selecting the desired element and clicking or F12. If you are viewing the document in Table View and you switch to Text View, when you switch back to Grid View the document will display in normal Grid View.|
Manipulating table data
You can manipulate table data in the following ways:
|•||Drag-and-drop column headers to move columns.|
|•||Sort column data for text nodes using the menu command XML | Table | Ascending Sort (also Descending Sort).|
|•||Append (or insert) rows using the menu command XML | Table | Insert Row (also Append Row).|
Moving data between Table View and external applications
You can take advantage of the table structure of data in Table View to exchange data between Table View and a spreadsheet application. To move data from Table View to another application, select the required nodes in the table and use the Copy as Structured Text option to copy/paste the data directly into, say, an Excel sheet. (You can select nodes in Table View by clicking the cells themselves, column headers, row headers, or the entire table. If you click the entire table or column headers, then the text of the column headers is also copied; otherwise it is not.)
The screenshot above shows six item elements displayed as a table in Table View, with two rows selected. To copy these two rows into an Excel sheet, copy them as structured text, and paste them into an Excel sheet. The result will be as shown below. For more details, see the description of the menu command Copy as Structured Text in the user reference section.
Data exchange works in both ways. So you can copy data from any spreadsheet-like application and insert it directly into a table in Table View. Do this as follows:
|1.||Select a range in the external application and copy it (to the clipboard, in Windows systems with Ctrl+C)|
|2.||Select a single cell in Table View of your XML document.|
|3.||Paste the copied data with Ctrl+V.|
The data will be pasted into the table in XMLSpy with a cell structure corresponding to the original structure and starting from the cell selected in Table View. The following points need to be noted:
|•||If data already exists in these cells in Table View, the new data overwrites the original data.|
|•||If more rows are required to accommodate the new data, these are created.|
|•||If more columns are required to accommodate the new data, these are not created.|
|•||The data in the cells becomes the contents of the elements represented by the respective cells.|
For more complex data exchange tasks, XMLSpy also offers a set of unique conversion functions that let you directly import/export XML data from/to any text file, Word document or database.
© 2019 Altova GmbH