introduce global attribute processing
[org.ibex.xt-crawshaw.git] / src / java / org / ibex / xt / JSElement.java
index c6eee6e..35ee51e 100644 (file)
@@ -32,21 +32,7 @@ public class JSElement extends JSScope implements XML.Element {
     public void out(OutputStream o) throws IOException { wrapped.out(o); }
     public void out(Writer w) throws IOException { wrapped.out(w); }
 
-    /** Load the attributes into the js scope. */
-    protected void loadAttr() {
-        try {
-            XML.Attributes a = getAttributes();
-            // FIXME: questionable abuse of XML namespaces here
-            boolean xturi = "http://xt.ibex.org/".equals(getUri());
-            for(int i=0; i < a.attrSize(); i++) {
-                if (!xturi && !"http://xt.ibex.org/".equals(a.getUri(i))) continue;
-                declare(a.getKey(i));
-                put(a.getKey(i), eval(a.getVal(i)));
-            }
-        } catch (JSExn e) { throw new Exn(e); }
-    }
-
-    private Object eval(String s) {
+    protected Object eval(String s) {
         if (s == null) return null;
         StringBuffer ret = new StringBuffer();
         while (s.indexOf("${") != -1) {
@@ -75,7 +61,7 @@ public class JSElement extends JSScope implements XML.Element {
                            JS.fromReader("input", 0, new StringReader(s)), this));
         } catch (IOException e) {
             e.printStackTrace();
-            throw new Exn("impossible IOException, reading from StringReader");
+            throw new Exn("error parsing script", e);
         } catch (JSExn e) {
             throw new Exn(e);
         }
@@ -154,6 +140,7 @@ public class JSElement extends JSScope implements XML.Element {
     public static class Exn extends RuntimeException {
         public Exn(String cause) { super(cause); }
         public Exn(JSExn e) { super(e); }
+        public Exn(String msg, Exception e) { super(msg + ": " + e.getMessage()); }
         public String toString() { return "JSElement.Exn: "+getMessage(); }
     }
 }