Re: Ælfred2 SAX conformance

Chris Burdess <[email protected]>
Newsgroups gmane.comp.java.classpath.extensions.xml
Message-ID <[email protected]>
Musachy Barroso wrote:
> Guys..I think something is wrong...I'm getting a 83.9 %....

I'm using a version of SAXTest with the attached patch applied. I 
submitted this patch to Rusty Harold along with build patches (for the 
correct name of the gnujaxp.jar property and to do the libxmlj tests), 
but he hasn't applied it upstream.

The patch normalises ignorableWhitespace and characters recognition, so 
it doesn't penalise other parsers for not having the exact same 
behaviour as Xerces (which is not demonstrably correct in this matter). 
There are a couple of performance improvements as well.
-- 
Chris Burdess

_______________________________________________
Classpathx-xml mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpathx-xml
SAXTest.patch (application/octet-stream, 4 KB)
--- SAXTest.orig/src/com/elharo/saxtest/ResultComparer.java	Sat Mar  6 11:33:06 2004
+++ SAXTest/src/com/elharo/saxtest/ResultComparer.java	Sat Jun 26 11:57:23 2004
@@ -218,74 +218,49 @@
         }   
         int actual = expected;  
         
-        for (; 
-             expected < expectedChildren.size() && actual < actualChildren.size(); 
+        for (; expected < expectedSize && actual < actualSize; 
              expected++, actual++) {
             Element nextExpected = expectedChildren.get(expected);
             Element nextActual = actualChildren.get(expected);
+            String expectedLocalName = nextExpected.getLocalName();
+            String actualLocalName = nextActual.getLocalName();
+            // handle fatalError
+            if (expectedLocalName.equals("fatalError") ||
+                actualLocalName.equals("fatalError")) {
+              return isDoubleFatality(expectedChildren, actualChildren);
+            }
             // need to normalize characters and ignorable 
-            if (nextExpected.getLocalName().equals("ignorable")) {
-                if (
-                 (nextActual.getLocalName().equals("char") || nextActual.getLocalName().equals("ignorable"))
-                  && nextActual.getValue().equals(nextExpected.getValue())) {
-                    continue;
-                }
-                else {
-                    return false;
+            if (expectedLocalName.equals("char") || expectedLocalName.equals("ignorable")) {
+                if (actualLocalName.equals("char") || actualLocalName.equals("ignorable")) {
+                  String expectedValue = nextExpected.getValue();
+                  String actualValue = nextActual.getValue();
+                  return actualValue.equals(expectedValue);
                 }
+                return false;
             }
             
             try {
                 XOMTestCase.assertEquals(nextExpected, nextActual);
             }
             catch (AssertionFailedError error) {
-                // is it a fatalError?
-                if (nextActual.getLocalName().equals("fatalError")) {
-                    Element expectedPenultimate = expectedChildren.get(expectedChildren.size()-2); 
-                    if ("fatalError".equals(expectedPenultimate.getLocalName())) {
-                        return true;
-                    }
-                }
-            
                 return false;
             }
             
         }
         
-        if (expectedChildren.size() != actualChildren.size()) {
-            
-            return isDoubleFatality(expectedChildren, actualChildren);
-            /* if (
-               ("fatalError".equals(actualChildren.get(actualSize-2).getQualifiedName())
-               || "fatalError".equals(actualChildren.get(actualSize-1).getQualifiedName()))
-              && "fatalError".equals(expectedChildren.get(expectedSize-2).getQualifiedName())) {
-                return true;
-            }
-            else {
-                return false;
-            } */
-        }
-        
         return true;
         
     }
-    
+
     
     private boolean isDoubleFatality(Elements expected, Elements actual) {
-        
-        try {
-            boolean b1 = expected.get(expected.size()-2).getQualifiedName().equals("fatalError");
-            boolean b2 = actual.get(actual.size()-1).getQualifiedName().equals("fatalError")
-                       || actual.get(actual.size()-2).getQualifiedName().equals("fatalError");
-            return b1 && b2;
-        }
-        catch (IndexOutOfBoundsException ex) {
-            return false;
-        }
+      Element expectedPenultimate = expected.get(expected.size() - 2); 
+      Element actualPenultimate = actual.get(actual.size() - 2);
+      return (expectedPenultimate.getLocalName().equals("fatalError") &&
+              actualPenultimate.getLocalName().equals("fatalError"));
+    }
     
-    } 
     
-
     private boolean containsNotation(Elements expectedNotations, Element actual) {
         
         for (int i = 0; i < expectedNotations.size(); i++) {
PGP.sig (application/pgp-signature, 186 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.