Reusing internal parameter entities in an attribute name or type

 

+
Search Tips   |   Advanced Search

 

DTDs use entities to provide a mechanism to associate a name with a piece of text. Whenever you need to replace that text within a document, you can just use the name instead. There are many ways you can design entities in a DTD for reuse purposes.

Reusing parameter entities in attributes can save you a lot of time because if you have several elements using the exact same attribute, you only have to input the information once (into an entity).

The following instructions were written for the Resource perspective, but they will also work in many other perspectives.

You can create a DTD that reuses internal parameter entities in attributes. To reuse internal parameter entities in attributes,...

  1. In the workbench, create a new DTD.

  2. Add a new entity to the DTD you just created.

  3. Select Parameter from the Entity type list, and type a value in the Entity Value field.

  4. Create an element and add an attribute to it.

  5. If you want to reuse the entity in an attribute name, in the Name field for the attribute, type the name of the entity (that is, %NewEntity;) then in the Type field, select the type for the attribute. Tip: If you want to use an entity to replace an entire attribute definition, select (none) from the Type list.

  6. If you want to reuse the entity as the type of an attribute, type the name of the attribute, and, in the Type field, click the name of the entity you created in step 2.

  7. Repeat steps 4 and 5 or 4 and 6 as applicable.

You now have two attributes with the same name or type.

The following is a sample of when you might reuse internal parameter entities in an attribute type.

You are making a list of office supplies, and all the supplies have Part and Stock attributes.

  1. Create a new DTD called OfficeSupplies.dtd .

  2. Add an entity called PartStock. Select Parameter from the Entity type list. In the Entity Value field, type Part ID #REQUIRED Stock CDATA #IMPLIED.

  3. Add three new elements to OfficeSupplies.dtd: pen, paper, and pencils. Make the value of each element (#PCDATA).

  4. Right-click pen and click Add Attribute. In the Name field for the attribute, type ID_Numbers. In the Type field, click %PartStock;.

  5. Repeat step 4 for paper and pencils.

You now have three elements with the same attribute.

 

Parent topic

Creating entities

 

Related tasks

Reusing the value of one entity in another entity
Reusing external parameter entities in an element's content model