Re: Alphabetical Index Problem

Subject: Re: Alphabetical Index Problem
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 03 Oct 2000 18:02:32 +0100
Lee,

Not sure if you're still working on this, but I haven't spotted a reply
from the last two weeks, so:

>I have a long list of data arranged alphabetically,
>and would like to reveal parts of it as a user
>types in a string, rather like an MSHelp index.

I'm assuming you're using client-side processing?

Given a filter string it's easy to only apply templates to those items in
the list that have a content beginning with that filter string:

<xsl:template match="list">
  <xsl:apply-templates select="item[starts-with(., $filter)]" />
</xsl:template>

<xsl:template match="item">
  <a href="{@href}"><xsl:value-of select="." /></a><br />
</xsl:template>

You could use a frameset, with a form containing a text box for the filter
string in the top and the resulting list underneath.  Whenever a change is
made to the filter string within the form (i.e. an onchange event), you
could reprocess the data with the stylesheet, using the content of the text
box as the value of the filter parameter.

At a generic level, you could pass the filter parameter into the stylesheet
using addParameter and display the entire content of the result as a new
page within the file.  However, it would probably be more efficient if you
have a script that loads the XML data and the stylesheet when the page is
first loaded, and have the script attached to the onchange attribute of the
text box change the parameter through manipulating the stylesheet DOM, then
display the content using transformNode.  This would prevent the stylesheet
and the data being parsed and processed every time the user typed a character.

Hope that gives you some ideas,

Jeni

Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread