Added more functionality to the Java class
Posted by mholmes on 17 Oct 2007 in Activity log
Added another function to the Java class, to enable the calling XQuery to embed XML detailing any phrases which will need to be highlighted in output. This is explained in the comments in the class file:
* This is how you would use this class: * * 1. Get the search string as input from a form, and collect it * in the XQuery using request.getParameter(). * * 2. Create a SearchParser instance, passing the search string to * the constructor. * * 3. When you need the XQuery clauses to tack onto your XQuery * code, call the SearchParser's getXQueryClauses() method. What * you get back can form part of a string passed to util:eval(). * * 4. When you need to embed phrases that your XSLT can find and * highlight, call the SearchParser's getPhrasesToHighlight() method. * This gives you back a <seg type="searchHitPhrase">...</seg> element * for each phrase which is included in the search. This is necessary * because, when we search using eXist's &= or |= operators, the hits * come back tagged with <exist:match> elements, but when we use the * XPath contains() function (which is necessary for doing phrase * searches), they don't come back highlighted. XSLT can use the <seg> * elements to perform some later highlighting on search results, * perhaps by adding <exist:match> elements which can be rendered in * the normal way later in the XSLT.