In Grid View, the XML document structure can be edited graphically. For example, you can collapse and expand individual segments of the document structure, insert, append and delete nodes, drag-and-drop nodes to different locations, and convert one type of node to another type.
Adding new nodes
There are two ways to add new nodes to the document:
•The Siblings and Children entry helpers enter specific nodes at the selected location. For this to work, an XML document must be associated with a schema (DTD or XML Schema). For example, when you select a node in the Main Window, the sibling and children that are allowed at that point (according to the schema) are displayed in the Siblings and Children entry helpers, respectively. You can select the node to add via the entry helpers.
•You can add a new node that is not defined in a schema as a sibling, child, or parent. The commands to do this are available in context menus of Grid View cells, and also in the XML menu and Grid View toolbar.
Siblings and Children entry helpers
If an XML document is associated with a schema (DTD or XML Schema), then the available siblings and children of a selected node are displayed in the Siblings and Children entry helpers. In each of these entry helpers, you can toggle the visibility of elements and attributes on or off by clicking their respective toolbar icons. Mandatory nodes are displayed with an exclamation mark. Nodes in gray cannot be added. This is because of one of the following reasons: (i) The node has already been added, and no more instances of it are allowed by the schema, as in the case of the Address sibling in the screenshot below; (ii) Another node needs to be added before the grayed out node can be added, as in the case of the Last child in the screenshot below, which can be added only after the First child has been added.
Add nodes as follows:
•Siblings: In the entry helper, select the node you want to add as a sibling. Then click the appropriate icon (see screenshot above left), depending on whether you want to add the sibling after or before the node selected in the grid, or append it as the last of the selected node's siblings.
•Children: Double click the node you want to add as a child.
Inserting new nodes
When a node in the document (that is, a grid cell) is selected, you can add a new empty node as a sibling, child, or parent. The commands for these operations are listed in the table below, and are available in: (i) the context menu of the cell; (ii) the XML menu; and (iii) the Grid View toolbar.
Insert (Sibling) After
Insert (Sibling) Before
Wrap in Element
Note the following points:
•The new node is created as an empty element by default. You can change the node type subsequently.
•The Wrap in Element command creates an element node around the current node. This element becomes the new parent of the current node.
Modifying structure with standard Windows mechanisms
In Grid View, you can also modify document structure using the following Windows mechanisms:
•Delete: Select a component and delete it with the Delete key.
•Move: Select a component and drag-and-drop it to a new location.
Display as table
Repeating elements are shown in standard Grid View, one after the other, progressing vertically downward in document order (screenshot below left). However, displaying repeating elements as the rows of a table provides additional editing features. In the screenshots below, the Person element is the repeating element. The screenshot at left shows standard Grid View; the first Person element is shown expanded, while subsequent instances are shown collapsed. The screenshot at right shows the repeating Person elements as the rows of a table.
To switch to Table View, click the Table Mode icon (circled in green in the screenshot below left). When switched to table display, the icon is displayed in color (see screenshot below right).
Table View offers unique editing benefits in that whole rows and columns can be manipulated relative to other columns and rows in the table. This enables such operations as sorting table rows on the values of one column. For example, in the screenshot above right, the six Person elements can be sorted on the basis of their Last child elements via a single command in the Grid View toolbar. This is simpler than running an XSLT transformation, which would be the usual way to sort an XML nodeset.
For more information, see the topic Table Display.