Rose – Document Type Declaration (DTD) Mapping

Страницы работы

Содержание работы

1.  Rose – Document Type Declaration (DTD) Mapping

This document defines the mapping of Rose model elements to DTD types.  Each section has three subsections, as appropriate:

·  DTD semantics

·  Corresponding Rose mapping

·  Examples

A DTD names the root element of the document and declares elements, attributes, notation, and entities used in the document instance.  Interspersed with these declarations may be comments and processing instructions. The document type declaration must appear before the first element in a XML document.  The Name in the document type declaration must match the element type of the root element.

DTD Element

Each DTD element belonging to the logical structure of a document must be declared.  This declaration specifies the name of the element, as well as, between parentheses, its content model, which elements can or must be part of the element in question.

DTD semantics:

<!ELEMENT name (content model) >

content model = ‘EMPTY’ | ‘ANY’ | model

model = '(' tokengrp ')' | '(' tokengrp ')?' | '(' tokengrp ')*' | '(' tokengrp ')+'

tokengrp = seqtokens | ortokens

token = '#PCDATA' | NAME occurance | model

Rose mapping:

A DTD Element (<!ELEMENT ….>) maps to a Rose class with the pre-defined stereotype of <<DTDElement>>.  A DTDElement class can be assigned with a type of ANY, EMPTY, PCDATA or ContentModel.  A model maps to a Rose class with the stereotype of <<DTDGroup>>.  A Grouping Type of Choice or Sequence can be selected to represent the grouping operations of unordered choice or ordered sequence.  The multiplicity (?, * or +) is modeled as “Multiplicity”. In case of a ordered sequence of elements, the order of elements participate in the model is specified using the Rose association role constraint specifying the sequence number starting at one up to the number of elements.

Table 1.  Grouping operators and Rose mapping:

DTD grouping



Rose  Mapping







All must appear and in the order indicated (sequence)

One and only one can appear (choice)

Element must appear once

Element must appear once or more

Optional element ( 0 or one )

Element can appear once or more

<<DTDSequenceGroup>>, constrains = {1}, {2},… to indicate the order


Group Multiplicity = 1

Group Multiplicity = 1..*

Group Multiplicity = 0..1

Group Multiplicity = 0..*

Table 2. Occurance operators and Rose mapping:

DTD occurance



Rose  Mapping




Element must appear once or more

Optional element ( 0 or one )

Element can appear once or more

Association Multiplicity = 1..*

Association  Multiplicity = 0..1

Association  Multiplicity = 0..*

Table 3.  Fundamental types and Rose mapping:

DTD symbol


Rose class stereotype




Any element defined in the DTD

Empty content.  Can be qualified by possible attributes

Character data





<! ELEMENT DL  (DT*, DD?)+>

<!ELEMENT novel (preface,chapter+,biography?,criticalessay?)>

<!ELEMENT preface (paragraph+)>

<!ELEMENT chapter (title,paragraph+,section+)>

<!ELEMENT section (title,paragraph+)>

<!ELEMENT biography (title,paragraph+)>

<!ELEMENT criticalessay (title,section+)>

<!ELEMENT paragraph (#PCDATA|keyword)*>

<!ELEMENT title (#PCDATA|keyword)*>

<!ELEMENT keyword (#PCDATA)>

DTD Attribute

All possible attributes of all elements in a DTD must be explicitly declared in the same DTD.   An attribute declaration consists of:

·  The name of the element(s) that it refers to

·  The name of the attribute

·  The attribute type

·  A default value

DTD semantics:

            <!ATTLIST element_name

                        attributename_1 attype defaultdec

                        attributename_2 atttype defaultdec

                        … >

            atttype = stringtype | tokenizedtype | enumeratedtype

stringtype = ‘CDATA’

tokenizedtype = ‘ID’

                        | ‘IDREF’

                        | ‘IDREFS’

                        | ‘ENTITY’

Похожие материалы

Информация о работе