X hits on this document

430 views

0 shares

1 downloads

0 comments

116 / 142

Apache

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:

  • 1.

    Copy the xml-data/ead/fixed directory to Apache's htdocs directory.

  • 2.

    Copy cgi-bin/ead.cgi to the htdocs directory.

  • 3.

    Copy swish-indexes/ead.cfg to the htdocs directory.

  • 4.

    Edit ead.cfg so IndexDir points to many (IndexDir fixed).

  • 5.

    Edit ead.cfg so IndexFile outputs to ead.idx (IndexFile ead.idx).

  • 6.

    Index the contents of fixed ( swish-e -c ead.cfg ).

  • 7.

    Edit ead.cgi's first line so it points to Perl.

  • 8.

    Open a command prompt and run ead.cgi from the command line. It should return a stream of

XHTML.

9.

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

108

Document info
Document views430
Page views436
Page last viewedWed Dec 07 22:46:37 UTC 2016
Pages142
Paragraphs3126
Words34660

Comments