Modern browsers and XML search results
Notice how the links in the previous exercise returned raw XML. This is because no stylesheet informa- tion was associated with the XML. This can be overcome by inserting an XML processing instruction into each XML file and indexing the files. Using the "fixed" EAD data from a previous exercise you can see this work accomplished though a CGI script called cgi-bin/ead.cgi:
Copy the xml-data/ead/fixed directory to Apache's htdocs directory.
Copy cgi-bin/ead.cgi to the htdocs directory.
Copy swish-indexes/ead.cfg to the htdocs directory.
Edit ead.cfg so IndexDir points to many (IndexDir fixed).
Edit ead.cfg so IndexFile outputs to ead.idx (IndexFile ead.idx).
Index the contents of fixed ( swish-e -c ead.cfg ).
Edit ead.cgi's first line so it points to Perl.
Open a command prompt and run ead.cgi from the command line. It should return a stream of
Finally, open a modern Web browser and point it to ead.cgi.
Transforming raw XML on the fly
You can not always rely on the end user having a modern browser. This is why it might be necessary to transform your raw XML into HTML before it is sent to the user-agent. This can be done by inserting a second CGI script into the hot link of the full document. This second script is really xsltproc.pl wrapped in a CGI interface. Open cgi-bin/xsltproc.cgi to see.
Xsltproc.cgi is incorporated into tei.cgi's search results loop:
process each hit
while (my $result = $results->NextResult)
get the results
my $detail = my $title = my $author = $hit_list .=
$result->Property ('swishdocpath'); $result->Property ('title'); $result->Property ('author'); "<li>$author / $title
(<a href='./$XSLTPROC?xslt=$STYLE&xml=$detail'>full record</a>)</li
In this loop:
a few properties are read from the index
the hitlist is hotlinked to the full record using the global variables $XSLTPROC and $STYLE