Cladonia, proud developers of the Exchanger XML Editor

Cladonia - simplifying XML!

Home News Links About Contact

Overview
Features
FAQ
Online Help
Getting Started
Menus
Preferences
Toolbars
Download
Extensions
Evaluate
Buy
User Forum

Platforms
The Exchanger XML Editor runs on all platforms:
Windows
Linux
Mac OS X
Any Unix Platform
Other Java Enabled Platforms

Further Information
For more information download the V3.1 User Guide.
  User Guide (A4) (2.19MB)
  User Guide (US) (2.18MB)
  What's New (833KB)

Newsletter
Subscribe to Newsletter
Keep up to date with our latest product releases by subscribing to our newsletter.

Editing XML using the Grid

The Grid view provides a convenient means for viewing and editing XML while shielding the user from the complexities of the actual markup. While the grid is particularly useful for handling structured data, such as purchase orders or medical records, it also supports documents that contain mixed content.

Grid Overview

Figure 1. Grid Overview

Grid Layout

The Grid display is a combination of a single tree and multiple table components. The nodes in the tree represent the element hierarchy. When a node on the tree is expanded, a table is displayed to show the children of the current element. Each row in the table represents a single child element, while the columns correspond to the element name, the text content of the element (if any) and the attribute values for the element (if any).

Grid functionality for creating, modifying and deleting nodes is avilable via the Grid Tool Bar which runs vertically on the left hand side of the Grid display. Alternatively, you can use the Grid Menu (and create keyboard short cuts for commonly used functions) or right-click in the Grid to display the pop-up Context menu.

Opening an XML Document in the Grid View

Open the file PurchaseOrder.xml in the Grid Example project. By default, the Editor view is selected and contains a text-based view of the file.

Purchase Order in Editor

Figure 2. Purchase Order in Editor

Make sure that the file is well-formed by looking for any errors or warnings in the Errors output panel or by explicitly choosing the XML->Check Well-Formedness menu item or by pressing the Check Well-Formed button . If any well-formedness errors are reported, it is necessary to rectify them before attempting to use the Grid. To switch from the Editor view to the Grid view, press the Grid button in the top right of the application or choose the View->Grid menu item or press Ctrl-5. The document is displayed in collapsed fashion so that only the root element is initially visible.

Purchase Order in Grid

Figure 3. Purchase Order in Grid

Expanding and Collapsing Elements

