It’s time to shift gears, roll up our sleeves, and start building docbases. Our first example will be a web docbase that works like the BYTE Virtual Press Room did. In this chapter, we’ll look at ways to capture and store docbase records. In Chapter 7, we’ll explore how to generate sets of pages that enable users to navigate a docbase. By the end of the two chapters, we’ll have created a system that you can use to manage monthly status reports, service bulletins, analyst reports, or any template-driven, semistructured documents.
What I’ll call the Docbase system includes a family of Perl modules. Docbase::Input, featured in this chapter, collects, validates, previews, and stores docbase records. Docbase::Indexer and Docbase::Navigate, which we’ll encounter in Chapter 7, support indexing and navigation of docbase records. These modules are driven by other Perl scripts, some general and some tailored to each instance of the Docbase system. Also associated with each instance are templates that govern the form used to collect its records and define the repository format used to store the records. Finally, each instance uses a standardized directory structure.
Is the Docbase system something you can apply directly with little modification, or is it just a way of illustrating techniques that you’ll need to adapt heavily to your purposes? Both. With minor adaptations, mostly involving templates, you can use it to create a variety of docbases that gather, organize, and present sets of semistructured records. In this sense, the Docbase system is reusable.
On another level, what’s reusable are the ideas and techniques it embodies. The pattern is: XML storage, mapped to Perl data structures, managed by Perl modules, delivered as HTML pages or SMTP/NNTP messages. We’ll see variations on this theme throughout this book, solving lots of different kinds of development problems. In this sense, the Docbase system is intended to serve as an extended example of a way of problem solving that I find almost infinitely fruitful.
The Docbase
system uses several kinds of templates, each with its own processor.
A form template, processed by a CGI script using the
formGen( )
method of
Docbase::Input, becomes the data-entry form used
to collect records. A record template, processed by the _previewDoc( )
and _writeDoc( )
methods of Docbase::Input, yields a record in an
HTML (or HTML/XML) repository format. We’ll focus on these
steps in this chapter, and in the next, we’ll see how
Docbase::Indexer and
Docbase::Navigate transform the stored records
into a navigable docbase that can be delivered two
ways—dynamically or statically.
An instance of the Docbase system—that is, a collection of service bulletins or analyst reports—uses a set of standard parts. Each instance also customizes some parts. See Appendix A, for details about acquiring and setting up the Docbase system. If you’re inclined to do that, now would be a good time.
Every Docbase instance relies on a set of standard Perl modules:
System-wide constants and methods
Input validation, storage
Build page sets for navigation
Support for sequential navigation
In addition to these modules, every instance uses these standard Perl scripts:
Generate docbase input forms
Receive and record validated input
Dynamic page display
Dynamic page display
For a docbase called ProductAnalysis, whose records store analyst reports, here are the pieces that live in the cgi-bin directory (e.g., /web/cgi-bin/Docbase/ProductAnalysis):
Template used by formgen.pl to generate input form
Template used by submit.pl to store validated record
Template used by Docbase::Navigate to present navigational controls in the dynamic version
Template used by Docbase::Indexer to present navigational controls in the static version
Script to validate and store a record
Subdirectory for sequence info used in navigation
18.116.239.195