You use the Tags panel to manage XML tags, and to apply tags to frames and text. To apply a tag, select something—a frame or a range of text—and click a tag in the Tags panel (see Figure 14-14). If the object you’re tagging is not contained by an object associated with an XML element, InDesign will ask you which element you want to associate with the selection. When you apply a tag, InDesign creates an element in the XML structure. Alternatively, you can choose Tag Text or Tag Page Item from the Context menu to apply a tag to the selection (see Figure 14-15). You can also tag objects by simply dragging them into the Structure view (see Figure 14-16).
Figure 14.14 Tagging Frames and Text
Figure 14.15 Tagging a Frame Using the Context Menu
Figure 14.16 Tagging a Frame Using Drag and Drop
You’ve probably noticed the Add Tag and Retag options at the top of the Tags panel—what do they do? They answer a question: What should InDesign do when you have selected text that’s already tagged and then click a tag in the Tags panel? When the Add Tag option is on, clicking a tag assigns the tag to the selected text. When the Retag option is active, InDesign switches the tag from the current tag to the tag you clicked.
To remove a tag from an object, select the object, or the corresponding element in the Structure view and then click the Untag button in the Tags panel.
Tagging Preset Options
When you apply a tag to text, and have not yet applied a tag to the text frame containing the text, InDesign applies a default tag to the text frame and adds a corresponding XML element to the document structure. You can use the Tagging Preset Options dialog box to specify the tag you want to apply as the default (see Figure 14-17).
Figure 14.17 Tagging Preset Options
The Tagging Preset Options dialog box also gives you a way to automate the tagging of tables and table cells. Choose the tags you want to apply from the Tables and Cells pop-up menus, and InDesign will apply those tags when you tag a table, cell, or text frame (see Figure 14-18).
Figure 14.18 Tables and Tagging Preset Options
Mapping XML Tags to Paragraph Styles
You’ve got an XML structure and a set of XML tags, and a document full of text. The task of tagging each paragraph with a specific XML tag is daunting—or is it? Not if you’ve used paragraph styles and character styles to format your text. If you’ve used styles, you can “map” those styles to XML tags, and automate the whole process.
To map XML tags to paragraph and character styles, follow these steps (see Figure 14-19).
Figure 14.19 Mapping XML Tags to Styles
- Choose Map Tags to Styles from the Tags panel menu. The program displays the Map Tags to Styles dialog box.
- For each XML tag, you can select a corresponding paragraph style or character style. You don’t have to map each style to a tab, and you can map multiple styles to a single XML tag. To automatically map tags to styles of the same name, click the Map By Name button. This mapping is case sensitive—the style names “Body_Text” and “body_text” will be mapped to different XML tags. Note, also, that tag names cannot contain spaces or punctuation (avoid using those characters in your style names).
- When you’ve created as many tag-to-style correspondences as you want, click the OK button. InDesign applies the paragraph style to all paragraphs tagged with the corresponding XML tag.
Mapping Styles to XML Tags
You’ve formatted all of the text in your InDesign document using paragraph and character styles, and you’ve imported or created a set of XML tags. Since you’ve already told InDesign what all of the text objects are (by way of the paragraph and character styles), shouldn’t you be able to do so with the document’s XML structure? You can, by following the steps below (see Figure 14-20).
Figure 14.20 Mapping Styles to XML Tags
- Select the Map Styles to Tags option from the Tags panel menu. InDesign displays the Map Styles to Tags dialog box.
- Select an XML element for each style for which you want to establish a mapping. If some or all of your XML tag names are the same as the names of your styles, you can click the Map By Name button to automatically match tags and styles with the same names (this matching is case sensitive).
- When you’ve created as many style-to-tag correspondences as you want, click the OK button. InDesign creates an XML element for all text tagged with the styles you’ve specified.