The last XML feature we look at in Layout view is the use of Document Type Definitions, known as DTDs, to validate XML structure. This topic is covered in detail in Chapter 11, but here’s the dime tour.
Loading a DTD
If a DTD is not included as an inline element within the XML file itself, you must load it manually (Figure 2.58).
Figure 2.58 The DTD can be loaded from either the Structure pane menu or the Tags panel menu. The controls for DTD validation are located at the top of the Structure pane. Select masters.dtd in the Load DTD dialog. Click Open.
Validating Structure with a DTD
As we explain in Chapter 1, a DTD can be used to test an XML structure to make sure it follows the rules. By validating your structure against the DTD, InDesign identifies parts that don’t conform and gives you tips on how the problem may be fixed. Figure 2.59 shows how to validate an existing XML structure. Click the lightning bolt icon at the top of the Structure pane to validate the current document structure. Errors are indicated within the structure schematic and suggested fixes appear in their own section of the pane.
Viewing the DTD
The error messages in the Structure pane can be somewhat cryptic and often inaccurate. This is a case where knowing how to read DTD comes in handy, and InDesign provides a simple way to get a first-hand look at the DTD that you loaded (Figure 2.60). Select View DTD from the Structure pane menu.
Figure 2.60 From our coverage of DTD syntax and grammar in Chapter 1, you should be able to parse out the proper XML structure. If so, you’ll see that the real problem with our structure is that no text is tagged with the element placeofdeath.
Fixing XML Structure
Let’s put your newly acquired knowledge to the test. To fix the structure you must select the text Clos Lucé, France, tag it with the element placeofdeath, and then revalidate the layout (Figure 2.61).