1 11 package org.eclipse.help.internal.search; 12 13 import java.io.InputStream ; 14 15 import org.eclipse.core.runtime.IPath; 16 import org.eclipse.core.runtime.Path; 17 import org.eclipse.help.internal.base.HelpBasePlugin; 18 import org.eclipse.help.internal.xhtml.DynamicXHTMLProcessor; 19 import org.eclipse.help.search.XMLSearchParticipant; 20 import org.xml.sax.Attributes ; 21 22 25 public class XHTMLSearchParticipant extends XMLSearchParticipant { 26 27 30 protected void handleEndElement(String name, IParsedXMLContent data) { 31 } 32 33 36 protected void handleStartElement(String name, Attributes attributes, IParsedXMLContent data) { 37 } 38 39 42 protected void handleText(String text, IParsedXMLContent data) { 43 String stackPath = getElementStackPath(); 44 IPath path = new Path(stackPath); 45 if (path.segment(1).equalsIgnoreCase("body")) { data.addText(text); 47 data.addToSummary(text); 48 } else if (path.segment(1).equalsIgnoreCase("head")) { data.setTitle(text); 50 } 51 } 52 53 56 protected InputStream preprocess(InputStream in, String name, String locale) { 57 try { 58 return DynamicXHTMLProcessor.process(name, in, locale, false); 59 } 60 catch (Throwable t) { 61 String msg = "An error occured while pre-processing help XHTML document \"" + name + "\" for search indexing"; HelpBasePlugin.logError(msg, t); 63 return in; 64 } 65 } 66 } | Popular Tags |