Applying the XML Tags
Having attached a schema to your open sample document, you're ready to apply the XML tags supplied by that schema. I'm assuming that the XML Structure pane is displayed, but if it isn't, display it. (Choose View, Task Pane and select XML Structure in the drop-down menu of the task pane, as shown in Figure 6.)
Figure 6 Selecting the XML Structure pane.
Follow these steps:
- Click anywhere in the text of the sample document. Then select the element
"listing {Herb Catalog}" from the "Choose an element" box at
the bottom of the XML Structure pane, as shown in Figure 7.
Figure 7 The element name appears.
- In the dialog box that appears, click Apply to Entire Document.
- Beginning inside the listing tag, select all text from Sage down through (including) the first diamond-shaped wingding.
- Click "herb" in the "Choose an element"
box at the bottom of the XML Structure pane. The XML tag herb is
applied to the selected text and the elements under the class subheading
herb appear in the task pane, as shown in Figure 8.
Figure 8 Class subheadings appear.
- If formatting indicators (paragraph marks, etc.) are not displayed in your sample text, display them by choosing Tools, Options, clicking the View tab, and then selecting the All check box under Formatting Marks.
- Carefully select each paragraph individually, tagging it with the
appropriate tag from the "Choose an element" box. Begin with
"Sage, Berggarten" and apply the plantname tag. Stop when you
get to the paragraph beginning with Cooking and include the wingding in
that tag. Be very precise in your tagging; don't include existing tags in
this process. Also, make sure that there are start and end tags for every item
in your document.
You'll see error icons as shown in Figure 9 until you finish tagging a section (or if you misapply a tag). For example, this schema only allows each tag to be used once within the "herb" class. If you try to use it twice, Word alerts you that this last action was invalid.
Figure 9 Tags showing the error icon.
- Highlight the second block of text from the first letter down to just inside
the closing tag. Apply the paragraph tags as before. When every bit of text has
been properly tagged, the error icons disappear.
The resulting tagged document will look like Figure 10.
Figure 10 Sample document with XML tags applied.
Using Macros To Apply Tags
To reduce boredom and the risk of repetitive stress on your mouse hand, try creating keyboard macros for tags that you have to apply repeatedly. It's easy, and you can do it while you're tagging the next item in your list:
- Highlight the text to be tagged.
- Choose Tools, Macro, Record New Macro. Add a macro name (such as the name of the tag) and then click the Keyboard button.
- Press the keyboard combo that you want to use to apply your tag—perhaps the Alt key and the first letter of the tag name.
- Click Assign and then close the dialog box. Notice that the Stop Recording toolbar is displayed.
- Apply the tag and then click the Stop Recording button (with the square icon) to stop recording.
Now you can highlight a passage and press the keyboard combo to apply the tag. You'll be surprised at how much faster this makes the process of tagging a document.