If an element has children, the child elements are displayed in a table by clicking on the Expand symbol in the tree. Depending on the current Look and Feel, this symbol may be a "plus" sign () or a "handle" ( ). Expand the root element and observe how its children are displayed in a table, with each row corresponding to a single child element. The columns correspond to the element name(, the text content, if any () and the attributes, if any ().

First Level Table

Figure 4. First Level Table

If a child element has descendants itself, then it too will have an Expand icon in the tree outline. Repeatedly click the Expand icons to open up all descendant elements.

Second Level Table

Figure 5. Second Level Table

To hide the table displays representing descendant elements, click the Collapse symbol in the tree outline. Depending on the current Look and Feel, this symbol may be a "minus" sign () or a "opened handle" ().

To display an entire document all at once in the Grid, click on the Expand All button on the Editor toolbar or choose the View->Expand All menu item. Similarly, a partially or fully displayed document can be collapsed using the Collapse All button on the Editor toolbar or the View->Collapse All menu item.

Note: Use the Expand All functionality with care as displaying very large documents in full in the Grid may consume significant system resources.

Tabular Navigation

Normal spreadsheet conventions are used for navigating within the table. Up/Down Arrow keys change the current row, while Left/Right Arrow keys change the current column.

The Tab key chooses the next cell in the current row and moves to the first cell in the next row after you encounter the last cell in the current row. Use the Tab key when you want to do a breadth-first traversal of a table. Shift-Tab allows you to navigate in reverse, choosing the previous cell in the current row, and then the last cell in the previous row after you encounter the first cell in the current row.

The Enter key chooses the next cell in the current column and moves to the first cell in the next column after you encounter the last cell in the current column. Use the Enter key when you want to do a depth-first traversal of a table. Shift-Enter allows you to navigate in reverse, moving focus to the previous cell in the current column, and then the last cell in the previous column after you encounter the first cell in the current column.

Tree Navigation

Menu items are also provided for expanding and collapsing the tree. Choose Grid->Navigate->Expand Row and Grid->Navigate->Collapse Row as an alternative to using the symbols in the tree. The element that is currently selected will be expanded or collapsed (provided of course that it has children). While the menu items may not be as convenient as using the symbols in the tree outline, they do allow for the possibility of creating corresponding keyboard shortcuts that facilitate navigation without using the mouse. Choose File->Preferences... and on the Keys tab, assign keystrokes for the Grid: Expand Row and Grid: Collapse Row actions.

A not-so-obvious benefit of using the Grid Expand Row/Collapse Row menu items surrounds the issue of focus. When expanding an element with the mouse on the Grid tree, the focus is lost and another mouse click is required to select a cell in the expanded table. However, when using the Grid->Expand Row menu item (or the corresponding keyboard shortcut if assigned), the focus is programatically set to the first cell in the expanded table.

A number of other functions are provided to assist with navigating up and down the tree structure.

To move focus from the current element to its first child element, choose Grid->Navigate->Goto Child Table. The table representing the children will be displayed (if not already visible) and focus will be moved to the first element in the table.

Use Grid->Navigate->Goto Parent Table to move focus from anywhere in a child table to the parent element. The current table remains visible.

To collapse the current table, choose Grid->Navigate->Collapse Current Table. Focus is returned to the parent element.

Together with the tabular navigation keys (ENTER, TAB, UP/DOWN ARROW, LEFT/RIGHT ARROW), the Grid->Navigate menu functions facilitate navigation up and down the Grid and within tables. Setting keyboard shortcuts for these functions supports navigation without having to resort to using the mouse.

Table Header

The table header is displayed in a different color so that tables can be easily identified from one another. The table header contains an XPath representation for the current element, showing the ancestry from the root node. If the preferences have been set to generate unique XPaths (on the Views tab of the File->Preferences dialog) then a fully qualified repesentation will be displayed.

Grid Table Header

Figure 6. Grid Table Header

Column Header

The Column Header appears directly below the table header and identifies the columns relating to element name, attribute names and text content of the elements in the table.

Grid Column Header

Figure 7. Grid Column Header

Columns can be visually sorted in ascending or descending alphabetical order by clicking on a cell in the column header. Sorting is purely for display purposes and does not affect the underlying document order.

Column widths can be adjusted by positioning the mouse on the divider between any two cells in a column header and dragging the mouse to the left or right.

Some or all of the attribute columns and the text column in a table can be hidden to improve usability. Right-clicking on a cell in the column header and in the popup context menu, choose Show/Hide Columns.

For more information on sorting, resizing and showing/hiding columns, see the following sections.

Sorting Columns

Element, attribute and text columns can all be sorted by clicking the corresponding cell in the column header. Clicking the first time will sort in ascending alphabetical order, clicking the second time will sort in descending order while clicking a third time will return to document order. It is important to realise that sorting is purely visual and has no effect on the underlying order of the data. To physically move elements with respect to one another requires the use of the Move Element Up, Move Element Down functionality , or the Copy/Cut/Paste functionality described in the following sections.

The sorting functionality can also be accessed though the Grid->Move/Sort menu or via the Column Header context menu.

Attribute Column Sorted in Ascending order

Figure 8. Attribute Column Sorted in Ascending order

Attribute Column Sorted in Descending Order

Figure 9. Attribute Column Sorted in Descending Order

Attribute Column Unsorted (Document Order)

Figure 10. Attribute Column Unsorted (Document Order)

Resizing Column Widths

By default, table columns have equal width. To resize a column, position the mouse on the divider between two column header cells and drag to the right or left as required.

Columns before Resizing

Figure 11. Columns before Resizing

Columns after Resizing

Figure 12. Columns after Resizing

Showing/Hiding Columns

When an element has many attributes, each attribute column can be very narrow and hence difficult to use. To temporarily hide a column, right-click in the column header. This gives rise to a popup context menu of actions that operate on a table column.

Context Menu - Show/Hide Columns

Figure 13. Context Menu - Show/Hide Columns

In the popup context menu, choose the Show Columns item and untick the appropriate attribute name or text column. To show columns that have already been hidden, reverse the process by right-clicking in the column header or in the table header and ticking the attribute name or text in the Show Columns sub-menu.

Grid after Hiding Columns

Figure 14. Grid after Hiding Columns

Selecting a Cell

To select a cell, single-click the mouse in a table on the required cell and the cell will be highlighted. The XPath Field below the main toolbar will be updated to reflect the current position and, if the Navigator is visible in the Controller window, the tree outline will be expanded to the appropriate node.

Cell Selection

Figure 15. Cell Selection

It is also possible to select a cell using an XPath query or using the Navigator. For more information, see the sections Selecting Cells using XPath Queries and Selecting Cells using the Navigator.

When a cell is selected, the entire cell is highlighted. The current row is selected for Row-Based actions and the current column is selected for Column-Based actions - see the sections on editing for more details.

Basic Editing in the Grid

Content can be easily added to any cell by simply selecting the cell and starting to type. The new content will be appended to any existing content. Press ENTER to finish editing - the cell focus automatically moves onto the next cell in the column. Alternatively, press ESCAPE to undo the editing and return the cell content to its original value.

Typing directly into a selected cell is convenient when the cell is empty. However, when a cell already has content, you will typically want to edit the content rather than append to the end. To achieve this, double-click on a cell to enter editing mode. The cell outline is highlighted and a cursor appears in the cell and the current word is selected.

Normal text editing functionality is available via keyboard short-cuts, including Delete Previous Character (BACKSPACE), Delete Next Character (DELETE), Copy (Ctrl+C), Cut (Ctrl+X ), Paste (Ctrl+V), Next Word (Ctrl+Right Arrow), Previous Word (Ctrl-Left Arrow), Start of Text (HOME), End of Text (END).

Press ENTER to finish editing - the cell focus stays in the current cell after exiting edit mode. Alternatively, press ESCAPE to undo the editing and return the cell content to its original value. Note that while in editing mode, the Expand/Collapse icons in the tree outline disappear so as to disable changes to the overall grid display while editing. The icons reappear on completion of editing.

Copy, Cut and Paste in the Grid

The Grid provides two distinct forms of functionality for Copy, Cut and Paste:

  • Basic Copy, Cut and Paste for XML Data (Attribute Values and Text Content)

  • XML-Aware Copy, Cut and Paste for XML Structures (Element and Attribute Nodes)

The Basic functionality makes it simple to move the data content around in a document while the XML-Aware functionality facilitates moving complete XML structures. The Basic form is explained in the following section while the XML-Aware form is documented later in this guide.

Basic Copy, Cut and Paste for Data

The Grid makes it easy to manipulate the data content of an XML document. Attribute values and text content can easily be copied or cut by selecting the appropriate cell and using the normal Copy and Cut functions.

To copy an attribute cell, highlight the cell and use Ctrl+C or Edit->Copy. To paste the attribute, select the target cell and use Ctrl+V or Edit->Paste. If the target cell is another attribute cell, the attribute value overwrites the contents of the cell. Similarly, if the target cell is a text cell, the attribute value overwrites the contents of the text cell.

However, if the target cell is an element cell, the XML-Aware functionality is used and a new attribute name-value pair is added to the element, provided an attribute of the same name does not already exist there. See the XML-Aware documentation in a later section for more details on pasting attribute nodes into elements.

To copy a text cell, highlight the cell and use Ctrl+C or Edit->Copy. To paste the text, select the target cell and use Ctrl+V or Edit->Paste. If the target cell is an attribute cell, the text content overwrites the attribute value. Similarly, if the target cell is another text cell, the text content overwrites the current content of the target cell.

However, if the text is pasted into an element cell, the XML-Aware form is used and a new text node is added to the element, at the end of any existing text content. See the XML-Aware documentation in a later section for more details on pasting text nodes into elements.

To cut an attribute cell and put it on the clipboard, highlight the cell and use Ctrl+X or Edit->Cut Note that the entire attribute node (i.e. both the attribute name and attribute value) is removed. Alternatively, to delete the entire attribute node without putting it on the clipboard, simply highlight the attribute cell and press DELETE.

To set an attribute value to null, but to leave the attribute node in place (i.e. to go from attr_name="attr_val" to attr_name=""), just double-click on the cell to enter editing mode, delete the cell contents and press ENTER.

To cut a text cell and put it on the clipboard, highlight the cell and use Ctrl+X or Edit->Cut. Alternatively, to delete the text node without putting it on the clipboard, simply highlight the text cell and press DELETE.

Special Characters

XML requires the escaping of certain characters in attribute values and in text content. In general, it is good practice to use entites for all special characters - & for the ampersand character, ' for the single quote, &quote; for the double quote, < for the less-than sign and > for the greater-than sign.

The Grid interface tries to simplify the user's life by automatically escaping these characters when entered in attribute values and text content. Type in these characters as normal when editing the contents of a cell and press ENTER to finish editing. The special characters will automatically be converted to their corresponding entities, thus ensuring that the XML is well-formed. To explicitly enter other entities, simply enter them as named entity, for example, © for the copyright sign. Provided the entity is well-formed, the Grid will not escape the ampersand character when it occurs as part of an entity. Note that this escaping of special characters is turned off when Mixed Content mode has been chosen in the Grid Properties - see the following section for more details.

Mixed Content

Mixed Content is the name given to the situation where an element has both text content and sub-structure. For example, the paragraph element (<P>) in XHTML can contain text and also styling elements such as bold (<B>) and italics (<I>). While the Grid view is better suited to handling structured XML Data (e.g. Purchase Orders) as opposed to XML Documents (e.g. XHTML or DocBook Article), it does provide some limited support for elements with mixed content.

To enable Mixed Content mode, select View->Grid Properties->Support Mixed Content from the main menu. In Mixed Content mode, the automatic escaping of special characters described earlier in this section is disabled. An element containing both text content and sub-elements will be represented in the grid by a single cell, with the text and element/attribute markup directly editable in the cell. The onus is on the user to ensure that any editing of the cell ensures that the cell contents remain well-formed.

If the grid encounters and element with mixed content while not in Mixed Content mode, it does its best to handle the situation by grouping all the text content in a single cell, and creating a table for the sub-elements. The complete element can still be treated in its entireity in the grid for functions such as move, copy, cut and paste. However, if edits are made to the mixed content, the outcome is unpredictable. In this situation, switch to Mixed Content mode in the Grid, or alternatively switch to the text-based Editor for better support for editing mixed content.

In general, Mixed Content mode should only be used in special circumstances, for example, to easily manipulate the overall structure of XML documents, and not for regular editing of mixed content which is probably more suited to the text-based Editor view.

CDATA

CDATA sections will appear in the Grid as text content, delimited by the normal <![CDATA[ and ]]> strings.

Processing Instructions and Comments

The Grid editor does not support creating, editing or deleting processing instructions or comments. However, if any of these node types already exist in a document, the Grid view will maintain the nodes without modification.

Undo and Redo in the Grid

Normal Undo/Redo functionality is available for all editing operations on the grid. Use the regular Ctrl+Z and Crtl+Y shortcuts or the Edit->Undo or Edit->Redo menu items. TODO

NOTE: The Undo/Redo history is lost when switching views between the Grid and the Editor.

Row-Based (Atomic) Operations versus Column-Based (Aggregate) Operations

Editing functionality is divided between Atomic actions that operate on a single element (or row) and Aggregate actions that operate on all elements in a table (column-based).

When a cell is selected (highlighted), the current row is selected for Atomic actions and the current column is selected for Aggregate actions.

Row-Based actions include:

  • Add Attribute, Add Text, Add Element Before, Add Element After, Add Child Element.

  • Delete Attribute, Delete Text, Delete All Attributes and Text, Delete Element, Delete Children.

  • Move Element Up, Move Element Down.

Column-Based actions include:

  • Add Attribute to All Elements in Table, Add Text to All Elements in Table

  • Delete Attribute from All Elements in Table and Delete Text from All Elements in Table.

  • Sort Ascending, Sort Descending, Unsort.

Row-Based (Atomic) Operations

Elements - How to Add, Modify, Move and Delete Elements

Add Element Before

To add an element immediately preceding the current element, press the Add Element Before icon on the Grid Toolbar or select Grid->Add->Add Element Before from the menu or right-click on the element cell and choose Add Element Before on the pop-up context menu. Enter the element name and text content (if any) in the dialog and press OK.

Add Element After

To add an element immediately following the current element, press the Add Element After icon on the Grid Toolbar or select Grid->Add->Add Element After from the menu or right-click on the element cell and choose Add Element After on the pop-up context menu. Once again, enter the element name and text content (if any) in the dialog and press OK.

Add Child Element

To add an element as a child of the current element, press the Add Child Element icon on the Grid Toolbar or select Grid->Add->Add Child Element from the menu or right-click on the element row and choose Add Child Element on the pop-up context menu. Enter the element name and text content (if any) in the dialog and press OK. If you add a child to an element that already has children, the new element will be appended at the end of the list of existing children. (If you need to change the position of the newly created child, you can use the Move Element functions described later).

Rename Element

To modify the name of an element, double-click on the element name cell and use the normal editing functionality to change the name.

Move Element

While sorting only has a visual effect, the underlying order of elements can be changed using Move Element Up and Move Element Down. To move an element (and all its attributes, text and sub-structure) earlier in document order relative to its siblings, select a cell on the element row and press the Move Element Up icon on the Grid Toolbar (or use the Grid->Move/Sort->Move Element Up menu item).

To move an element later in the document relative to its siblings, select a cell on the element row and press the Move Element Down icon on the Grid Toolbar (or use the Grid->Move/Sort->Move Element Down menu item)

Delete Element

To delete the current element, press the Delete Element icon on the Grid Toolbar or select Grid->Delete ->Delete Element from the menu or right-click on the element cell and choose Delete Element on the pop-up context menu. If the deleted element is the last or only row in a table, then the table is removed on the delete operation. To restore a deleted element, select Edit->Undo from the main menu or press Ctrl-Z.

Delete Children

To delete all the children of an element, select the element and press the Delete Children icon on the Grid Toolbar or select the Grid->Delete->Delete Children menu item or right-click on the element cell and choose Delete Children on the popup context menu. Note that Delete Children only removes sub-elements. Any text content and/or attributes must be removed using the Delete Attributes and Text functions described in the following sections.

Attributes - How to Add, Modify and Delete Attributes on the current Element

Add Attribute

The mechanism for adding a new attribute to an element depends on whether or not the attribute column already exists in the current table. If the attribute column exists, highlight the appropriate cell by single-clicking the mouse, or navigate to it using the arrow keys or other keyboard shortcuts. There is no need to double-click to enter editing mode - simply type in the required attribute value and press ENTER when finished.

To create a new attribute and set its value for the current element (row), press the Add Attribute icon in the Grid Toolbar , or choose the Grid->Add->Add Attribute menu item or right-click on the element cell and choose Add Attribute from the popup context menu. Enter the attribute name and value (if any) in the pop-up dialog and press OK. A new column will be added to the table and the attribute value will appear in the appropriate cell.

Edit Attribute Value

To modify an existing attribute value, double-click on the appropriate cell to enter editing mode and then use the normal editing functions to change the value. When finished, press ENTER.

Rename Attribute

To rename a single attribute on an element, highlight the appropriate cell and select Grid->Edit->Rename Attribute from the menu. Alternatively, right-click on the cell and on the popup content menu, select Rename Attribute. Enter the new attribute name in the dialog and press OK. If an attribute of that name already exists on the current element, a warning will be given and the rename operation will not succeed.

Delete Attribute Value

To delete an attribute value, double-click on the appropriate cell to enter editing mode. Select the contents of the cell, for example, using Ctrl+A and then press the DELETE button. The attribute will remain on the element, but its value will be empty.

Delete Attribute Name-Value Pair

To delete an attribute completely from an element, removing both the attribute name and the attribute value, highlight the cell corresponding to the attribute and press the the DELETE button. Alternatively use the Delete Attribute icon on the Grid Toolbar or select Grid->Delete->Delete Attribute. To remove the attribute completely and put it on the clipboard, select the cell and use the normal Cut functions (Ctrl+X or Edit->Cut).

Text - How to Add, Modify and Delete Text on the current Element

Add Text

The mechanism for adding text content to an element depends on whether or not a Text column already exists in the current table. If the Text column exists, simply select the appropriate cell by single-clicking the mouse, or navigate to it using the arrow keys or other keyboard shortcuts and then start typing. If the Text column is not already present, press the Add Text icon on the Grid Toolbar or select Grid->Add->Add Text from the menu or right-click on the element cell and choose Add Text on the pop-up context menu. A new colum will appear in the table with the text content in the appropriate cell.

To append content to an existing text cell, simply highlight the cell and start typing. Editing mode is automatically entered, and the normal text editing conventions apply. To finish editing and maintain the changes, press ENTER, or alternatively press ESCAPE to return the cell content to its previous state.

Edit Text

To edit the content of an existing text cell, double-click on the cell to enter editing mode. Normal text editing functionality is available via keyboard short-cuts, including Delete Previous Character (BACKSPACE), Delete Next Character (DELETE), Copy (Ctrl+C), Cut (Ctrl+X ), Paste (Ctrl+V), Next Word (Ctrl+Right Arrow), Previous Word (Ctrl+Left Arrow), Start of Text (HOME), End of Text (END), Press ENTER to finish editing - the cell focus is moved to the next cell in the current column. Alternatively, press ESCAPE to undo the editing and return the cell content to its original value.

Delete Text

To delete the text content of an element, simply highlight the text cell and press DELETE. Alternatively, if the element name cell is selected, press the Delete Text icon on the toolbar or choose Grid->Delete->Delete Text, or right-click on the element cell and choose Delete Text from the popup context menu.

Column-Based (Aggregate) Operations

How to Add an Attribute to All Elements in a Table

To add an attribute (and potentially a corresponding attribute value) to all the elements in a table, select any cell in the table and press the Add Attribute Column icon in the Grid Toolbar or select the Grid->Add->Add Attribute Column menu item. In the popup dialog, enter the attribute name and, if required, a value that will be added for each attribute and then press OK. A new column will appear in the table, with each cell containing the specified attribute value, if one was specified.

How to Rename an Attribute for all Elements in a Table

To rename an attribute column, highlight a cell and select Grid->Edit->Rename Attribute Column from the menu. Alternatively, right-click on the column header and on the popup menu, select Rename Attribute Column. Enter the new attribute name in the dialog and press OK. If an attribute column of that name already exists in the current table, a warning will be given and the rename operation will not succeed.

How to Add Text to all Elements in a Table

If there is not already a text column in a table (i.e. none of the elements have text content) then a fixed piece of content can easily be added to all elements by pressing the Add Text Column icon in the Grid Toolbar or selecting the Grid->Add->Add Text Column menu item. Enter the placeholder text in the popup dialog and press OK to have a new text column appear in the table.

How to Delete an Attribute from all Elements in a Table

To remove an attribute from all the elements in a table, select a cell in the appropriate attribute column and press the Delete Column icon in the Grid Toolbar or select the Grid->Delete->Delete Column menu item. Alternatively use the Column Header context menu as described later in this section.

How to Delete Text from all Elements in a Table

To remove the text content from all the elements in a table, select a cell in the text column and press the Delete Column icon in the Grid Toolbar or select the Grid->Delete->Delete Column menu item.

XML-Aware Copy, Cut and Paste

The Grid provides special functionality for easily moving complete XML structures. When in editing mode, the Copy, Cut and Paste functions deal only with text, so that element names, attribute values and text content can be copied, cut or pasted on an individual basis. However, it is also possible to copy or cut complete XML structures and paste them in another part of the document.

Copy/Cut an XML Element

To copy an entire XML element, including its attributes, text content and sub-structure, highlight the cell representing the element name by single-clicking on the cell or by navigating to it using the navigation keystrokes and then use the regular Copy function using Ctrl+C or selecting Edit->Copy on the main menu or right-click in the element cell and choose Copy on the popup context menu. Similarly, to cut an entire element, use Ctrl+X or select Edit->Cut on the main menu or right-click in the element cell and choose Cut on the popup context menu.

Paste an XML Element

To paste an entire element, including its sub-structure, select the cell for the element that will act as the parent and use the normal paste action. Either press Ctrl+V or select Edit->Paste or right-click on the target parent and select Paste from the popup context menu. The element will be inserted as a child of the target element. If the parent element already has children, the pasted element will be inserted as the last child. The pasted element can then be moved into position using the Move Element Up functionality if required.

Paste Special

While the default operation for paste is to create a new child element, it is also possible to paste as a sibling of the target element, using the Paste Special functions. Highlight the target element and select Grid->Edit->Paste Special from the menu or right-click on the target element and choose Paste Special from the popup context menu. Options are given to paste the source element as a preceeding sibling of the current (highlighted) element using Paste Before or to paste it as a following sibling using Paste After. The default paste option, Paste as Child, is also provided on the Paste Special menus.

Copy Special

While the default Copy action on a selected element takes all the sub-structure (i.e. it is a "deep" copy), it is also possible to just copy the element name and any attributes by using the Copy Special function. Highlight the element to be copied and select Grid->Edit->Copy Special from the menu or right-click on the element cell and choose Copy Special from the popup context menu. On the Copy Special sub-menu, select Copy Shallow to take the current element and attributes, but omitting any text or sub-elements. The regular Paste function or the Paste Special functions can be used to insert the copied nodes.

Copy/Cut an XML Attribute (Name-Value Pair)

To copy an entire XML attribute, including the attribute name and the attribute value, highlight the cell representing the attribute by single-clicking on the cell or by navigating to it using the navigation keystrokes and then use the regular copy function using Ctrl+C or selecting Edit->Copy on the main menu or right-click on the attribute cell and choose Copy on the popup context menu. Similarly, to Cut an entire XML attribute, use Ctrl+X or select Edit->Cut on the main menu or right-click and choose Cut on the popup context menu.

Paste an XML Atrribute (Name-Value Pair)

To paste an entire attribute, including the attribute name and the attribute value, select the cell for the target element and use the normal paste action. Either press Ctrl+V or select Edit->Paste or right-click on the target element and select Paste from the popup context menu. If the target element already has an attribute of the same name, the paste operation will fail with a warning.

Table 1.  Copy/Cut/Paste Summary

First Action Second Action Description
Copy from Attribute cell Paste to Attribute cell Replaces attribute value in target Attribute cell
Copy from Attribute cell Paste to Text cell Replaces content in target Text cell
Copy from Attribute cell Paste to Element cell Adds Attribute name and value to target Element (if attribute with that name does not already exist)
Copy from Text cell Paste to Text cell Replaces content in target Text cell
Copy from Text cell Paste to Attribute cell Replaces attribute value in target Attribute cell
Copy from Text cell Paste to Element cell Adds Text node to target Element (appended to existing text content)
Copy from Element cell Paste to Text cell Replaces text content in target Text cell with element name
Copy from Element cell Paste to Attribute cell Replaces attribute value in target Attribute cell with element name
Copy from Element cell Paste to Element cell Adds child Element node to target Element (appended to existing children)
Copy from Element cell Paste Special->Paste Before Adds a sibling Element node before target Element
Copy from Element cell Paste Special->Paste After Adds a sibling Element node after target Element
Copy Special->Copy Shallow from Element cell Copy to the clipboard the current element plus attributes plus text but minus any child elements
Cut or DELETE Attribute cell Removes attribute name and value from current element
Cut or DELETE Text cell Removes text content from current element
Cut or DELETE Element cell Removes current element (removes table if last/only child element)
Paste Attribute cell in Editor view Attribute name-value pair inserted at cursor
Paste Text cell in Editor view Text content inserted at cursor
Paste Element cell in Editor view Element inserted at cursor, including attributes, text and sub-elements

Multiple Document Interface and Grids

The Copy/Cut/Paste functionality in the Grid is not restricted to the current document. It is possible to move content between multiple documents that are open simultaneously in Grid view, or between one or more Grid views and one or more Editor (tag-based) views.

To demonstrate the convenience of concurrent grid views, we will build a new document for Contacts based on the ShippingAddress entries on the PurchaseOrder.xml file. The new document will be constructed so as to conform to the Contacts schema from the Schema Viewer project.

Open the PurchaseOrder.xml document in Grid view and navigate to the first ShippingAddress element by entering an XPath query //ShippingAddress[1] or by any other navigation method you prefer. Expand the ShippingAddress element to see the contact data we wish to transfer into the new document.

Now create a new file using File->New, selecting Default XML Document in the dialog. Change the view to Grid by pressing the Grid button or selecting View->Grid. Split the view vertically using View->Split Vertically or press the Split Vertically button on the main toolbar so that the two grids are displayed side-by-side.

Multiple Grids

Figure 16. Multiple Grids

(Note: If necessary, minimize the controller window and the output window to maximize the screen real estate available for the grids).

Rename the root element in the new document from xngr to Contacts by double-clicking on the element cell and entering the new name.

Add a Person element to the Contacts element by using the Add Child Element button or right-clicking and choosing Add Element->Add Child Element.

In the new document, add a Firstname element with text content Joe as a child of Person.

With the Firstname element cell selected, use Add Element After to create a sibling element Lastname with text content Smith.

In the PurchaseOrder.xml document, select the ShippingAddress element and use the normal copy function (Ctrl+C or Edit->Copy) to copy the element to the clipboard.

In the new document insert the copied element from the clipboard by right-clicking on the Lastname element and using Paste Special->Paste After.

Multiple Grids - Copy and Paste XML Structure

Figure 17. Multiple Grids - Copy and Paste XML Structure

In the new document, rename the ShippingAddress element to Address.

Add an attribute with name type and value equal to work to the new Address element.

Since we want to make the new document conform to Contacts schema from the Schema Viewer project , it is necessary to delete some of the elements in the new Address element. Delete the two elements called DeliverTo and the State element by selecting the relevant element cells and pressing DELETE.

Finally, rename the PostalCode element to Postcode and the newly created document should correspond to the structure required by the Contacts schema.

To check this is so, press the Validate button and enter the details for the location of the Contacts schema from the Schema Viewer project. On Windows, this will typically be located at C:\Program Files\Exchanger XML Editor 3.1\projects\Schema Viewer\schema\contacts.xsd

Multiple Grids - Validation

Figure 18. Multiple Grids - Validation

Advanced Navigation using XPath

Selecting Cells using the XPath Queries

Ease of browsing and navigation in the Grid is significantly improved through the use of XPath searches. In the PurchaseOrder.xml file, perform a sample XPath search by entering the query //LineItem in the XPath field and pressing enter.

The results corresponding to the three LineItem elements are listed in the Output window at the bottom of the screen in the XPath Results Tab. Notice how the Grid expands automatically to highlight the first result. Clicking on the second result in the XPath Results Tab will cause the appropriate element to be selected in the Grid.

While many XPath queries deal solely with elements, it is also possible to search based on attributes and text content. To find all the LineItem elements relating to hammers, enter the query //LineItem[@description='Hammer' ]

To find all the occurrences of attributes named description , use the XPath query //@description . A number of results are listed in the output panel, showing the fully qualified XPath for the result nodes. Click on any result and the corresponding atttribute cell will be highlighted automatically expanding any necessary tables.

To find the LineItem that is to be shipped to Freemont, enter the query: //LineItem/ShippingAddress/City[.='Freemont']

Selecting Cells using the Navigator

The Navigator is the middle tab in the Contoller window on the left hand side and provides a very convenient means of traversing a complex XML structure. By default, the Navigator shows all element nodes in the document, with colored icons used to differentiate elements from different namespaces. Double-clicking on a node in the Navigator causes the Grid to expand and highlight the appropriate cell. By default, only elements are displayed in the navigator but it is possible to turn on/off the display of element names, element content, attribute names and attribute values in the Navigator Properties dialog by pressing the Navigator Preferences button .

Customized views can be created in the Navigator by filtering based on Namespace or XPath. By default, element nodes in all namespaces are displayed, but specific namespaces can be chosen by clicking on the drop-down button to the right of the Namespace button and choosing from the list displayed. For more information, see the section on customizing the Navigator in the Exchanger XML documentation.

To create an XPath filter in the Navigator, press the XPath button and enter the XPath //LineItem. A tree view is displayed with each node representing a match to the XPath query. Double click on a node in the tree and the corresponding cell in the Grid will be highlighted. The Grid will automatically expand the hierarchy so that the correct table is displayed.

To show attributes as well as elements in the navigator, press the Navigator Preferences button and click to Show Attributes.

It is possible to store named XPath queries that can be reused in the Navagtor - see the section on Types in the Exchanger XML documentation for more information.

The Grid Toolbar

Grid functionality for creating, modifying and deleting nodes is avilable via the Grid Tool Bar which runs vertically on the left hand side of the Grid display.

Use the Add Attribute button or select Grid->Add->Add Attribute to add an attribute to the current element.

Use the Add Text button or select Grid->Add->Add Text to add a text node to the current element.

Use the Add Element Before button or select Grid->Add->Add Element Before to add an element immediately preceeding the current element.

Use the Add Element After button or select Grid->Add->Add Element After to add an element immediately following the current element.

Use the Add Child Element button or select Grid->Add->Add Child Element to add an element as a child of the current element.

Use the Delete Attribute button or select Grid->Delete->Delete Attribute to delete the selected attribute. This deletes both the attribute name and value from the current element.

Use the Delete Text button or select Grid->Delete->Delete Text to delete a text node from the current element.

Use the Delete Attributes and Text button or select Grid->Delete->Delete Attributes and Text to delete all the attributes abd text content for the current element.

Use the Delete Element button or select Grid->Delete->Delete Element to delete the current element.

Use the Delete Children button or select Grid->Delete->Delete Children to delete all the child elements from the current element.

Use the Add Attribute Column button or select Grid->Add->Add Attribute Column to add an attribute to all the elements in the current table.

Use the Add Text Column button or select Grid->Add->Add Text Column to add a text node to all the elements in the current table.

Use the Delete Column button or select Grid->Delete->Delete Column to delete the current column from a table. If the current column is an attribute column, this action deletes both the attribute name and value from all the elements in the current table.

Use the Move Element Up button or select Grid->Move/Sort->Move Element Up to move the current element before its immediately preceeding sibling in document order.

Use the Move Element Down button or select Grid->Move/Sort->Move Element Down to move the current element after its immediately following sibling in document order.

Using the Cell Context Menu

Right-clicking on any cell in in the Grid causes the Cell Context Menu to be displayed. For more information on the actions available, see the section on Row-Based (Atomic) Operations.

Cell Context Menu

Figure 19. Cell Context Menu

Using the Column Header Context Menu

Right-clicking on a column header cell gives rise to a popup context menu of actions that operate on a table column. For more information on the actions available, see the section on Column-Based (Aggregate) Operations.

Column Header Context Menu

Figure 20. Column Header Context Menu