Subject: RE: [xsl] Search highlighting using xslt 2.0 From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx> Date: Wed, 24 Mar 2004 14:44:36 -0000 |
> 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. Hi David, To expand on the problem a little bit, I would like to be able to take an xhtml page (any xhtml) and provide search highlighting for any given sentence. So a stylesheet given the parameter 'Hello World' should highlight every occurance of 'Hello World' in the output. The highlighting can be achieved using any allowed technique, but I would expect it would be by wrapping the words in <span class="highlight"> ... </span> with an associated css definition. An example: <body> <table> <tr> <td>The simplest Hello<td> </td>World program</td> </tr> </table> </body> (with a search string of 'Hello World') One way I can see to do this is to tokenize the text values, tokenize the search string, compare one in the other and then check positionally for the sentence. Possible, but too much work I think. Another possible approach is use value-of on a higher element to get the string value, check for an occurance of the string-to-match, then insert empty elements as delimiters: <td>The simplest <highlight/>Hello</td> <td>World<highlight/> program</td> These delimiters can then be turned into the required markup using techniques discussed on the list a while back. The difficulty here would be getting from the value-of on say the <tr> to inserting the delimiter in the correct place in the <td>. Just some ideas, hopefully there are some better ones! cheers andrew
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Search highlighting using, David Carlisle | Thread | Re: [xsl] Search highlighting using, Robert Koberg |
RE: [xsl] translate, Jarno.Elovirta | Date | RE: [xsl] Search highlighting using, Andrew Welch |
Month |