cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ard Schrijvers" <>
Subject RE: multiple xpaths
Date Mon, 03 Oct 2005 15:02:31 GMT

I did write the uses SAX parsing, so finding XPath expressions
will not be possible...

There are two different HighlightingTransformers

1) Just highlights a single keyword in html/xml 
2) Highlight keywords in a html/xml page, with a keyword file as lookup which to highlight.

For example, the following piece of sitemap:

<map:transform type="highlightkeywordstransformer" src="keywords.xml"/> 

and with keywords.xml like

	<keyword value="open source" href=""/>
	<keyword value="cocoon" href=""/>

will place <a href="...."> </a> around every occurence of a keyword in the text.
By default, the text is scanned within the "body" element. But, it is possible two parameterize
it completely, for example

<map:transform type="highlightkeywordstransformer" src="keywords.xml">
	<map:parameter name="wrapElement" value="b"/>
	<map:parameter name="containerElementId" value="maincontent"/>
	<map:parameter name="containerElement" value="div"/>
	<map:parameter name="wrapAttributeStyle" value="color:green;"/>
	<map:parameter name="wrapAttributeClass" value="someClass"/>

This will wrap every keyword occurence within containerElement(s) "div" and containerElementId
"maincontent" with 
<b class="someClass" style="color:green">keyword</b>

So, if the Xpaths have some element with id, you could use this highlighttransformer, because
you can say "this" element with "thisId". The searching in keywords is done for files containing
over 200.000 keywords to be looked up.  For ~1000 keyword, it takes 30 ms, for 10.000 about
95 ms and for 200.000 about 1,5 s. So, performance is fast, except for extreme large keyword
files. I can upload it somewhere if anybody interested


> -----Original Message-----
> From: Sandor Spruit []
> Posted At: maandag 3 oktober 2005 14:31
> Posted To: Cocoon User List
> Conversation: multiple xpaths
> Subject: Re: multiple xpaths
> Geert Josten wrote:
> > > Was does work is the use of the extension in calls to
> > > xsl:apply-templates, but that is not what I want. It will help iff
> > > you want to apply a template to one specific XPath. What I need is
> > > to copy the entire XML tree using a regular xsl:copy, with some
> > > extra highlighting tags inserted for the XPath.
> >
> >  You might want to take a look at the 
> HighlightingTransformer that has
> >  been donated only a week or two ago. Look for messages 
> with that name
> >  in the cocoon-dev mailinglist.
> Duh. Somebody beat me to it! :(
> >  Though, I think it marks keywords, not element matching a specific
> >  xpath...
> That might be a useful extension though ... :)
> >  By the way, I think you approach of generating a XSL to achieve the
> >  highlighting is not bad at all, quite powerful even. I have been
> >  using the approach on many fields allready. Mostly for template
> >  mechanisms (when jxgenerator wasn't yet around).
> Thanks - I needed that. Deadline approaching ;)
> >  In your case performance might be an issue though. When the Xpaths
> >  vary a lot, a new XSL has to be generated, compiled and cached each
> >  time. :-(
> Well, performance has been pretty good so far. In fact, 
> excellent. Maybe
> it won't be so bad....
> Sandor
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message