Java Reference
In-Depth Information
<!ELEMENT color EMPTY>
<!ATTLIST color
R CDATA #REQUIRED
G CDATA #REQUIRED
B CDATA #REQUIRED
>
We must now define the <position> and <endpoint> elements. These are both points defined by
an (x,y) coordinate pair so you would sensibly define them consistently. Empty elements with attributes
are the most economical way here and we can use a parameter entity for the attributes:
<!ENTITY % coordinates "x CDATA #REQUIRED y CDATA #REQUIRED">
<!ELEMENT position EMPTY>
<!ATTLIST position %coordinates;>
<!ELEMENT endpoint EMPTY>
<!ATTLIST endpoint %coordinates;>
A rectangle will be defined very similarly to a line since it is defined by its position, which corresponds
to the top left corner, plus the coordinates of the bottom right corner. It also has a color and a rotation
angle. Here's how this will look in the DTD:
<!ELEMENT rectangle (color, position, bottomright)>
<!ATTLIST rectangle
angle CDATA #REQUIRED
>
<!ELEMENT bottomright EMPTY>
<!ATTLIST bottomright %coordinates;>
We don't need to define the <color> and <position> elements since we have already defined these
earlier for the <line> element.
The <circle> element is no more difficult. Its position is the center, and it has a radius and a color. It
also has a rotation angle. We can define it like this:
<!ELEMENT circle (color, position)>
<!ATTLIST circle
radius CDATA #REQUIRED
angle CDATA #REQUIRED
>
The <curve> element is a little more complicated because it is defined by an arbitrary number of
points, but it is still quite easy:
<!ELEMENT curve (color, position, point+)>
<!ATTLIST curve angle CDATA #REQUIRED>
<!ELEMENT point EMPTY>
<!ATTLIST point %coordinates;>
The start point of the curve is defined by the <position> element and it includes at least one
<point> element, which is specified by the + operator.
Search WWH ::




Custom Search