You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2009/02/23 19:49:34 UTC
svn commit: r747101 - in /xerces/java/trunk/src/org/apache/xerces/impl/xs:
opti/SchemaDOMParser.java traversers/XSDHandler.java
Author: mrglavas
Date: Mon Feb 23 18:49:33 2009
New Revision: 747101
URL: http://svn.apache.org/viewvc?rev=747101&view=rev
Log:
Improve error processing in schema loading. We should not be
swallowing parse exceptions thrown by the SAX or StAX parser.
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java
xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java?rev=747101&r1=747100&r2=747101&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java Mon Feb 23 18:49:33 2009
@@ -192,7 +192,8 @@
// the string we saw: starting from the first non-whitespace character.
String txt = new String(text.ch, i, text.length+text.offset-i);
// report an error
- fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ fErrorReporter.reportError(fLocator,
+ XSMessageFormatter.SCHEMA_DOMAIN,
"s4s-elt-character",
new Object[]{txt},
XMLErrorReporter.SEVERITY_ERROR);
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java?rev=747101&r1=747100&r2=747101&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java Mon Feb 23 18:49:33 2009
@@ -55,12 +55,16 @@
import org.apache.xerces.util.DOMInputSource;
import org.apache.xerces.util.DOMUtil;
import org.apache.xerces.util.DefaultErrorHandler;
+import org.apache.xerces.util.ErrorHandlerWrapper;
import org.apache.xerces.util.SAXInputSource;
import org.apache.xerces.util.StAXInputSource;
+import org.apache.xerces.util.StAXLocationWrapper;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.util.XMLSymbols;
import org.apache.xerces.util.URI.MalformedURIException;
import org.apache.xerces.xni.QName;
+import org.apache.xerces.xni.XMLLocator;
+import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.grammars.Grammar;
import org.apache.xerces.xni.grammars.XMLGrammarDescription;
import org.apache.xerces.xni.grammars.XMLGrammarPool;
@@ -70,6 +74,7 @@
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLErrorHandler;
import org.apache.xerces.xni.parser.XMLInputSource;
+import org.apache.xerces.xni.parser.XMLParseException;
import org.apache.xerces.xs.XSObject;
import org.apache.xerces.xs.XSParticle;
import org.w3c.dom.Document;
@@ -77,6 +82,7 @@
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
@@ -387,7 +393,7 @@
private XSDocumentInfo [] fKeyrefsMapXSDocumentInfo = new XSDocumentInfo[INIT_KEYREF_STACK];
private XSElementDecl [] fKeyrefElems = new XSElementDecl [INIT_KEYREF_STACK];
private String [][] fKeyrefNamespaceContext = new String[INIT_KEYREF_STACK][1];
-
+
// Constructors
public XSDHandler(){
fHiddenNodes = new Hashtable();
@@ -1802,7 +1808,11 @@
hasInput = false;
}
}
- catch (SAXException se) {
+ catch (SAXParseException spe) {
+ throw SAX2XNIUtil.createXMLParseException0(spe);
+ }
+ catch (SAXException se) {
+ throw SAX2XNIUtil.createXNIException0(se);
}
catch (IOException ioe) {
}
@@ -1939,6 +1949,9 @@
return getSchemaDocument0(key, schemaId, schemaElement);
}
catch (XMLStreamException e) {
+ StAXLocationWrapper slw = new StAXLocationWrapper();
+ slw.setLocation(e.getLocation());
+ throw new XMLParseException(slw, e.getMessage(), e);
}
catch (IOException e) {
}
@@ -2845,6 +2858,15 @@
}
}
+ private static final class SAX2XNIUtil extends ErrorHandlerWrapper {
+ public static XMLParseException createXMLParseException0(SAXParseException exception) {
+ return createXMLParseException(exception);
+ }
+ public static XNIException createXNIException0(SAXException exception) {
+ return createXNIException(exception);
+ }
+ }
+
/**
* @param state
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org