Chapter 6. Docbase Input Techniques

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.

An Overview of the Docbase System

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.

Standard Parts Common to Every Instance of the Docbase System

Every Docbase instance relies on a set of standard Perl modules:

Docbase::Docbase

System-wide constants and methods

Docbase::Input

Input validation, storage

Docbase::Indexer

Build page sets for navigation

Docbase::Navigate

Support for sequential navigation

In addition to these modules, every instance uses these standard Perl scripts:

formgen.pl

Generate docbase input forms

final-submit.pl

Receive and record validated input

doc-nav.pl

Dynamic page display

doc-view.pl

Dynamic page display

Customized Parts Unique to Each Instance of the Docbase System

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):

form-template.htm

Template used by formgen.pl to generate input form

docbase-template.htm

Template used by submit.pl to store validated record

dynamic-navigation-template.htm

Template used by Docbase::Navigate to present navigational controls in the dynamic version

static-navigation-template.htm

Template used by Docbase::Indexer to present navigational controls in the static version

submit.pl

Script to validate and store a record

./seqinfo

Subdirectory for sequence info used in navigation

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.239.195