Fix for issue #1796.  I am not sure that the behavior is what we want.   The original problem is that the XML parser  throws a NULL pointer exception if there is a non-blank body to an XML element and there is no stack element left (we are at an inner most definition of a class.) I modified the characters() method so that a body filled with whitepace is OK, but a body with some text in it will throw a (specific) exception.

The problem occurs in the module XML file under the following condition:

<servelet> </servelet>    <!-- OK -->
<servelet> stuff </servelet> <!-- throws a SAXException pointing out that the " stuff " is unexpected -->

(I ran into this when editing my module.xml file with the eclipse built-in XML editor.)

Patch by: zundel
Review by: me


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1509 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/util/xml/ReflectiveParser.java b/dev/core/src/com/google/gwt/dev/util/xml/ReflectiveParser.java
index 5c31158..1b53760 100644
--- a/dev/core/src/com/google/gwt/dev/util/xml/ReflectiveParser.java
+++ b/dev/core/src/com/google/gwt/dev/util/xml/ReflectiveParser.java
@@ -65,6 +65,21 @@
       //
       Schema schemaLevel = getTopSchemaLevel();
 
+      if (schemaLevel == null) {
+        // It is legitimate to run out of schemaLevels if there is an empty node
+        // in the XML. Otherwise, it indicates that the user has specified
+        // extra stuff in the body of the XML tag that we don't understand.
+        //
+        for (int i = 0; i < length; i++) {
+          if (!Character.isWhitespace(ch[i + start])) {
+            throw new SAXException("Unexpected XML data found: "
+                + String.valueOf(ch, start, length));
+          }
+        }
+        // This is okay. Nothing special to do.
+        //
+        return;
+      }
       // Find the precomputed handler class info.
       //
       Class slc = schemaLevel.getClass();