Attributes are created by declaring an attribute type in the Attribute Types pane or by entering attribute names for an element in the element list pane of the Element Types pane.
NOTE: When attributes are entered in the element list pane of the Element Types pane, if they are previously undeclared, the attribute is automatically created in the Attribute Types window with a data type of string.
Creation of an attribute type within the Attribute Types pane consists of several steps. As an example, let's say we have an element Picture, with the attributes GraphicsType and ImageFile. GraphicsType is an attribute that tells us if a picture is a JPG, TIF, or GIF file. ImageFile is the full path and filename of a file that contains a picture. The steps followed to declare attribute types for GraphicsType and ImageFile appear below:
1. Click on a blank line under the Attribute Name column. Enter the attribute name GraphicsType (as shown in Figure A). (NOTE: Names must begin with a letter and may contain numbers, underscores, dashes, and full stops -- typically periods.)
Figure A - Entering an attribute type name.
2. Select the cell under the next column heading, Element, in the row for GraphicsType. Since we know this attribute will be used by the element Picture, type in Picture. If the Picture element type is already defined, as the first few letters of "Picture" are typed in, the element type name in its entirety will appear in the cell (Figure B). If the element Picture is not yet defined, the row selector/error indicator will turn red until the element is defined.
Figure B - After typing in the "P" in picture, the element name appears.
NOTE: If an attribute is used by multiple elements, a list of elements cannot be entered here. The attribute must be specified in the Attributes column of the element list pane of the Element Types pane (in each row, for each element using that particular attribute). The attribute, when it is listed in the Attribute Types pane, will have the word "shared" under its Element column. To view a list of elements sharing an attribute, right click on the word "shared", and a list of elements will appear (Figure C).
Figure C - Multiple elements using the same attribute (GraphicsType).
When entering attributes for an XDR schema, the attribute can be designated as global by not associating it with a specific element (i.e. by leaving the element column blank.)3. An attribute type declaration, by default, sets the data type for an attribute to string. However, in this example, because GraphicsType is enumerated (that is, it will only ever have the values of JPG, TIF, or GIF), a data type of enumeration must be selected. To change the data type for GraphicsType, first select the cell (where string appears) under the Data Type column in the row for GraphicsType. A Qlicker with one button, Type, appears. Click on the Type button, then choose XML Types, then enumeration (Figure D).
Figure D - Selecting a data type of enumeration.
4. Since GraphicsType can be a JPG, TIF, or GIF, constraints need to be entered in the attribute type declaration. Click on the cell under the column heading Constraints for the row GraphicsType. Enter the constraints as they appear in Figure E. Notice that the JPG, TIF, and GIF entries are separated by the or ('|') indicator. When creating constraints within a DTD, keep in mind that they can be declared as reusable, and XML Authority provides another one-button Qlicker to help the user create/edit/use reusable constraints.
Figure E - Entering constraints.
5. A default value can be entered for an attribute. For example, to set the default value of GraphicsType to JPG, first select the cell under the column header Default for the row GraphicsType, then type in JPG for the default value (Figure F).
Figure F - Entering a default value.
6. Attributes can be required or optional. In this case, GraphicsType will be a required attribute, so a check must be placed under the column header Required for the row GraphicsType (Figure G).
Figure G - The Required checkbox.
7. What would an attribute type declaration for the attribute ImageFile look like? Follow steps one and two above to create an attribute of type ImageFile belonging to element Picture. The difference between GraphicsType and ImageFile comes in step three -- ImageFile, since it is a path and filename, will be of data type string. It will have no constraints or default value, but will be required. The attribute type declaration for ImageFile will look like the one shown in Figure H.
Figure H - Attribute type declaration for ImageFile.
8. When finished entering attribute type declarations, check the row selector/error indicator for the attribute type in each row. If there is a problem with an attribute type's declaration, the error indicator will turn red. Hovering the mouse cursor over the red indicator will display an explanation of the error.
Copyright 2000 Extensibility, Inc.
Suite 250, 200 Franklin Street, Chapel Hill, North Carolina 27516