Reusing external parameter entities in an element's content model

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:

  1. Create a new DTD. If you want to work with an existing DTD, open your DTD in the DTD editor.
  2. Create an entity (for example, MyEntity).
  3. Select Parameter from the Entity type list, and type a value for the entity in the Entity value field.
  4. Save your DTD file.
  5. Create another DTD.
  6. Create another entity (for example, MySecondEntity).
  7. Select Parameter from the Entity type list and select the External check box to declare this as an external entity.
  8. 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.
  9. (Optional) Type a value in the Public ID field.
  10. 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).
  11. Add an element.
  12. 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.

  1. Create a new DTD called WorkOffice.dtd..
  2. Create the following four elements: Monitor,Keyboard, Mouse, and Hard_Drive. Make the value of each element (#PCDATA).
  3. Add an entity called WorkComp. Select Parameter as the Entity type. In the Value field, type: (Monitor, Keyboard, Mouse, Hard_Drive). Click File > Save
  4. Create another DTD called HomeOffice.dtd
  5. 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.
  6. (Optional) Type a value in the Public ID field.
  7. In the Outline view, right-click the DTD and select Add Parameter Entity Reference to add the entity you created earlier (that is, %HomeComp;).
  8. 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.
Related tasks
Reusing the value of one entity in another entity
Reusing internal parameter entities in an attribute name or type

Feedback