Customize the display of OpenSearch results

This section explains how to customize the display of OpenSearch search results. Customization is required to brand the default search results page with organizational metadata. Customization is also required to allow searching between different collections.

<description>. Trends in &lt;B&gt;Energy&lt;/B&gt; and Water Use of Clothes Washers and Dishwashers. , W. Morris, AHAM, USA . The Association of Home Appliance Manufacturers (AHAM) will present information on recent trends in &lt;B&gt;energy&lt;/B&gt;... not only the recent changes to the US Department of &lt;B&gt;Energy&lt;/B&gt; test procedures but also new.... AHAM will explain how the market place has changed in &lt;B&gt;energy&lt;/B&gt;/water efficient machines, and how the... disconnects in the consumerÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢s laundry experience. The Impact of Lower &lt;B&gt;Energy&lt;/B&gt; and Water Trends... and the continued emphasis have been on reduced &lt;B&gt;energy&lt;/B&gt; consumption. This affects the appliance industry, the detergent industry, and the end-use consumer. The new second wave compounds the &lt;B&gt;energy&lt;/B&gt;... manufacturers have struggled to meet &lt;B&gt;energy&lt;/B&gt; &amp;amp; water standards and legislation. This often results in lower...</description>

The process of converting the XML response into HTML is shown below. Third party developers (partners) wishing to customize the search result page are responsible for building the Custom Web Application displayed in the diagram.

Human Resources Required for Search Result Customization

Programming resources with knowledge of XML, XSL, and a Web computer language are required to create a customized search result page.

Customization Procedures

To build a customized search result page, the XSL style sheet that generates the HTML user interface must be modified. Also, a custom Web application must be built to query the OpenSearch server and apply the style sheet to the server's XML response. The custom Web application can take many forms. Examples include Java servlets, PHP pages, and Ruby on Rails components. Each type of Web application has benefits and drawbacks. Consult a programming resource for more information.

The customization procedure can be broken down into the following sub-procedures.

Building the Custom Web Application

Format the XML results from the OpenSearch server into HTML using a customized version of the search.xsl style sheet

To illustrate the implementation of these responsibilities, a sample Web application is provided. It can be downloaded here. The sample Web application is a Java servlet but its structure can inform the creation of Web applications in any language.

Custom Sample Web Application Components

WEB-INF\classes\org\archive\search\example\SearchResultGenerator.java

Java code of the servlet Web application

WEB-INF\search.xsl

The default XSL style sheet

WEB-INF\search_title.xsl

XSL style sheet that customizes the title and header of the search results page

Installing the Sample Web Application

The sample Web application (test-app.war) can run in any Java servlet container. The recommended servlet container is Tomcat 6.0. Tomcat 6.0 can be downloaded here. Install Tomcat 6.0 and copy the test-app.war file into the Tomcat webapps directory. Start Tomcat and navigate to the following URL: http://localhost:8080/test-app/SearchResultGenerator. The page that displays should look like the image below.

XSL Style Sheet Customizations

This section describes various customizations to the search.xsl style sheet.

Customizing the Headers and Title

The default title and headers are shown in the image below.

The default title is defined by the XML.

&lt;title><xsl:value-ofselect="title"/>&lt;/title>

The default headers are defined under the comment, "Page header: title and search form," in search.xsl. The XML snippet below displays the default headers.

<!-- Page header: title and search form -->

&lt;div class="pageTitle" >

Archival Search Sample XSLT

&lt;/div>

&lt;div>

This simple XSLT demonstrates the transformation of OpenSearch XML results into a fully-functional, human-friendly HTML search page. No JSP needed.

&lt;/div>

To change the headers, modify the lines, "Archival Search Sample XSLT" and "This simple XSLT demonstrates the transformation of OpenSearch XML results into a fully-functional, human-friendly HTML search page. No JSP needed.." To change the title modify the XML: <title>Search for <xsl:value-of select="title" /></title> An example customization is shown below.

Modified Title

&lt;title>My Institution&lt;/title>

Modified Headers

<!-- Page header: title and search form -->

&lt;div class="pageTitle" >

My Institution

&lt;/div>

&lt;div>

Search Page for My Institution

&lt;/div>

The resulting search page is shown below.

Adding Collection Choices to the Search Page

By default, the search functionality queries ALL collections, even collections that have been defined by other partners. Make the following customization to allow the user to limit the searchable collections to those defined by a specific partner. An example is provided to illustrate this procedure.

If a partner has two collections with the ids 100 and 200, it would be useful to define two check boxes to limit the search to these two collections.

This XML code above defines two check boxes that, when selected, will pass the values 100 and/or 200 to the custom Web application, which will format the search query by using these values as the i parameter.

NOTE: The collection ids and the collection names must be HARDCODED in the custom XML. At this time, there is no way to dynamically retrieve the collection ids and collection names of a specific partner. If the collection name is changed or a new collection is added through the Archive-It user interface, the XML displayed above must be modified to reflect the changes. Synchronization is a manual procedure.

Place the custom XML code directly below the following line in the search.xsl style sheet.