In this lesson, you'll work with an existing XML document (Overview.xml) and learn how to add special design features to manage XML documents.
In this lesson, you'll create
a table of contents
a cross-reference
You can use the formatting features of WordPerfect to create an index for your XML document. For more information, see Generating and updating indexes in the WordPerfect Help.
Creating a table of contents
Creating a table of contents for an XML document is very similar to creating a table of contents for a WordPerfect document. You must first define a table of contents by specifying the number of levels and the numbering format just as you would when creating a WordPerfect document. Then, you mark entries for the table of contents. These entries can include section, heading, subheading, and chapter entries.
For more information about creating a table of contents for WordPerfect documents, see Generating and updating tables of contents in the WordPerfect Help.
Creating a cross-reference
In this lesson, you will create a reference for the XRef element. The target for the XRef element is a specified Descrip element which contains a description of a particular chapter.
Creating cross-references in XML documents is very similar to creating cross-references in WordPerfect documents except that in XML documents you mark elements, not text, and you use attributes, not identifying names, to link a reference with a target.
For more information about creating cross-references for WordPerfect documents, see Generating and updating cross-references in the WordPerfect Help.
You'll need about 50 minutes to complete this lesson.
Creating a table of contents
To add a table of contents, you first define the table of contents, then you will use the WordPerfect XML Project Designer to add table of contents markings to elements. A generated table of contents is not saved with the XML document but can be used when the document is saved in a WordPerfect format.
To define a Table of Contents
1. In WordPerfect, open the Overview.xml document located in the \XML\Tutorial folder.
2. On the Property bar, click the XML button, then choose, Edit Layout.
3. In the Element Rule List box, choose the TOC element, then click the Edit menu, Edit Rule.
4. Click the Insert menu, Table of Contents, Define.
5. In the Number Of Levels box, type 2, then click the OK button.
6. In the Element Rule dialog box, click the OK button.
To define elements for inclusion in the Table of Contents
1. From the Element Rule List box, choose Descrip, then click the Edit menu, Copy Rule.
2. With the first Descrip element selected, click the Edit menu, Edit Rule.
3. Click the Hierarchy button, then click the Show All Elements option button.
4. Double-click the Chapter element in the Element Parents box, click the OK button to return to the Element Rule dialog box, then click the OK button again.
5. From the Element Rule List box, choose the second Descrip element, then click the Edit menu, Edit Rule.
6. Click the Hierarchy button, then click the Show All Elements option button.
7. Double-click the Section element in the Element Parents box, click OK to return to the Element Rule dialog box, then click OK again.
To mark elements for inclusion in the Table of Contents
1. From the Element Rule List box, choose the first Descrip element, then click the Edit menu, Edit Rule.
2. Click in the Rule Entry For Start Tag box, then click the Insert menu, Table Of Contents, Mark 1, Begin.
3. Click in the Rule Entry For End Tag (After Revert) box, then click the Insert menu, Table Of Contents, Mark 1, End.
4. Click the OK button.
5. From the Element Rule List box, choose the second Descrip element, then click the Edit menu, Edit Rule.
6. Click in the Rule Entry For Start Tag box, then click the Insert menu, Table Of Contents, Mark 2, Begin.
7. Click in the Rule Entry For End Tag (After Revert) box, then click the Insert menu, Table Of Contents, Mark 2, End.
8. Click the OK button.
9. Save the layout file, then exit the WordPerfect XML Project Designer.
To create a Table of Contents
1. Position the cursor before the Front end tag.
2. On the XML Property Bar, choose the Table of Contents element from the Valid Elements list box.
3. Click the Tools menu, Reference, Table Of Contents.
4. On the Table of Contents Property bar, click the Generate button.
5. In the Generate dialog box, click the OK button.
Note
To save the Table of Contents information, select the Table of Contents and insert WP DATA codes around it using the WPDATA command from the Insert menu, then save the document in a .wpd format.
Marking references and targets for cross-references
Cross-references are linked through the attributes of the target element and the reference element. Therefore, only elements with attributes can be cross-referenced.
To mark a reference
1. In WordPerfect, open the Overview.xml document located in the \XML\Tutorial folder.
2. On the Property bar, click the XML button, then choose, Edit Layout.
3. Click the Tools menu, Create Generic Rules.
The XML document will be easier to read with a generic layout applied.
4. On the Property bar, click the Elements button, then choose XRef.
5. Click in the Rule Entry For Start Tag box, then click the Insert menu, Cross Reference.
6. From the Attribute Target box, choose idref.
7. Click the Mark Reference button, then click Close.
8 Click OK to return to the WordPerfect XML Project Designer.
To mark a target
1. From the Element Rule List box, choose Descrip.
2. Click Edit, Edit Rule.
3. Click Insert, Cross Reference.
4. Click in the Rule Entry For Start Tag box, then click the Insert menu, Cross Reference.
5. From the Attribute Target box, choose id.
6. Click the Mark Target button, then click Close.
7. Click OK to return to the WordPerfect XML Project Designer.
8. Click the File menu, Exit and then click Yes to save the changes.
Marking and generating cross-references
To mark cross-references, you type an attribute value for the reference and a matching attribute value for the target. Cross-references are created between matching attribute values.
To mark a cross-reference
1. In WordPerfect, position the cursor after the Descrip start tag located in front of "What Makes Up An XML Document."
2. On the Property bar, click the XML button, then choose Edit Attributes.
3. Click the Edit Value button, type "a1" in the Value box, then click OK.
4. Click the Close button.
5. Click the Edit menu, Find And Replace, then type "Table Tagging" and click Find Next.
6. Position the cursor after the end tag for table, then type "For information about the contents of an XML document see".
7. On the Property bar, from the Valid Elements list box, choose XRef.
8. Click the Edit Value button, then type "a1", then click OK.
9. Click the Close button.
To generate cross-references
1. Click Tools, Reference, Generate.
2. In the Generate dialog box, click OK.
3. Click the File menu, Save to save the updated Overview.xml.
Notes
To set up a cross-reference, you must have a cross-reference element (such as XRef) defined in your DTD.
Until you use the Generate command, a question mark appears where you have marked references. When you generate, the reference number is inserted or updated.