Re: [xsl] Search highlighting using xslt 2.0

Subject: Re: [xsl] Search highlighting using xslt 2.0
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 24 Mar 2004 14:10:26 GMT
> This seems quite a task

yes but feasible in this case because you are matching well formed
fragments.
It gets much harder if you want need to break open arbitrarily nested
elements to mark your matched terms.
For example given your input


<p>This car has <b>170</b>bhp.</p>


you indicated you wanted "170bhp" to succeed and match the entire
original matched text in a highight element.

do you want a search of 70bhp to also succeed? If so, not only do you
have a harder job finding it you have a harder job highlighting as you
have to split the existing <b> element in two:

<p>This car has <b>1</b><highlight><b>70</b>bhp</highlight>.</p>

In general, you may have to unwind an arbitrary stack of nested elements
which can get entertaining in the case of tables for example:
is
<tr><td>170</td><td>bhp</td?</tr>
also supposed to match, here you can't put a single <highlight> around
the string as it would wreck the column structure, you have to mark up
each bit separately.

Depending on the answers, possibly completely different methods would be
needed, it's hard to "extend" a method just doing the simple case to
cover the later cases.

David

-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread