crossley 2003/03/20 23:54:19
Added: src/blocks/lucene/conf lucene.xsamples
src/blocks/lucene/samples create-index.xsp search-index.xsp
sitemap.xmap statistic-index.xsp welcome-index.xsp
src/blocks/lucene/samples/images lucene_green_300.gif
src/blocks/lucene/samples/stylesheets search2html.xsl
Log:
Add the old sample to its block.
Revision Changes Path
1.1 cocoon-2.1/src/blocks/lucene/conf/lucene.xsamples
Index: lucene.xsamples
===================================================================
<?xml version="1.0"?>
<xsamples xpath="/samples" unless="[EMAIL PROTECTED]'lucene']">
<group name="lucene">
<sample name="Search with Lucene" href="lucene/welcome">
Examples showing use of Apache Lucene to search.
</sample>
</group>
</xsamples>
1.1 cocoon-2.1/src/blocks/lucene/samples/create-index.xsp
Index: create-index.xsp
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0">
<xsp:structure>
<xsp:include>org.apache.avalon.framework.context.ContextException</xsp:include>
<xsp:include>org.apache.avalon.framework.component.ComponentException</xsp:include>
<xsp:include>org.apache.cocoon.ProcessingException</xsp:include>
<xsp:include>java.net.URL</xsp:include>
<xsp:include>java.net.MalformedURLException</xsp:include>
<xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</xsp:include>
<xsp:include>org.apache.avalon.framework.context.ContextException</xsp:include>
<xsp:include>org.apache.cocoon.components.search.*</xsp:include>
<xsp:include>org.apache.lucene.store.Directory</xsp:include>
<xsp:include>org.apache.lucene.analysis.Analyzer</xsp:include>
</xsp:structure>
<xsp:logic>
File workDir = null;
/** Contextualize this class */
public void contextualize(Context context) throws ContextException {
super.contextualize( context );
workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
}
LuceneCocoonIndexer lcii;
Analyzer analyzer = LuceneCocoonHelper.getAnalyzer(
"org.apache.lucene.analysis.standard.StandardAnalyzer" );
void createIndex(String baseURL, boolean create) throws ProcessingException {
try {
lcii = (LuceneCocoonIndexer)this.manager.lookup( LuceneCocoonIndexer.ROLE );
Directory directory = LuceneCocoonHelper.getDirectory( new File( workDir,
"index" ), create );
lcii.setAnalyzer( analyzer );
URL base_url = new URL( baseURL );
lcii.index( directory, create, base_url );
} catch (MalformedURLException mue) {
throw new ProcessingException( "MalformedURLException in createIndex()!", mue
);
} catch (IOException ioe) {
// ignore ??
throw new ProcessingException( "IOException in createIndex()!", ioe );
} catch (ComponentException ce) {
// ignore ??
throw new ProcessingException( "ComponentException in createIndex()!", ce );
} finally {
if (lcii != null) {
this.manager.release( lcii );
}
lcii = null;
}
}
</xsp:logic>
<page>
<xsp:logic>
boolean create;
String createParam = <xsp-request:get-parameter name="create" />;
if (createParam == null) {
create = false;
} else {
create = true;
}
String baseURL = <xsp-request:get-parameter name="baseURL" />;
if (baseURL != null && baseURL.length() > 0) {
createIndex(baseURL, create );
}
if (baseURL == null || baseURL.length() < 1) {
baseURL =
"http://" +
<xsp-request:get-server-name/> +
":" + <xsp-request:get-server-port/> +
<xsp-request:get-context-path/> + "/" + "docs/index.html";
}
</xsp:logic>
<content>
<h1>Create a Lucene search index</h1>
<para>
This process might take some time (follow the tail of your logfiles
to see the indexer in progress).
<ul>
<li>LuceneCocoonIndexer.ROLE <xsp:expr>LuceneCocoonIndexer.ROLE</xsp:expr>
</li>
<li>context-path <xsp-request:get-context-path/>
</li>
<li>baseURL <xsp:expr>baseURL</xsp:expr>
</li>
<li>create <xsp:expr>String.valueOf(createParam)</xsp:expr>,
<xsp:expr>String.valueOf( create )</xsp:expr>
</li>
<li>get-uri <xsp-request:get-uri/>
</li>
<li>get-sitemap-uri <xsp-request:get-sitemap-uri/>
</li>
</ul>
<form action="create">
<table>
<tr>
<td>BaseURL</td>
<td>
<input type="text" name="baseURL" size="60">
<xsp:attribute
name="value"><xsp:expr>baseURL</xsp:expr></xsp:attribute>
</input>
</td>
</tr>
<tr>
<td colspan="2">
<input type="radio" name="create" value="true" checked="checked"/>
Create/Overwrite the Index, or
<input type="radio" name="create" value="false"/>
Update the existing Index
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="find" value="Create"/>
</td>
</tr>
</table>
</form>
</para>
</content>
</page>
</xsp:page>
1.1 cocoon-2.1/src/blocks/lucene/samples/search-index.xsp
Index: search-index.xsp
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0">
<xsp:structure>
<xsp:include>org.apache.avalon.framework.context.ContextException</xsp:include>
<xsp:include>org.apache.avalon.framework.component.ComponentException</xsp:include>
<xsp:include>org.apache.cocoon.ProcessingException</xsp:include>
<xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</xsp:include>
<xsp:include>org.apache.cocoon.components.search.*</xsp:include>
<xsp:include>org.apache.lucene.analysis.Analyzer</xsp:include>
<xsp:include>org.apache.lucene.store.*</xsp:include>
<xsp:include>org.apache.lucene.document.*</xsp:include>
<xsp:include>org.apache.lucene.search.Hits</xsp:include>
<xsp:include>java.util.*</xsp:include>
</xsp:structure>
<xsp:logic>
File workDir = null;
/** Contextualize this class */
public void contextualize(Context context) throws ContextException {
super.contextualize( context );
workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
}
LuceneCocoonSearcher lcs;
Directory directory;
Analyzer analyzer = LuceneCocoonHelper.getAnalyzer(
"org.apache.lucene.analysis.standard.StandardAnalyzer" );
Hits search( String query_string ) throws ProcessingException {
Hits hits = null;
try {
lcs = (LuceneCocoonSearcher)this.manager.lookup( LuceneCocoonSearcher.ROLE );
lcs.setAnalyzer( analyzer );
if (directory == null) {
directory = LuceneCocoonHelper.getDirectory( new File( workDir, "index" ),
false );
}
lcs.setDirectory( directory );
hits = lcs.search( query_string, LuceneXMLIndexer.BODY_FIELD );
start = 0;
end = Math.min(hits.length(), start + hitsPerPage);
} catch (IOException ioe) {
// ignore ??
throw new ProcessingException( "IOException in search", ioe );
} catch (ProcessingException pe) {
// ignore ??
Throwable t = pe.getCause();
if (t instanceof org.apache.lucene.queryParser.ParseException) {
// ignore it or write info about reason
} else {
throw new ProcessingException( "ProcessingException in search", pe );
}
} catch (ComponentException ce) {
// ignore ??
throw new ProcessingException( "ComponentException in search", ce );
} finally {
if (lcs != null) {
this.manager.release( lcs );
}
lcs = null;
}
return hits;
}
int hitsPerPage = 10;
int start = 0;
int end = 0;
Hits hits;
LuceneCocoonPager luceneCocoonPager;
</xsp:logic>
<page>
<xsp:logic>
String queryString = <xsp-request:get-parameter name="queryString"
default=""/>;
boolean findIt = "Find!".equals( <xsp-request:get-parameter name="find"/> );
Integer startIndex = null;
Integer pageLength = null;
try {
if (<xsp-request:get-parameter name="previous"/> != null) {
startIndex = new Integer( <xsp-request:get-parameter
name="startPreviousIndex" default="0"/> );
} else if (<xsp-request:get-parameter name="next"/> != null) {
startIndex = new Integer( <xsp-request:get-parameter
name="startNextIndex"/> );
} else {
startIndex = new Integer( 0 );
}
pageLength = new Integer( <xsp-request:get-parameter name="pageLength"
default="10"/> );
} catch (NumberFormatException nfe) {
// ignore it
}
</xsp:logic>
<title>Cocoon XML Search Interface</title>
<content>
<a href="http://jakarta.apache.org/lucene/"><img border="0" alt="Lucene Logo"
src="images/lucene_green_300.gif"/></a>
<para>
<font size="-1">
<a target="_blank" href="statistic">Index Statistics</a> |
<a href="welcome">Welcome</a>
</font>
</para>
<para>
<form action="search">
<input type="text" name="queryString" size="60">
<xsp:attribute
name="value"><xsp:expr>queryString</xsp:expr></xsp:attribute>
</input>
<input type="submit" name="find" value="Find!"/>
</form>
</para>
<para>
Help by example (see also the
<a href="http://www.lucene.com/cgi-bin/faq/faqmanager.cgi">Lucene FAQ</a>)
<table cellspacing="2" cellpadding="2">
<tr bgcolor="#dddedd" valign="top">
<td width="50%"><font size="-2" >
<ul>
<li>free AND "text search"
Search for documents which contain the word "free" and the
phrase "text search"
</li>
<li>+text search
Search for documents which must contain the word "text" and
optionally contain the word "search".
</li>
<li>giants -football
Search for "giants" but omit documents containing "football"
</li>
</ul>
</font></td>
<td><font size="-2">
<ul>
<li>body:john
Search for documents containing "john" in the body field.
The field "body" is used by default.
Thus query "body:john" is equivalent to query "john".
</li>
<li>[EMAIL PROTECTED]:cocoon
Search for documents containing "cocoon" in the
using field [EMAIL PROTECTED], ie searching in
title attribute of s1 element of xml document.
</li>
</ul>
</font></td>
</tr>
</table>
</para>
<para>
SearchResult:
<xsp:logic>
if (queryString != null && queryString.length() != 0) {
// do the search, search results are available in hits
hits = search( queryString );
luceneCocoonPager = new LuceneCocoonPager( hits );
if (startIndex != null && pageLength != null) {
luceneCocoonPager.setStartIndex( startIndex.intValue() );
luceneCocoonPager.setCountOfHitsPerPage( pageLength.intValue() );
}
<xsp:content>
Total Hits: <xsp:expr>hits.length()</xsp:expr>
</xsp:content>
}
</xsp:logic>
</para>
<para>
<table width="90%" cellpadding="4" border="1">
<tr>
<td>Score</td><td>Count</td><td>URL</td>
</tr>
<xsp:logic>
if (luceneCocoonPager!= null && luceneCocoonPager.hasNext()) {
int counter = luceneCocoonPager.getStartIndex();
List l = (List)luceneCocoonPager.next();
Iterator i = l.iterator();
for (; i.hasNext(); counter++) {
LuceneCocoonPager.HitWrapper hw =
(LuceneCocoonPager.HitWrapper)i.next();
Document doc = hw.getDocument();
float score = hw.getScore();
String url = doc.get( LuceneXMLIndexer.URL_FIELD );
<xsp:content>
<tr>
<td> <xsp:expr>String.valueOf((int)(score * 100.0f))</xsp:expr>%
</td>
<td> <xsp:expr>String.valueOf(counter + 1)</xsp:expr> </td>
<td>
<a target="_blank">
<xsp:attribute
name="href"><xsp:expr>url</xsp:expr></xsp:attribute>
<xsp:expr>url</xsp:expr>
</a>
</td>
</tr>
</xsp:content>
}
}
</xsp:logic>
</table>
</para>
<para>
<xsp:logic>
if (luceneCocoonPager!= null && luceneCocoonPager != null
&&
(luceneCocoonPager.hasNext() || luceneCocoonPager.hasPrevious())) {
<xsp:content>
<form action="search">
<input type="hidden" name="queryString">
<xsp:attribute
name="value"><xsp:expr>String.valueOf(queryString)</xsp:expr></xsp:attribute>
</input>
<input type="hidden" name="pageLength">
<xsp:attribute
name="value"><xsp:expr>String.valueOf(luceneCocoonPager.getCountOfHitsPerPage())</xsp:expr></xsp:attribute>
</input>
<xsp:logic>
if (luceneCocoonPager.hasPrevious()) {
<input type="hidden" name="startPreviousIndex">
<xsp:attribute
name="value"><xsp:expr>String.valueOf(luceneCocoonPager.previousIndex())</xsp:expr></xsp:attribute>
</input>
<input type="submit" name="previous" value="previous"/>
}
</xsp:logic>
 
<xsp:logic>
if (luceneCocoonPager.hasNext()) {
<input type="hidden" name="startNextIndex">
<xsp:attribute
name="value"><xsp:expr>String.valueOf(luceneCocoonPager.nextIndex())</xsp:expr></xsp:attribute>
</input>
<input type="submit" name="next" value="next"/>
}
</xsp:logic>
</form>
</xsp:content>
}
</xsp:logic>
</para>
</content>
</page>
</xsp:page>
1.1 cocoon-2.1/src/blocks/lucene/samples/sitemap.xmap
Index: sitemap.xmap
===================================================================
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<!-- =========================== Components ================================ -->
<map:components>
<map:generators default="file">
<map:generator name="search"
src="org.apache.cocoon.generation.SearchGenerator"
label="content"/>
</map:generators>
<map:transformers default="xslt">
<map:transformer name="log"
src="org.apache.cocoon.transformation.LogTransformer"/>
</map:transformers>
<map:readers default="resource"/>
<map:serializers default="html"/>
<map:matchers default="wildcard"/>
<map:selectors default="browser"/>
<map:actions>
<!-- FIXME: Has this action moved somewhere else?
<map:action name="lang-select" src="org.apache.cocoon.acting.LangSelect"/>
-->
<map:action name="locale" src="org.apache.cocoon.acting.LocaleAction"/>
<map:action name="request"
src="org.apache.cocoon.acting.RequestParamAction"/>
<map:action name="form-validator"
src="org.apache.cocoon.acting.FormValidatorAction"/>
<map:action name="resource-exists"
src="org.apache.cocoon.acting.ResourceExistsAction"/>
</map:actions>
</map:components>
<!-- =========================== Views =================================== -->
<map:views>
<map:view name="content" from-label="content">
<map:serialize type="xml"/>
</map:view>
<map:view name="links" from-position="last">
<map:serialize type="links"/>
</map:view>
</map:views>
<!-- =========================== Pipelines ================================= -->
<map:pipelines>
<map:pipeline>
<map:match pattern="images/*.gif">
<map:read src="images/{1}.gif" mime-type="image/gif">
<map:parameter name="expires" value="60000"/>
</map:read>
</map:match>
<map:match pattern="findIt">
<map:generate type="search"/>
<map:transform type="log"/>
<map:transform src="stylesheets/search2html.xsl"/>
<map:serialize/>
</map:match>
<map:match pattern="**">
<map:generate type="serverpages" src="{1}-index.xsp"/>
<!--
Run-time configuration is done through these
<map:parameter/> elements. Again, let's have a look at the
javadocs:
"[...] All <map:parameter> declarations will be made
available in the XSLT stylesheet as xsl:variables. [...]"
-->
<map:transform src="context://samples/stylesheets/dynamic-page2html.xsl">
<map:parameter name="view-source" value="{1}-index.xsp"/>
</map:transform>
<map:serialize/>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
1.1 cocoon-2.1/src/blocks/lucene/samples/statistic-index.xsp
Index: statistic-index.xsp
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp">
<xsp:structure>
<xsp:include>org.apache.avalon.framework.context.ContextException</xsp:include>
<xsp:include>org.apache.cocoon.components.search.*</xsp:include>
<xsp:include>org.apache.lucene.document.Document</xsp:include>
<xsp:include>org.apache.lucene.index.*</xsp:include>
<xsp:include>org.apache.lucene.document.*</xsp:include>
<xsp:include>org.apache.lucene.store.*</xsp:include>
<xsp:include>java.io.*</xsp:include>
<xsp:include>java.util.*</xsp:include>
<xsp:include>java.net.*</xsp:include>
</xsp:structure>
<xsp:logic>
File workDir = null;
/** Contextualize this class */
public void contextualize(Context context) throws ContextException {
super.contextualize( context );
workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
}
Directory directory;
void init() throws ProcessingException {
try {
directory = LuceneCocoonHelper.getDirectory( new File( workDir, "index" ),
false );
} catch (Exception e) {
throw new ProcessingException( "Exception in init()!", e );
}
}
int numDocs() throws ProcessingException {
try {
IndexReader reader = IndexReader.open( directory );
int num_docs;
num_docs = reader.numDocs();
return num_docs;
} catch (Exception e) {
throw new ProcessingException( "Exception in numDocs()!", e );
}
}
Map allDocuments() throws ProcessingException {
try {
IndexReader reader = IndexReader.open( directory );
HashMap fieldsStatistic = new HashMap();
for (int i = 0; i < reader.maxDoc(); i++ ) {
if (!reader.isDeleted(i)) {
Document document = reader.document(i);
Enumeration fields = document.fields();
while (fields.hasMoreElements()) {
Field f = (Field)fields.nextElement();
String name = f.name();
String value = f.stringValue();
if (value == null) value = "--void--";
String fieldStatistic = name + "/" + value;
if (fieldsStatistic.get( fieldStatistic ) == null) {
fieldsStatistic.put( fieldStatistic, new Integer(1) );
} else {
Integer sum = (Integer)fieldsStatistic.get( fieldStatistic );
int sum_plus = sum.intValue() + 1;
fieldsStatistic.put( fieldStatistic, new Integer( sum_plus ) );
}
}
}
}
return fieldsStatistic;
//map.keySet();
} catch (Exception e) {
throw new ProcessingException( "Exception allDocuments()!", e );
}
}
Map allTerms() throws ProcessingException {
try {
IndexReader reader = IndexReader.open( directory );
TermEnum te = reader.terms();
HashMap all_fields = new HashMap();
while (te.next()) {
Term term = te.term();
int docfreq = te.docFreq();
String field = term.field();
if (field != null) {
if (all_fields.containsKey( field )) {
Integer sum = (Integer)all_fields.get( field );
int sum_plus = sum.intValue() + docfreq;
all_fields.put( field, new Integer( sum_plus ) );
} else {
all_fields.put( field, new Integer( docfreq ) );
}
}
}
te.close();
return all_fields;
} catch (Exception e) {
throw new ProcessingException( "Exception allDocuments()!", e );
}
}
Map sort( Map map ) {
TreeMap treeMap = new TreeMap( map );
return treeMap;
}
</xsp:logic>
<page>
<xsp:logic>
init();
</xsp:logic>
<title>Index Statistics</title>
<content>
<para>
Statistics:
</para>
<para>
Total Count Of Documents
<xsp:expr>String.valueOf(numDocs())</xsp:expr>
</para>
<para>
<table>
<tr>
<td>Count Of Terms</td><td>Fieldname/Fieldvalue</td>
</tr>
<xsp:logic>
Map all_docs = sort(allDocuments());
Iterator it1 = all_docs.keySet().iterator();
while (it1.hasNext()) {
String k = (String)it1.next();
Integer v = (Integer)all_docs.get( k );
<xsp:content>
<tr>
<td> <xsp:expr>v.toString()</xsp:expr> </td>
<td> <xsp:expr>k</xsp:expr> </td>
</tr>
</xsp:content>
}
</xsp:logic>
</table>
</para>
<para>
All Terms
</para>
<para>
<table>
<tr>
<td>Count Of Terms</td><td>Term</td>
</tr>
<xsp:logic>
Map all_terms = sort(allTerms());
Iterator it2 = all_terms.keySet().iterator();
while (it2.hasNext()) {
String k = (String)it2.next();
Integer v = (Integer)all_terms.get( k );
<xsp:content>
<tr>
<td> <xsp:expr>v.toString()</xsp:expr> </td>
<td> <xsp:expr>k</xsp:expr> </td>
</tr>
</xsp:content>
}
</xsp:logic>
</table>
</para>
</content>
</page>
</xsp:page>
1.1 cocoon-2.1/src/blocks/lucene/samples/welcome-index.xsp
Index: welcome-index.xsp
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp">
<page>
<title>Welcome to Cocoon XML Search using Lucene</title>
<content>
<a href="http://jakarta.apache.org/lucene/"><img border="0" alt="Lucene Logo"
src="images/lucene_green_300.gif"/></a>
<h1>XML Search</h1>
<p>
Welcome to Cocoon XML Search. This page introduces Cocoon searching
and offers the following samples:
</p>
<ul>
<li>Creating a Lucene index to enable searching
</li>
<li>Searching through a once created Lucene index using various means:
</li>
<li>Searching a Lucene index using <em>XSP</em>
</li>
<li>Searching a Lucene index using <em>SearchGenerator</em>
</li>
</ul>
<h2>Creating an Index</h2>
<p>
You must create a Lucene index first, before you can do the searching.
Create an index by specifying a base url from which to start
crawling (the indexer will follow the links to build its content).
The base url should be
<a href="../../docs/userdocs/concepts/views.html">cocoon-view</a>
aware of content-labels
<strong>links</strong>, and <strong>content</strong>.
For example you might use the base URL
<code>http://localhost:8888/docs/index.html</code>
</p>
<p>
This following page allows you to <a href="create">create</a> an
index.
</p>
<h2>Searching</h2>
<p>
Enter a query and search the Lucene index that you have created
- using <a href="search?queryString=lucene">XSP</a>.
</p>
<p>
Enter a query and search the Lucene index that you have created
- using <a href="findIt?queryString=lucene">Cocoon Generators</a>.
</p>
<h2>Internals</h2>
<p>
Cocoon XML search uses the
<a href="http://jakarta.apache.org/lucene/">Jakarta Lucene</a>
indexing and search engine.
The Cocoon documentation
<a href="../../docs/userdocs/concepts/xmlsearching.html">explains</a> how it
is implemented within Cocoon. Look behind the scenes of this
example to find out more.
</p>
<!--center>
<form name="search" action="search" method="get">
<table>
<tr><td></td>
<td>
<input name="queryString" size="44"/> <input type="submit"
value="Search"/>
</td>
</tr>
<tr>
<td>Index</td>
<td>
<select name="index">
<option value="index">index</option>
<option value="index-1">index-1</option>
<option value="index-2">index-2</option>
<option value="index-3">index-3</option>
</select>
</td>
</tr>
<tr>
<td>Analyzer Class</td>
<td>
<select name="analyzerClassName">
<option
value="org.apache.lucene.analysis.StopAnalyzer">StopAnalyzer</option>
<option
value="org.apache.lucene.analysis.standard.StandardAnalyzer">StandardAnalyzer</option>
<option
value="org.apache.lucene.analysis.de.GermanAnalyzer">GermanAnalyzer</option>
<option
value="org.apache.lucene.analysis.SimpleAnalyzer">SimpleAnalyzer</option>
</select>
</td>
</tr>
</table>
</form>
</center-->
</content>
</page>
</xsp:page>
1.1 cocoon-2.1/src/blocks/lucene/samples/images/lucene_green_300.gif
<<Binary file>>
1.1 cocoon-2.1/src/blocks/lucene/samples/stylesheets/search2html.xsl
Index: search2html.xsl
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:search="http://apache.org/cocoon/search/1.0"
>
<xsl:template match="search:results">
<html>
<head>
<title>Index Search</title>
</head>
<body bgcolor="white" alink="red" link="blue" vlink="blue">
<a href="http://jakarta.apache.org/lucene/">
<img border="0" alt="Lucene Logo" src="images/lucene_green_300.gif"/>
</a>
<h1>IndexSearch</h1>
<p>
<small>
<a href="welcome">Welcome</a> |
<a href="statistic">Index Statistic</a>
</small>
</p>
<form action="findIt">
<input type="text" name="queryString" size="60" value="[EMAIL
PROTECTED]:query-string}"/>
 
