Author: scabanovich
Date: 2010-09-07 12:09:53 -0400 (Tue, 07 Sep 2010)
New Revision: 24772
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java
Log:
https://jira.jboss.org/browse/JBIDE-3875
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java 2010-09-07
15:36:15 UTC (rev 24771)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java 2010-09-07
16:09:53 UTC (rev 24772)
@@ -17,6 +17,7 @@
import org.w3c.dom.*;
import org.xml.sax.Attributes;
+import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
@@ -99,14 +100,19 @@
stream1 = url.openStream();
stream2 = new BufferedInputStream(stream1, 16384);
-
Element g = parse(stream2);
if(g == null) {
+ System.out.println("SAX parser failed to load meta resource " + name);
+ stream1 = url.openStream();
+ stream2 = new BufferedInputStream(stream1, 16384);
+ g = XMLUtilities.getElement(stream2, new EmptyResolver());
+ }
+ if(g == null) {
ModelPlugin.getPluginLog().logInfo("Corrupted meta resource " + name);
//$NON-NLS-1$
} else {
load0(g, name, url.toString());
}
-
+
} catch (IOException e) {
ModelPlugin.getPluginLog().logError("MetaLoader: Cannot read resource " +
url.toString()); //$NON-NLS-1$
return;
@@ -151,28 +157,16 @@
}
- boolean isRootUsed = false;
-
Element parse(InputStream stream) {
- if(isRootUsed) {
- root = XMLUtilities.createDocumentElement("meta"); //$NON-NLS-1$
- ModelPlugin.getDefault().logError("Is root used");
- System.out.println("Is root used");
- }
- isRootUsed = true;
Parser p = new Parser();
p.documentElement = root;
p.current = root;
p.parse(stream);
Element g = p.documentElement;
g = XMLUtilities.getUniqueChild(g, "XModelEntityGroup"); //$NON-NLS-1$
- try {
+ if(g != null) {
p.documentElement.removeChild(g);
- } catch (NullPointerException e) {
- ModelPlugin.getDefault().logError("Null pointer while trying to remove child
" + g);
- System.out.println("Null pointer while trying to remove child " + g);
}
- isRootUsed = false;
return g;
}
@@ -274,14 +268,6 @@
SAXValidator.setFeature(parserInstance, VALIDATION_DYNAMIC_FEATURE_ID, false);
SAXValidator.setFeature(parserInstance, FATAL_ERROR_PROCESSING_FEATURE_ID,
false);
- class EmptyHandler implements org.apache.xerces.xni.parser.XMLEntityResolver {
-
- public XMLInputSource resolveEntity(XMLResourceIdentifier id)
- throws XNIException, IOException {
- return new XMLInputSource(id.getPublicId(), id.getBaseSystemId(),
id.getBaseSystemId(), new StringReader(""), null);
- }
-
- }
try {
if(MetaLibLoader.validateMetaXML) {
parserInstance.setProperty(ENTITY_RESOLVER_PROPERTY_ID, new
XMLEntityResolverImpl());
@@ -346,3 +332,18 @@
public void startPrefixMapping(String prefix, String uri) throws SAXException {}
}
+
+class EmptyHandler implements org.apache.xerces.xni.parser.XMLEntityResolver {
+
+ public XMLInputSource resolveEntity(XMLResourceIdentifier id)
+ throws XNIException, IOException {
+ return new XMLInputSource(id.getPublicId(), id.getBaseSystemId(), id.getBaseSystemId(),
new StringReader(""), null);
+ }
+
+}
+
+class EmptyResolver implements EntityResolver {
+ public InputSource resolveEntity(String publicID, String systemID) throws SAXException,
IOException {
+ return new InputSource(new StringReader("")); //$NON-NLS-1$
+ }
+}