XML.com: XML From the Inside Out
oreilly.comSafari Bookshelf.Conferences.


XML in WordPerfect 9: A Developer's View

May 31, 2000


One of the most annoying problems with XML (and SGML before it) is the lack of editors/word processors supporting it. Sure, Emacs+PSGML fits the bill, but would you let people familiar with traditional office suites or word processors use it? The remaining options are a few pieces of Java software, Adobe's FrameMaker+SGML (at $1499 a pop), or the even pricier Adept from ArborText. In other words, unless you have a healthy budget or an inclination to fiddle with things technical and complex, XML and its cosmic potential are likely to pass right by. The lack of XML editors impedes one of XML's main goals: cross-platform, cross-application functionality.

Corel's WordPerfect 9, which offers full, open XML/SGML support, promises to bring the power of XML to the masses. Bundled with the WordPerfect Office 2000 suite, which also includes Quattro Pro (also with XML support), Paradox, and a bunch of other useful applications, the most alluring feature of WP9 is its bargain-basement $150 price tag. Not to mention the suite runs on PC and Linux. Looks hopeful!

In this article we examine the XML support in WordPerfect 9, both from the point of view of a developer who needs to set up the XML environment (i.e., the style sheet), and of a user -- an editor who uses both SGML and non-SGML word processors.

We should note that prior to writing this article, neither of us had had much prior experience using WordPerfect, our usual publishing environment being FrameMaker+SGML (and vi!).

A Developer's View

The bad news first. Two things are really annoying when trying to set up an XML environment for WordPerfect: the documentation is very thin, and WordPerfect keeps crashing.

Now for the good news. Style sheet development is somewhat crude but effective, especially when starting from one of the several templates that come with the software.

Although not as powerful as FrameMaker or Adept Editor, WordPerfect 9 is a great tool in which to quickly set up an editing environment robust enough to handle simple to moderately complex XML documents.


WordPerfect's documentation is appalling. Actually, the lack of documentation is appalling!

Many of the features in the software are barely mentioned in the manuals or in the online help. And out of the 1170 pages of the WordPerfect Office 2000 Bible, exactly six pages (including four screen shots) are dedicated to XML. I will admit that the last words of those six pages were worth the effort: "For more information see the Corel Reference Center." The Reference Center, it turns out, is a well-hidden item in the Set-up and Notes menu created at install. This menu provides access to a whole manual dedicated to WordPerfect and XML. The problem is that it gives you all the obvious information that you can figure out on your own--I had already found out how to assign a style to an element--but gives no details on any advanced features (or bugs). For example, what is the difference between the two types of end tag rules for an element?

