You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Kent Fitch <k....@adfa.edu.au> on 2000/11/14 07:46:01 UTC

Java extension function which generates nodes of highlighted text

Hi,

I'm using Xalan to format the results of a bibliographic
search.  Users typically provides names or name
fragments or keywords as search terms, we do the search,
produce XML nodes and format them with Xalan.

It would be nice to highlight the names/keywords matching
the search terms, and I successfully experimented calling
a simple java extension function which is passed a
NodeList and returns a NodeList to which further templates are
applied:


<xsl:apply-templates
    select="java:aleg.ui.StylesheetFunctions.hilite(.,
$searchTerms)"/>

where the returned Nodelist contains a node such as:

 <result>The <hilite>Grail</hilite> Poems: Camelot</result>

This all works fine for simple cases, but as I'm generalizing
the code to deal with an arbitrary number of search terms
to match, and attempting to match forward and rear trunctation
matches, I'm wondering:

a) is there a better way?
b) has someone already done this!

Regards,

Kent Fitch
Australian Literature Electronic Gateway