01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.schema;
11:
12: import java.io.StringReader;
13: import java.util.LinkedList;
14:
15: import org.xml.sax.Attributes;
16: import org.xml.sax.InputSource;
17: import org.xml.sax.SAXException;
18: import org.xml.sax.helpers.DefaultHandler;
19:
20: /**
21: * BaseDescriptionHandler
22: *
23: */
24: public class BaseSchemaHandler extends DefaultHandler {
25:
26: protected LinkedList fElementList;
27:
28: public BaseSchemaHandler() {
29: reset();
30: }
31:
32: protected void reset() {
33: fElementList = new LinkedList();
34: }
35:
36: public void startDocument() throws SAXException {
37: reset();
38: }
39:
40: public void startElement(String uri, String localName,
41: String qName, Attributes attributes) throws SAXException {
42: // Track where we are in the XML document
43: // Note: XML namespaces not utilized, safe to use qualified name
44: fElementList.addFirst(qName);
45: }
46:
47: public void endElement(String uri, String localName, String qName)
48: throws SAXException {
49: // Track where we are in the XML document
50: if (fElementList.size() != 0) {
51: fElementList.removeFirst();
52: } else {
53: // This should never happened and is ignored in any case
54: throw new SAXException(
55: "Serious error. XML document is not well-formed"); //$NON-NLS-1$
56: }
57: }
58:
59: public InputSource resolveEntity(String publicId, String systemId)
60: throws SAXException {
61: // Prevent the resolution of external entities in order to
62: // prevent the parser from accessing the Internet
63: // This will prevent huge workbench performance degradations and hangs
64: return new InputSource(new StringReader("")); //$NON-NLS-1$
65: }
66:
67: }
|