2003/04/10 01:41:43
[org.ibex.core.git] / src / org / xwt / XML.java
index 7376510..afd2c3a 100644 (file)
@@ -3,7 +3,6 @@ package org.xwt;
 import java.io.*;
 import java.net.*;
 import java.util.*;
-import org.xwt.util.*;
 
 /** an event-driven XML parser, derived from MinML (http://www.wilson.co.uk/xml/minml.htm) */
 public abstract class XML {
@@ -229,6 +228,7 @@ public abstract class XML {
         public static final int discardSaveAndChange = 19;
         public static final int saveAndChange = 20;
         public static final int change = 21;
+        public static final int writeAsWS = 22;
         
         public static final int inSkipping = 0;
         public static final int inSTag = 1;
@@ -443,16 +443,7 @@ public abstract class XML {
                         
                         if (buffer.read() != '-') continue; // not "<!--"
 
-                        char[] lastthree = new char[3];
-                        int pos = 0;
-                        while(true) {
-                            currentChar = buffer.read();
-                            lastthree[pos] = (char)currentChar; 
-                            if (lastthree[pos] == '>' && lastthree[(pos + 2) % 3] == '-' && lastthree[(pos + 1) % 3] == '-') break;
-                            pos = (pos + 1) % 3;
-                        }
-
-                        state = operands[inCharData];
+                        state = operands[inComment];
                         continue;  // change state to operand
 
                     case endComment:
@@ -462,7 +453,9 @@ public abstract class XML {
                             // deal with the case where we might have "------->"
                             while ((currentChar = buffer.read()) == '-');
                             
-                            if (currentChar == '>') break;  // end of comment, change state to operand
+                            if (currentChar == '>') {
+                                state = operands[inCharData];
+                            }
                         }
                         
                         continue;   // not end of comment, don't change state
@@ -591,6 +584,10 @@ public abstract class XML {
                         buffer.write(currentChar);
                         break;  // change state to operand
                         
+                    case writeAsWS:
+                        buffer.write((currentChar == '\n' ? currentChar : (char)32));
+                        break;
+
                     case discardAndChange:
                         // throw saved characters away and change state
                         
@@ -898,7 +895,8 @@ public abstract class XML {
             "\u0a15\u110f\u110f\u110e\u110f\u110f\u110f\u110f\u110f\u110f\u110f\u110f\u110f\u1811\u110f",
             "\u1d11\u1d11\u1d11\u1d11\u1d11\u1d11\u1d11\u1d11\u1d11\u130c\u1d11\u1408\u1d11\u1811\u1515",
             "\u130f\u130f\u130f\u130f\u130f\u130f\u130f\u130f\u130f\u130f\u110d\u130f\u130f\u1811\u130f",
-            "\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u0009\u1415\u1811\u1415",
+            "\u1416\u1416\u1416\u1416\u1416\u1416\u1416\u1416\u1416\u1416\u1416\u0009\u1416\u1811\u1416",
+//            "\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u1415\u0009\u1415\u1811\u1415",
             "\u150a\u000b\u1515\u1515\u1515\u1515\u1515\u1515\u1515\u1515\u1515\u1515\u1515\u1811\u1515",
             "expected Element",
             "unexpected character in tag",