# Editing in the Design view

The XML editor has a Design view, which represents the XML file simultaneously as a table and a tree. This helps make navigation and editing easier. Content and attribute values can be edited directly in the table cells, while pop-up menus on the tree elements give alternatives that are valid for that particular element.

For example, the Add child menu item will list only those elements from a DTD or XML schema which would be valid children at that point.

When you have an XML file associated with an XML schema or DTD file, certain tags and rules for that file have already been established, which is why the Design view can provide prompts (via a pop-up menu) for those tags. When you create an XML file that is not associated with an XML schema or DTD file, it has no tags or rules associated with it, so the Design view cannot provide prompts for specific tags, but it can provide prompts to create new elements and attributes.

For any XML file associated with an XML schema or DTD file, you can use the Design view to add any items defined in the XML schema or DTD (such as elements and attributes) to the XML file. You can also use it to add processing instructions and comments to all XML files.

For more information on the icons used in the Design view, refer to the related reference.

The following instructions were written for the Resource perspective, but they will also work in many other perspectives.

To edit an XML file in the Design view, follow these steps:

1. Open the XML file that you want to work with in the XML editor (right-click the file in the Navigator view and click Open With > XML Editor). If necessary, click the Design tab.
2. To expand all the items in your XML file, click the Expand All toolbar button .
3. To collapse them, click the Collapse All toolbar button .
4. Right-click the item that you want to work with. Some or all of the following options (as applicable) will be available from the pop-up menu that appears. For more information on these options, refer to the related tasks:
   - Add DTD Information - Click this if you want to associate the XML file with a DTD
   - Edit DOCTYPE - Click this if you want to edit the DOCTYPE declaration.
   - Edit Namespaces - Click this if you want to edit the existing namespace information or create a new association with a namespace.
   - Edit Processing Instruction - Click this if you want to edit the processing instruction.
   - Remove - Click this if you want to remove the item that you have selected from the XML file. This option will not be available if the item you want to remove must exist (for example, in your DTD, you have declared that "One or more" of the item must always exist in your XML file, and the item you have selected is the only one that exists in your XML file).
   - Add Attribute - Click this if you want to add an attribute to the element that you selected. Any attributes you are allowed to add to the element will be listed. After you have added the attribute to the XML file, you can click in the right-hand column to change the value of the attribute. If the attribute has set values, they will appear in a list.
   - Add Child - Click this to add another element, a comment, or a processing instruction as a child of the parent element.
   - Add Before - Click this to add a child element, comment, or processing instruction that can go before the item you have selected. For example, if you have a parent element called "CD Collections" that can contain an unlimited amount of children called "CD", you could click a CD element and click Add Before > CD , as a CD element can go before another CD element.
   - Add After - Click this to add a child element, comment, or processing instruction that can go after the item you have selected. For example, if you have a parent element called "CD Collections" that can contain an unlimited amount of children called "CD", you could click a CD element and click Add After > CD, as a CD element can go after another CD element.
   - Replace With - Click this if you want to replace one item with another. This option is not available if you turn grammar constraints off or if there are no valid alternatives for you to replace the item with.
5. Click the appropriate option.

Any changes you make in the Design view are also reflected in the Source view and the Outline view.

> Editing your DOCTYPE declaration
> The DOCTYPE declaration in an XML file is used at the beginning of it to associate it with a DTD file. You can edit your DOCTYPE declaration to change the DTD file your XML file is associated with.
> Editing your namespace information
> Your namespace information is used to provide various information about the XML file, such as the XML schema it is associated with.
> Editing your XML processing instructions
> A processing instruction is a syntax in XML for passing instructions along to the application using an XML document.

Related concepts
XML editor
XML file associations with DTDs and XML schemas

Related tasks
Editing in the Source view

(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.