2003/04/24 14:33:27
authordavid <david@xwt.org>
Fri, 30 Jan 2004 06:59:14 +0000 (06:59 +0000)
committerdavid <david@xwt.org>
Fri, 30 Jan 2004 06:59:14 +0000 (06:59 +0000)
darcs-hash:20040130065914-0c9ea-0c2bc61fd698849e46b61361d851887cd2f17470.gz

src/org/xwt/ByteStream.java
src/org/xwt/Resources.java

index ab2dac1..2211d7d 100644 (file)
@@ -45,15 +45,17 @@ public class ByteStream extends JSObject {
     private class XMLHelper extends XML {
         Vector obStack = new Vector();
 
-        public void startElement(String name, String[] keys, Object[] vals, int line, int col) throws SAXException {
+        public XMLHelper() { super(BUFFER_SIZE); }
+
+        public void startElement(XML.Element c) throws XML.SchemaException {
             JSObject o = new JSObject();
-            o.put("$name", null, name);
-            for(int i=0; i<keys.length; i++) o.put(keys[i], null, vals[i]);
+            o.put("$name", null, c.localName);
+            for(int i=0; i<c.len; i++) o.put(c.keys[i], null, c.vals[i]);
             o.put("$numchildren", null, new Integer(0));
             obStack.addElement(o);
         }
 
-        public void endElement(String name, int line, int col) throws SAXException {
+        public void endElement(XML.Element c) throws XML.SchemaException {
             if (obStack.size() == 1) return;
             JSObject me = (JSObject)obStack.lastElement();
             obStack.setSize(obStack.size() - 1);
@@ -63,8 +65,8 @@ public class ByteStream extends JSObject {
             parent.put(numchildren, null, me);
         }
 
-        public void content(char[] content, int start, int length, int line, int col) throws SAXException {
-            String s = new String(content, start, length);
+        public void characters(char[] ch, int start, int length) throws XML.SchemaException {
+            String s = new String(ch, start, length);
             JSObject parent = (JSObject)obStack.lastElement();
             int numchildren = ((Integer)parent.get("$numchildren", null)).intValue();
             Object lastChild = parent.get(numchildren - 1, null);
@@ -76,12 +78,14 @@ public class ByteStream extends JSObject {
             }
         }
 
+        public void whitespace(char[] ch, int start, int length) {}
+
         public Scriptable doParse() throws JavaScriptException {
             try { 
                 InputStream is = getInputStream();
                 BufferedReader r = new BufferedReader(new InputStreamReader(is));
                 parse(r);
-            } catch (XML.SAXException e) {
+            } catch (XML.XMLException e) {
                 throw new JavaScriptException("error parsing XML: " + e.toString());
             } catch (IOException e) {
                 if (Log.on) Log.log(ByteStream.class, "IO Exception while reading from file");
index 59884c9..26d4f68 100644 (file)
@@ -101,6 +101,8 @@ public class Resources {
                 }
             });
 
+        Template.TemplateHelper t = new Template.TemplateHelper();
+
         for(ZipEntry ze = zis.getNextEntry(); ze != null; ze = zis.getNextEntry()) {
             String name = ze.getName();
             if (!validResourceName(name.substring(name.lastIndexOf('/') + 1))) {
@@ -120,7 +122,7 @@ public class Resources {
                 } else {
                     usedPackages.put(packageName, thisArchive);
                     Static.createStatic(name.replace('/', '.'), false);
-                    Template.buildTemplate(zis, name.replace('/', '.'));
+                    Template.buildTemplate(zis, name.replace('/', '.'), t);
                 }
 
             } else {