Revision: 4497
          http://vexi.svn.sourceforge.net/vexi/?rev=4497&view=rev
Author:   mkpg2
Date:     2013-03-21 06:10:41 +0000 (Thu, 21 Mar 2013)
Log Message:
-----------
Fix regression. Broke XML.parse(), reset has to happen before detecting 
encoding.
Fix. Attributes.getIndex() - previously unused, so unnoticed.

Modified Paths:
--------------
    trunk/org.vexi-library.util/src/main/java/org/ibex/util/XML.java

Modified: trunk/org.vexi-library.util/src/main/java/org/ibex/util/XML.java
===================================================================
--- trunk/org.vexi-library.util/src/main/java/org/ibex/util/XML.java    
2013-03-20 12:40:22 UTC (rev 4496)
+++ trunk/org.vexi-library.util/src/main/java/org/ibex/util/XML.java    
2013-03-21 06:10:41 UTC (rev 4497)
@@ -110,17 +110,22 @@
         buf = new char[bSize];
         this.poolElements = poolElements;;
     }
+    
+    private void reset(){
+       // reset
+        off = len = 0;
+        line = col = 1;
+        current = null;        
+    }
    
     public void setInput(InputStream in, String defaultEncoding) throws 
IOException{
-       // parse prolog, which will determine the char set if present
+       reset();
+        // parse prolog, which will determine the char set if present
         String encoding = p_parse(in, defaultEncoding);
-        setInput(new InputStreamReader(in, encoding));
+        this.in = new InputStreamReader(in, encoding);
     }
     public void setInput(Reader in){
-       // reset
-        off = len = 0;
-        line = col = 1;
-        current = null;
+       reset();
         this.in = in;
     }
     
@@ -514,7 +519,8 @@
                 // work out the uri of this element
                 String p = current.getPrefix();
                 String uri = current.uri(p);
-                if (uri == null && p != null && !p.equals("")) 
error(e("undefined prefix '"+current.getPrefix()+"'", Exn.NC));
+                if (uri == null && p != null && !p.equals(""))
+                       error(e("undefined prefix '"+current.getPrefix()+"'", 
Exn.NC));
                 else current.uri = uri;
 
             } else {
@@ -1207,8 +1213,11 @@
         }
 
         public int getIndex(String uri, String key) {
-            if (attr != null) for(int i=0; i < attrSize; i++)
-                if (attr[i*4].equals(key) && attr[i*4+1].equals(uri)) return i;
+            if (attr != null) for(int i=0; i < attrSize; i++){
+               String key1 = attr[i*4];
+               String uri1 = attr[i*4+2];
+                if (key.equals(key1) && (uri==null || uri.equals(uri1))) 
return i;
+            }
             return -1;
         }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to