cocoon-users mailing list archives

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

I did write the HighlightingTransformer....it 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

<keywords> 
	<keyword value="open source" href="http://www.opensource.com"/>
	<keyword value="cocoon" href="http://cocoon.apache.org"/>
</keywords> 

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"/>
</map:transform>


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

Ard



> -----Original Message-----
> From: Sandor Spruit [mailto:sandor@cs.uu.nl]
> 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: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message