Keyword menu now working
Posted by mholmes on 26 May 2010 in Activity log
These were my steps for getting a keyword menu working:
- Wrote a Java class to create a custom collator, reproduced here in full:
package ca.uvic.hcmc.myndir; import java.text.ParseException; import java.text.RuleBasedCollator; public class MyndirCollation extends RuleBasedCollator { public MyndirCollation() throws ParseException { super(myndirRules); } //This is the order we need: //AÁBCDÐEÉFGHIÍJKLMNOÓPQRSTUÚVWXYÝZÞÆÖ private static String ucAAcute = new String("\u00C1"); private static String lcAAcute = new String("\u00E1"); private static String ucEth = new String("\u00D0"); private static String lcEth = new String("\u00F0"); private static String ucEAcute = new String("\u00C9"); private static String lcEAcute = new String("\u00E9"); private static String ucIAcute = new String("\u00CD"); private static String lcIAcute = new String("\u00ED"); private static String ucOAcute = new String("\u00D3"); private static String lcOAcute = new String("\u00F3"); private static String ucUAcute = new String("\u00DA"); private static String lcUAcute = new String("\u00FA"); private static String ucYAcute = new String("\u00DD"); private static String lcYAcute = new String("\u00FD"); private static String ucThorn = new String("\u00DE"); private static String lcThorn = new String("\u00FE"); private static String ucAsh = new String("\u00C6"); private static String lcAsh = new String("\u00E6"); private static String ucOUml = new String("\u00D6"); private static String lcOUml = new String("\u00F6"); //This is the order we need: //AÁBCDÐEÉFGHIÍJKLMNOÓPQRSTUÚVWXYÝZÞÆÖ private static String myndirRules = ("< a,A < " + lcAAcute + "," + ucAAcute + " " + "< b,B < c,C < d,D < " + lcEth + "," + ucEth + " " + "< e,E < " + lcEAcute + "," + ucEAcute + " " + "< f,F < g,G < h,H < i,I < " + lcIAcute + "," + ucIAcute + " " + "< j,J < k,K < l,L < m,M < n,N < o,O < " + lcOAcute + "," + ucOAcute + " " + "< p,P < q,Q < r,R < s,S < t,T < u,U < " + lcUAcute + "," + ucUAcute + " " + "< v,V < w,W < x,X < y,Y < " + lcYAcute + "," + ucYAcute + " " + "< z,Z < " + lcThorn + "," + ucThorn + " < " + lcAsh + "," + ucAsh + " " + "< " + lcOUml + "," + ucOUml); }
This is based on this explanation, and it worked first time, out of the box. Used NetBeans to create it. - Added it into
WEB-INF/lib
in Cocoon. - Created a new XQuery function to pull out all the relevant items from
names.xml
and include them in the output to the main page rendering code. - Wrote a new XSLT library to create the drop-down menu, using the custom collation like this:
<xsl:sort collation="http://saxon.sf.net/collation?class=ca.uvic.hcmc.myndir.MyndirCollation"/>
- Set up the menu CSS so that it works with mouseovers. Since we have a search box into which you can type any of these items as well, I don't know whether we need keyboard access to this menu; that might be overkill. But I'll think about it.
- Tested and uploaded.