This chapter discusses elements, attributes and entities and how to work with them in XML Pro. Elements are the foundations of XML documents. Attributes and entities are designed to further describe an element. XML Pro has features designed to make creating, deleting and managing of elements simple. Two of them are the Element Wizard and the Element Palette.
Figure 2-1 Element Wizard
Use the Element Wizard to create and remove element types for inclusion into the current document. When used in conjunction with a DTD, the Element Wizard only displays elements defined by the DTD, and does not allow elements to be removed.
If the DTD does allow creating new elements for the document, the Element Wizard can be used to create (and remove) new element types for it.
The Wizard contains three components:
Use the Element Wizard to create new Element types for your document. Follow these steps:
To delete an element type:
If you are working with a DTD, and have selected the Available Elements Constrained by DTD option, elements shown in the Element Palette will change, depending on where in the document you are trying to insert the new element.
Elements displayed in the Element Palette are sorted in alphabetical order. if you have elements that are defined in a DTD, and then you create new elements, element types defined within the DTD will be displayed first, sorted alphabetically. Following the DTD defined elements will be any custom elements, grouped together and also sorted alphabetically.
Besides the Element Wizard and the Element Palette, XML Pro has other ways to insert, delete, and or move elements. While you must use the Element Wizard to create and remove element types, you can add individual instances of each element directly to the document tree.
Elements can be inserted using the Element Palette, or by inserting them from directly within the document tree view (the window displaying the document on screen). To insert an element within the tree:
NOTE: The Add Element sub-menu is limited to displaying 15 elements. if your document contains more then 15, you will need to use the Element Palette to display all available element types.
Element types can only be removed by using the Element Wizard. Single occurrences of an element within a document can be deleted in one of two ways:
or
Elements shown in the document tree view can be repositioned in one of three ways:
Attributes let you further customize elements to provide more information about them.
The Attribute Wizard assigns attributes to elements, and also removes attributes from them.
Figure 2.2 Attribute Wizard
This Wizard contains three components:
Follow these steps to create a new attribute for an element type:
Follow these steps to delete an exiting attribute type from an element:
When you are working with a document that has an Document Type Definition (DTD) associated with it, attributes for elements defined within the DTD cannot be modified via the Attribute Wizard. This is because of the constraints placed on it by the DTD.
When you are editing a document in XML Pro, and you click on an element in the tree view that has an assigned attribute, the attribute appears in the Attribute Pane of the Editor.
Figure 2-3. Attribute Pane
From the Attribute Pane, you can enter, delete, or edit the values that have been assigned to element attributes in your document. You may also use the cut, copy, and paste editing features within the Attribute Pane when working with attribute values.
To assign a value to an attribute, follow these steps:
NOTE: There is no confirmation button in the Attribute Pane. Once you have entered a value, if you select another element, the value is committed to memory. if the attribute is specified in the DTD as enumeration, the fixed choices will be presented within a drop-down list box.
When you create attributes for an element, the attribute always appears in the Attribute Pane when that element is selected in the tree view.
However, you do not need to assign a value to all instances of that attribute in all elements. Only attributes that have values assigned are written to the final XML Code. This keeps your code from getting "empty attributes" which are not necessary to specify. To preview what attribute values are being written, use the View XML feature in the Tools Menu.
XML Pro displays element attributes in the Attribute Pane, when an element is selected. To view all attributes for all elements within the tree view, select the View Attributes in Tree option from the Options menu. When selected, this option displays an element's attributes adjacent to the element in the document tree view.
Entities provide another way to customize an element in an XML document. Because Entities are defined within a document's DTD, XML Pro does not have a way to create or remove actual entities. However, you can list the Entities that are available to a document, and insert defined Entities into a document.
![]() |
2.9.1 The Entity PaletteThe Entity Palette is a separate floating window that can be hidden or shown by selecting the Show Entity Palette option, found in the Options Menu. The window displays a list of the Entities that have been defined in the DTD, as shown on the left. The Entity Palette can then be used to see the available Entities, and to insert them into the document. |
There are two ways to add an entity to the current document:
Figure 2-4. Add Entity Sub-menu
There are two ways to remove an entity from the current document:
These methods do not affect the Entity's availability in the Entity Palette, because Entities are defined within the DTD.