<input type="submit" name="Search" value="Search"/>
</form>
Search Help
<table cellspacing="2" cellpadding="2">
<tr bgcolor="#dddedd" valign="top">
<td width="50%"><font size="-2" >
<ul>
<li>free AND "text search"
Search for documents containing "free" and the
phrase "text search"
</li>
<li>+text search
Search for documents containing "text" and
preferentially containing "search".
</li>
<li>giants -football
Search for "giants" but omit documents containing "football"
</li>
</ul>
</font></td>
<td><font size="-2">
<ul>
<li>body:john
Search for documents containing "john" in the body field.
The field "body" is used by default.
Thus query "body:john" is equivalent to query "john".
</li>
<li>[EMAIL PROTECTED]:cocoon
Search for documents containing "cocoon" in the
using field [EMAIL PROTECTED], ie searching in
title attribute of s1 element of xml document.
</li>
</ul>
</font></td>
</tr>
</table>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="search:hits">
<p>
Total Hits <xsl:value-of select="@search:total-count"/>
Pages <xsl:value-of select="@search:count-of-pages"/>
</p>
<p>
Page:
<xsl:for-each
select="/search:results/search:navigation/search:navigation-page">
<xsl:call-template name="navigation-link">
<xsl:with-param name="query-string"
select="/search:results/@search:query-string"/>
<xsl:with-param name="page-length"
select="/search:results/@search:page-length"/>
<xsl:with-param name="start-index" select="@search:start-index"/>
<xsl:with-param name="link-text" select="position()"/>
</xsl:call-template>
</xsl:for-each>
</p>
<p>
<xsl:call-template name="navigation-paging-link">
<xsl:with-param name="query-string"
select="/search:results/@search:query-string"/>
<xsl:with-param name="page-length"
select="/search:results/@search:page-length"/>
<xsl:with-param name="has-previous"
select="/search:results/search:navigation/@search:has-previous"/>
<xsl:with-param name="has-next"
select="/search:results/search:navigation/@search:has-next"/>
<xsl:with-param name="previous-index"
select="/search:results/search:navigation/@search:previous-index"/>
<xsl:with-param name="next-index"
select="/search:results/search:navigation/@search:next-index"/>
</xsl:call-template>
</p>
<hr/>
<table border="1" width="90%" cellpadding="4">
<tr>
<td>Score</td><td>Rank</td><td>URI</td>
</tr>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="search:navigation">
<p>
<xsl:call-template name="navigation-paging-form">
<xsl:with-param name="query-string"><xsl:value-of
select="/search:results/@search:query-string"/></xsl:with-param>
<xsl:with-param name="page-length"><xsl:value-of
select="/search:results/@search:page-length"/></xsl:with-param>
<xsl:with-param name="has-previous"><xsl:value-of
select="@search:has-previous"/></xsl:with-param>
<xsl:with-param name="has-next"><xsl:value-of
select="@search:has-next"/></xsl:with-param>
<xsl:with-param name="previous-index"><xsl:value-of
select="@search:previous-index"/></xsl:with-param>
<xsl:with-param name="next-index"><xsl:value-of
select="@search:next-index"/></xsl:with-param>
</xsl:call-template>
</p>
</xsl:template>
<xsl:template match="search:hit">
<tr>
<td>
<xsl:value-of select="format-number( @search:score, '### %' )"/>
</td>
<td>
<xsl:value-of select="@search:rank"/>
</td>
<td>
<a target="_blank" href="[EMAIL PROTECTED]:uri}">
<xsl:value-of select="@search:uri"/>
</a>
</td>
</tr>
</xsl:template>
<xsl:template name="navigation-paging-form">
<xsl:param name="query-string"/>
<xsl:param name="page-length"/>
<xsl:param name="has-previous"/>
<xsl:param name="has-next"/>
<xsl:param name="previous-index"/>
<xsl:param name="next-index"/>
<xsl:if test="$has-previous = 'true'">
<form action="findIt">
<input type="hidden" name="startIndex" value="{$previous-index}"/>
<input type="hidden" name="queryString" value="{$query-string}"/>
<input type="hidden" name="pageLength" value="{$page-length}"/>
<input type="submit" name="previous" value="previous"/>
</form>
</xsl:if>
<xsl:if test="$has-next = 'true'">
<form action="findIt">
<input type="hidden" name="startIndex" value="{$next-index}"/>
<input type="hidden" name="queryString" value="{$query-string}"/>
<input type="hidden" name="pageLength" value="{$page-length}"/>
<input type="submit" name="next" value="next"/>
</form>
</xsl:if>
</xsl:template>
<xsl:template name="navigation-paging-link">
<xsl:param name="query-string"/>
<xsl:param name="page-length"/>
<xsl:param name="has-previous"/>
<xsl:param name="has-next"/>
<xsl:param name="previous-index"/>
<xsl:param name="next-index"/>
<xsl:if test="$has-previous = 'true'">
<xsl:call-template name="navigation-link">
<xsl:with-param name="query-string"><xsl:value-of
select="$query-string"/></xsl:with-param>
<xsl:with-param name="page-length"><xsl:value-of
select="$page-length"/></xsl:with-param>
<xsl:with-param name="start-index"><xsl:value-of
select="$previous-index"/></xsl:with-param>
<xsl:with-param name="link-text">Previous Page Of Hits</xsl:with-param>
</xsl:call-template>
</xsl:if>
 
<xsl:if test="$has-next = 'true'">
<a
href="findIt?startIndex={$next-index}&queryString={$query-string}&pageLength={$page-length}">
Next Page Of Hits
</a>
</xsl:if>
</xsl:template>
<xsl:template name="navigation-link">
<xsl:param name="query-string"/>
<xsl:param name="page-length"/>
<xsl:param name="start-index"/>
<xsl:param name="link-text"/>
<a
href="findIt?startIndex={$start-index}&queryString={$query-string}&pageLength={$page-length}">
<xsl:value-of select="$link-text"/>
</a>
 
</xsl:template>
<xsl:template match="@*|node()" priority="-2"><xsl:copy><xsl:apply-templates
select="@*|node()"/></xsl:copy></xsl:template>
<xsl:template match="text()" priority="-1"><xsl:value-of
select="."/></xsl:template>
</xsl:stylesheet>