Services Products Purchase Free Trial Partner Support About LoopIP Contact Us Home

Tutorial 3 > Next tutorial

NRS Tutorial: Customizing the HTML of an NRS template

NRS uses XSLT technology to generate an HTML page out of an XML stream and an XSL file. In order to customize the HTML it is necessary to provide new XSL files for NRS templates. NRS provides several ways to do this:

  • 1. default XSL file: You can modify the default XSL files used by the different template types. The changes will then apply to all templates that use the defaults.
  • 2. partial XSL file: You can provide a partial XSL file for a template. It is partial in that it only contains the functions you wish to override, as opposed to a complete XSL file. This is useful if you only want to change certain aspects of the HTML rendering and want to leave the rest alone.
  • 3. complete XSL file: You can provide a complete XSL file for a template. The template will then use this XSL file instead of the default XSL file.

1. default XSL file

In the NRS administration interface navigate to 'Templates|Default template settings'. Here you can upload new XSL files for each template type. Before you can upload a new XSL file you need to get the original. To do this you can select under 'Templates' a template of the type you wish to change, and append '.xsl' to the URL. Save the resulting document to a filename. For example, retrieve a href="/files/directory.xsl">directory.xsl and save it to a local file called directory.xsl. This would be the default directory template and can be modified and then uploaded.

2. partial XSL file

Once you have created a template of a particular type, if you edit the properties of the template, there is a form that says 'Load new template from file'. This is where you upload a new XSL file. To retrieve the current XSL file of the template, click on the link found below the form, and save it to a local file. Your local XSL file has the complete XSL file for the template. You now want to open the XSL file in a text editor and remove all lines except for the xsl:template functions you are interested in modifying. For example, to change the logo of the page you will only want to keep the <xsl:template name="drawlogo">. Make your modifications to the function, save the file, and then upload it using the form.

3. complete XSL file

Once you have created a template of a particular type, if you edit the properties of the template, there is a form that says 'Load new template from file'. This is where you upload a new XSL file. To retrieve the current XSL file of the template, click on the link found below the form, and save it to a local file. You now want to open the XSL file in a text editor and make any necessary changes, save the file, and then upload it using the form.

Group Set

To facilitate applying a new XSL file to multiple templates at the same time you can use the "Group set" command found under "Templates|Default template settings|Group set", and also found on application templates.

XSL Function Overview

Each template type has its own XSL file, and many of the xsl:template functions within are the same across template types. This makes it easier to create a partial XSL file containing replacement xsl:template functions that will work across template types.

Some examples of these shared xsl:template functions are:

  • drawhtml: Draws the html tag and contents of it.
  • drawlogo: Draws the logo ontop of the page
  • drawbody: Draws the top, middle, and bottom of the page
  • drawmiddle: Draws left, middle, and right side of the page.
  • drawbottom: Draws the bottom of the page
  • hit: Draws a search result
  • drawmetasearchhits: Draws search results from one search engine

Help with XSL Syntax

When adding HTML to an XSL file, the HTML must be written in XHTML which means that all HTML tags must be closed, and certain HTML character encodings need to be rewritten using the &#XXX; syntax. For example you must use <br/> instead of <br>, you must write &#160; instead of &nbsp;.

Help with XML

In order to render the XML into HTML, you can mostly get away with adapting the existing XSL files. Sometimes you might need to have a better understanding of the XML structure to write XPath queries. You can always view the XML for the page you are trying to modify by appending ".xml" to the template in question. With Internet Explorer 5.0+ the XML is rendered in an easy to view manner that helps you understand the structure. Some information on the XML structure is available here.

Back to support



 
LoopIP search
Web search
Net Research Server
Net Research Server - demonstration website
visit Net Research Server - demonstration website
Demo Links
Web Search
Shopping Engine
Local Search
Directory
Metasearch
Enterprise
Wiki
Integration

Copyright © 2008 LoopIP LLC. All rights reserved | Terms | Privacy