The only effective support resources I have found are the Corel newsgroups, especially the Corel WordPerfect Suite - SGML one (although it's hosted on a Corel news server not mirrored by many ISPs, making access difficult).


WordPerfect keeps crashing.

Increasing the amount of RAM on my computer from 32 Mb (the minimum recommended) to 158 Mb did not help, unfortunately. Actually, WP9 works just fine (except for the crashes!) with only 32 Mb on a K2-400.

Three service packs can be obtained from the Corel web site (the last one, SP3, includes all fixes and weighs in at a hefty 79 Mb), but neither do these do much to improve the robustness of the software.

The upside is that the crashes are mostly just annoying and never show-stoppers; they never prevented me from ultimately doing what I wanted to do. Once you've learned (usually the hard way!) how to "save early and often," as well as how to use the handy "move the insertion point to the previous position" arrow to go back to your previous place in the document (click on it twice after a save), you shouldn't lose too much work.

One good thing is that the crashes tend to be consistent. If the software crashes during an operation, it will crash as many times as you repeat the attempt. Crashes can happen at any time, especially when inserting or deleting text. For some reason, WP9 seems to especially dislike inserting a title (in HTML-like DTDs) just before another title. The solution is nearly always to repeat the operation somewhere else in the document, and then cut and paste the text at the appropriate place. Or, better yet, to save and reload the document when the formatting goes wild!

Creating an XML Project

To edit XML documents you need to create an XML project, which consists of a DTD and a template.

Using a DTD makes sense in a word processor. After all, how could you apply a style to an element if you don't even know it exists? For flexibility, however, WordPerfect gives you the option of using tags that do not appear in the DTD (just type the name of the tag in the box at the top left of the screen), enabling you to adjust the DTD later.

After you compile the DTD and specify the template file, you can then edit the template using a tool called the XML Project Designer. A nice feature of this tool is that you can even call it up from within WordPerfect as you are editing a document. This is quite convenient, and makes interactive development rather smooth, at least when compared to the "open EDD, fix, check, save, import in document" cycle of FrameMaker.


The XML Project Designer lets you create rules for each element in the DTD, which trigger formatting actions when a start tag or end tag is found.

A rule can be applied to an element in context by specifying the hierarchy above the element and/or attribute values that trigger the rule. A rule can also be applied to only the first of a series of elements of the same type.

For each rule, you can define exactly which WordPerfect codes will be inserted with the start and end tag of the element. The WordPerfect codes include all formatting options, regular text, attribute values, and counters. While editing, you can view those codes using the ever-popular "Reveal Codes" option, which is very handy while writing the template.

WordPerfect supports a wide range of special elements -- equations, graphics, tables, two types of footnotes, headers, footers, and watermarks -- that can be associated with XML elements. The range of table models supported is good, including AAP, CALS and HTML tables, as well as WordPerfect's own model. There is no way to format other elements as tables, though.

Other options available in templates include defining WordPerfect macros that will be triggered when an element is inserted. Additionally, the Project Designer allows aliases to be created so that the user never sees the actual tag names. I have never liked that kind of feature, which inevitably leads to misunderstandings between users and developers, but it is there if you want it.

Overall, the Project Designer is quite easy to use. Except, of course, if you are not familiar with WordPerfect. It is then that some of the formatting options are difficult to find, such as having to go to Format->Style->Edit then Format->Paragraph->Format to change the indentation of a style.

WordPerfect definitely does not scale for complex DTDs. Rules are edited through a GUI and simply stored in alphabetical order, which makes it much harder to maintain than when they are stored in an editable file. Plus there is no flexibility in expressing the hierarchy of elements that triggers a rule: to apply the same formatting for a title whether in a <body_clause>, a <definition_clause>, an <accronym_clause>, or a <bibiography_clause>, you will have to duplicate the rule four times. Worse, there is no way to give a depth level for a rule to be triggered, or alternatives in the hierarchy. So if you want to specify a formatting for titles of level 3 regardless of the kind of clause they are in, you will have to write 64 rules!

One last piece of advice: as with FrameMaker+SGML, I found it beneficial to stay away from character and paragraph styles, preferring instead to insert the formatting codes in the template (the EDD in FrameMaker) so that all the formatting information was kept in one place.

WordPerfect XML Project Designer
Figure 1: The WordPerfect XML Project Designer

Putting WordPerfect to Work

Our tests included porting a subset of a fairly complex DTD and style sheet (the IEEE Standards DTD) to be used to create drafts of documents that will be later edited and output using FrameMaker+SGML, creating style sheets for HTML-based DTDs and, naturally, writing this article using the XMLNews DTD that comes with WordPerfect.

One of the easiest ways to create a new XML document type is to use the HTML DTD as a basis, as WordPerfect includes a template for HTML 3.2. Just copy the DTD and the template, add your own tags, create an XML project, recompile the DTD, add rules for the new tags... et voila! This is really easy, and a great way to use WP9 since most of the formatting is already done and the DTD is quite simple.

I was even able to use the XHTML 1.0 transitional DTD, plus the associated entity definition files, in which I replaced the PUBLIC identifiers by SYSTEM ones.

When it comes to using a more complex DTD, though, the results are less impressive. As noted above, it is very difficult to manage the number of rules needed to implement the formatting required. The lack of power in describing the context in which a rule is triggered made it impossible to generate the formatting we needed. So we had to settle for writing a style sheet for a subset of the original, sometimes only approximating the result we could get in FrameMaker+SGML. In hindsight this is probably the most sensible way to use WordPerfect: a rather cheap XML editor with limited display capabilities.

To summarize, the XML Project Designer is quite easy to use and a convenient tool with which to create (or update) templates for simple DTDs with a limited number of elements and a simple hierarchy. For more complex tasks it can be used a tool to create XML documents and print drafts.

One last note: WordPerfect comes with a handful of DTDs: CALS, Docbook, HTML 3.2, TEI Lite, and XML News. Of those only HTML and XML News have templates. I have not been able to even compile the Docbook 3 DTD! I really would have liked to see a style sheet for that huge DTD!

Pages: 1, 2

Next Pagearrow