We don’t ordinarily produce different document structures every time we have a different need. You can think of the Coverage API as allowing you to make two separate requests for two separate data sets, not two representations of the same data, even though they came out of the same log.
When do you provide additional requests and responses, and when do you opt to externally transform a single XML document from one format to another? There is probably no clear-cut line between the two practices that will fit every case. But looking at the data critically and asking “is this a new data set or structure or is this a new representation of the same data?” will help you make the decision.
A third, valid data structure might have separated out the “ON EVENT” lines of code. The Coverage text log doesn’t give you complete information for these lines; you can’t tell what bar or key label was actually invoked. Since these lines can’t be tied to a line of code, they can’t be statistically tallied in the same way. (The standard Coverage interface includes these lines of code as “never marked” or “unmarkable” to make them statisitically netural.) In both the standard and extended StackXML data structures, these lines have “N-A” as the attribute value for their “RunsFor” attribute. This is one way to signify their special status to any code running on this data. However, removing them from the main tree would have been equally valid, and perhaps easier for people doing calculations with this data. XML is flexible enough to handle “inconsistent” or “irregular” data sets – much as the appendices of a book don’t have to use the same format as the rest of the text.
Eventually, you have to arise on one structure that seems appropriate for your data design, and move on.
Consistency is the hobgoblin of small minds and small systems
You’ve decided how your data should be expressed in elements, in this case how the lines of code shown in the text log are arranged and summarized within these XML structures. Even though the structures are more elastic, and the choices more varied, than rows and columns and tables in a relational database, it’s a similar design task. You’ll probably enjoy it.
You can’t use the VFP Database Designer, or other design tools you’re used to, to work out your XML document structures. You need a different IDE.
I use XML SPY 3.0, a shareware tool from Icon Information Systems, for my XML and XSL design work. It’s the most flexible of the design surfaces I’ve tried, allowing full validation and intellisense but still providing a “text only” mode when I feel like doing some raw typing. It even incorporates an IE Browser view, so you can see the familiar Internet Explorer collapsible and context-colored version of your document. There’s unlimited undo, a project view, customizable toolbars, and all that good stuff -- but it doesn’t get in my way.
Check out http://www.xmlspy.com/default.html.
Now, what about the format of the tags and elements? The Coverage StackXML documents use a fairly straightforward set of tags and attributes (tag names are code elements, attributes give you statistics about each element). No particular standard has been followed here, just a desire for the default display (Internet Explorer’s rendering of the document) to be easy to follow.
Why not use something like the various XML formats Microsoft makes available for SQL Server, ADO, or Office – each of which, incidentally, can be generated by VFP 7 using the new CURSORTOXML() function ? Attractive as the thought of using the new function is, and flexible as its features are (see figure 7 below), it was impractical to use the actual CURSORTOXML()for the Coverage project for the same reasons that a set of rows and columns doesn’t fit stacklevel data very well: this function emits cursor-shaped, rather than nested-tree-shaped structures. Still, we could have made an attempt to provide a similar-looking structure, in element and attribute names, to make people feel that the StackXML “belonged” to one of the standard structures Microsoft promotes. No such attempt has been made. Why not?
Figure 7, VFP 7’s CURSORTOXML() function is great for regular, cursor-shaped data, and gives you lots of good choices with its arguments and flags.