Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Mastering UML with Rational Rose 2002.pdf
Скачиваний:
137
Добавлен:
02.05.2014
Размер:
9.68 Mб
Скачать

Chapter 16: XML DTD Code Generation and Reverse Engineering

Figure 16.5: Class Specification window for a DTD notation

There are only two code−generation properties for a DTDNotation class. The System ID property sets the location of the entity. The Public ID property sets the alternate location.

Attribute Properties

There are several properties that can be set for an attribute in a DTD class. Figure 16.6 shows the different properties that can be set.

Figure 16.6: XML attribute properties

Table 16.4 lists the attribute properties, their purposes, and their default values.

Table 16.4: XML Attribute Properties

551

 

Chapter 16: XML DTD Code Generation and Reverse Engineering

 

 

 

Property

 

Purpose

Name

 

Sets the name of the attribute in the generated DTD.

Type

 

Sets the data type of the attribute. Valid values are CDATA (character data),

 

 

ENTITIES (), and ENTITY().

Default Value

 

Determines whether the attribute is required or not.

Initial Value

 

Sets the default for the attribute.

DocComment

 

Comments to be generated for the attribute in the DTD.

Role Properties

Role properties are those properties that apply to the associations between the elements, entities, and other classes. These properties control the multiplicity between the elements, as well as the order of the elements in a content model. Figure 16.7 shows the Role Specification window.

Figure 16.7: XML role properties

There are four properties that can be set. The Name field is used to set the name of the role. This will not affect the generated DTD.

The Constraints field is used to model the order in which the element appears in the content model. The example in Figure 16.7 is the relationship between a book and a section. The DTD reads as follows:

<!ELEMENT book (title,tableofcontents,introduction?,section+)>

In this example, the Constraints field on the relationship between book and section was set to "4" because section is the fourth item in the content model for a book.

The Occurrence field sets the multiplicity of the relationship. In this example, each book can have one or more sections. This is noted in the DTD by the plus sign (+) after the section in the content model for the book

552

Chapter 16: XML DTD Code Generation and Reverse Engineering

element. It is noted in the Rose model by setting the Occurrence field to One or Many (+). The possible values for the Occurrence field include:

One

Zero or one (?)

Zero or Many (*)

One or Many (+)

Finally, the DocComment field can be used to enter comments for the relationship. Unlike comments for an attribute, these comments will not be included in the generated DTD file.

Component Properties

In Rose, the DTD file itself is modeled as a component. The different elements contained in the DTD are mapped to the component in Rose. As with other model elements, code−generation properties are set through the specification window. Figure 16.8 shows the specification window for a DTD component.

Figure 16.8: XML Component Specification window

In this window, the Name field sets the name of the DTD file to be generated. The Assignment field controls

553