diff options
author | Curtis D'Entremont | 2006-03-02 00:10:25 +0000 |
---|---|---|
committer | Curtis D'Entremont | 2006-03-02 00:10:25 +0000 |
commit | 94ff6f30fee5393bf8c5563bbd4040068f357e3c (patch) | |
tree | b3e990764296852127f7ce37e2d4b6aecc5858e3 /org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java | |
parent | 488c04382d19f95121b443ec6d7972789c6082d3 (diff) | |
download | eclipse.platform.ua-94ff6f30fee5393bf8c5563bbd4040068f357e3c.tar.gz eclipse.platform.ua-94ff6f30fee5393bf8c5563bbd4040068f357e3c.tar.xz eclipse.platform.ua-94ff6f30fee5393bf8c5563bbd4040068f357e3c.zip |
130051 [Help] Search dynamic content properlyv20060301
Diffstat (limited to 'org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java')
-rw-r--r-- | org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java | 104 |
1 files changed, 13 insertions, 91 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java index baddad91e..6ece2b517 100644 --- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java +++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java @@ -1,80 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2005, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ package org.eclipse.help.internal.search; -import java.io.IOException; -import java.io.InputStream; -import java.util.Stack; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import org.eclipse.help.internal.DynamicContentProducer; import org.eclipse.help.search.XMLSearchParticipant; import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - public class XHTMLSearchParticipant extends XMLSearchParticipant { - - class IncludedHandler extends DefaultHandler { - - private String id; - private boolean active; - private Stack stack = new Stack(); - private IParsedXMLContent data; - - public IncludedHandler(String id, IParsedXMLContent data) { - this.id = id; - this.data = data; - } - - public void startElement(String uri, String localName, String qName, Attributes attributes) - throws SAXException { - String eid = attributes.getValue("id"); //$NON-NLS-1$ - if (eid != null && eid.equals(id)) { - stack.push(qName); - active = true; - } - } - - public void endElement(String uri, String localName, String qName) throws SAXException { - if (active) { - stack.pop(); - if (stack.size() == 0) - active = false; - } - } - - public void characters(char[] characters, int start, int length) throws SAXException { - if (!active) - return; - if (length == 0) - return; - StringBuffer buff = new StringBuffer(); - for (int i = 0; i < length; i++) { - buff.append(characters[start + i]); - } - String text = buff.toString().trim(); - if (text.length() > 0) { - data.addText(text); - data.addToSummary(text); - } - } - } - - - public XHTMLSearchParticipant() { - } - + protected void handleStartElement(String name, Attributes attributes, IParsedXMLContent data) { - if (name.equalsIgnoreCase("include")) { //$NON-NLS-1$ - processIncludedContent(attributes.getValue("path"), data); //$NON-NLS-1$ - } + // do nothing } protected void handleEndElement(String name, IParsedXMLContent data) { + // do nothing } protected void handleText(String text, IParsedXMLContent data) { @@ -87,30 +35,4 @@ public class XHTMLSearchParticipant extends XMLSearchParticipant { data.setTitle(text); } } - - private void processIncludedContent(String path, IParsedXMLContent data) { - int sep1 = path.indexOf('/'); - if (sep1 == -1) - return; - String pluginId = path.substring(0, sep1); - int sep2 = path.lastIndexOf('/'); - if (sep2 == -1) - return; - String href = path.substring(sep1 + 1, sep2); - String id = path.substring(sep2 + 1); - InputStream stream = DynamicContentProducer.openStreamFromPlugin(pluginId, href, data.getLocale()); - if (stream == null) - return; - try { - SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); - IncludedHandler handler = new IncludedHandler(id, data); - parser.parse(stream, handler); - } catch (Exception e) { - } finally { - try { - stream.close(); - } catch (IOException e) { - } - } - } }
\ No newline at end of file |