Using an entity in a content model can save you time if you want
to have the same information in several content models. You can create a DTD
that references another DTD and then declares an element whose content model
refers to a parameter entity created in another DTD.
The following instructions were written for the Resource perspective,
but they will also work in many other perspectives.
To create
a DTD that reuses an external parameter entity in an element's content model,
follow these steps:
- Create a new DTD. If you want to work with an existing
DTD, open your DTD in the DTD editor.
- Create an entity (for example, MyEntity).
- Select Parameter from the Entity
type list, and type a value for the entity in the Entity
value field.
- Save your DTD file.
- Create another DTD.
- Create another entity (for example, MySecondEntity).
- Select Parameter from the Entity
type list and select the External check
box to declare this as an external entity.
- In the System ID field, type the path of
the DTD (or click the More button to browse for a file)
you created in step 1 . The path is relative to the workspace root.
- (Optional) Type a value in the Public ID field.
- In the Outline view, right-click the DTD and click Add
Parameter Entity Reference to add a reference to the entity you
created in step 6 (for example, MySecondEntity).
- Add an element.
- Change the content type for this element from EMPTY to the
value you specified in step 2 (for example,MyEntity). Note how you can select the value you specified in step 2 in the list
for the content element. This is because you included the first DTD that you
created in an earlier step.
You now have a DTD that references another DTD and declares an
element whose content model refers to a parameter entity created in the other
DTD.
The following sample shows how you might reuse external parameter
entities in an element's content model.
You are making a list of everything
you have in both your work office and your home office. You have a computer
in each office and you do not want to write out a list of each part of your
computer more than once.
- Create a new DTD called WorkOffice.dtd..
- Create the following four elements: Monitor,Keyboard, Mouse,
and Hard_Drive. Make the value of each element (#PCDATA).
- Add an entity called WorkComp. Select Parameter as
the Entity type. In the Value field,
type: (Monitor, Keyboard, Mouse, Hard_Drive). Click
- Create another DTD called HomeOffice.dtd
- Add an entity called HomeComp to your HomeOffice.dtd
. Select Parameter as the Entity type and
click the External check box to declare this as an
external entity. In the System ID field, type the path
(or click the More button to browse for the file) of WorkOffice.dtd.
The path is relative to the workspace root.
- (Optional) Type a value in the Public ID field.
- In the Outline view, right-click the DTD and select Add Parameter
Entity Reference to add the entity you created earlier (that is,
%HomeComp;).
- Add an element called MyHomeComp. Change the content
model for MyHomeComp from EMPTY to Work Office:
%WorkComp;. The value of MyHomeComp is now: Monitor Keyboard Mouse
Hard_Drive. Note how you can select the value you specified in step
4 in the Content type list for the content element.
This is because you included the first DTD you created in an earlier step.