fixed bug 456 re namespaces
authoradam <adam@megacz.com>
Wed, 11 Feb 2004 07:20:16 +0000 (07:20 +0000)
committeradam <adam@megacz.com>
Wed, 11 Feb 2004 07:20:16 +0000 (07:20 +0000)
darcs-hash:20040211072016-5007d-a7700f7b1e76d2a17d7565fb9102e019ed00d1a6.gz

src/org/ibex/HTTP.java
src/org/ibex/Ibex.java
src/org/ibex/Template.java
src/org/ibex/util/XML.java

index b95c3bc..a8389b1 100644 (file)
@@ -782,7 +782,9 @@ public class HTTP {
                 Scheduler.add(new Scheduler.Task() {
                         public void perform() throws IOException, JSExn {
                             Box b = new Box();
-                            Template t = Template.buildTemplate("org/ibex/builtin/proxy_authorization.ibex", Stream.getInputStream((JS)Main.builtin.get("org/ibex/builtin/proxy_authorization.ibex")), new Ibex(null));
+                            Template t = null;
+                            // FIXME
+                            //Template.buildTemplate("org/ibex/builtin/proxy_authorization.ibex", Stream.getInputStream((JS)Main.builtin.get("org/ibex/builtin/proxy_authorization.ibex")), new Ibex(null));
                             t.apply(b);
                             b.put("realm", realm);
                             b.put("proxyIP", proxyIP);
index 3ab733f..225b4bc 100644 (file)
@@ -322,8 +322,8 @@ public final class Ibex extends JS.Cloneable {
     public static class Blessing extends JS.Clone {
         private Ibex ibex;
         private Template t = null;
-        private Object parentkey = null;
-        private Blessing parent = null;
+        public Object parentkey = null;
+        public Blessing parent = null;
         public Blessing(JS.Cloneable clonee, Ibex ibex, Blessing parent, Object parentkey) {
             super(clonee); this.ibex = ibex; this.parentkey = parentkey; this.parent = parent; }
         public Object get(Object key) throws JSExn {
@@ -353,7 +353,7 @@ public final class Ibex extends JS.Cloneable {
             try {
                 // FIXME background?
                 if (t == null)
-                    t = Template.buildTemplate(parentkey + ".t", Stream.getInputStream(parent.get(parentkey + ".t")), ibex);
+                    t = Template.buildTemplate(parentkey + ".t", parent.get(parentkey + ".t"), ibex);
                 return t.staticScope;
             } catch (Exception e) {
                 Log.error(this, e);
index 943fe0f..ed91cd3 100644 (file)
@@ -123,9 +123,9 @@ public class Template {
 
     // XML Parsing /////////////////////////////////////////////////////////////////
 
-    public static Template buildTemplate(String sourceName, InputStream is, Ibex ibex) {
+    public static Template buildTemplate(String sourceName, Object s, Ibex ibex) {
         try {
-            return new TemplateHelper(sourceName, is, ibex).t;
+            return new TemplateHelper(sourceName, s, ibex).t;
         } catch (Exception e) {
             Log.error(Template.class, e);
             return null;
@@ -149,9 +149,17 @@ public class Template {
         int meta = 0;
         Ibex ibex;
 
-       public TemplateHelper(String sourceName, InputStream is, Ibex ibex) throws XML.Exn, IOException, JSExn {
+        String initial_uri = "";
+
+       public TemplateHelper(String sourceName, Object s, Ibex ibex) throws XML.Exn, IOException, JSExn {
             this.sourceName = sourceName;
             this.ibex = ibex;
+            InputStream is = Stream.getInputStream(s);
+            Ibex.Blessing b = Ibex.Blessing.getBlessing(s).parent;
+            while(b != null) {
+                initial_uri = (b.parentkey == null ? "" : (b.parentkey + ".")) + initial_uri;
+                b = b.parent;
+            }
             parse(new InputStreamReader(is));
             JS staticScript = parseScript(static_content, static_content_start);
             t.staticScope = new PerInstantiationScope(null, ibex, null, null);
@@ -173,10 +181,12 @@ public class Template {
                         throw new XML.Exn("root element was not <ibex>", XML.Exn.SCHEMA, getLine(), getCol());
                     if (c.getAttrLen() != 0)
                         throw new XML.Exn("root element must not have attributes", XML.Exn.SCHEMA, getLine(), getCol());
+                    if (c.getUri("ui") == null) c.addUri("ui", "ibex://ui");
+                    if (c.getUri("") == null) c.addUri("", initial_uri);
                     state = STATE_IN_ROOT_NODE;
                     return;
                 case STATE_IN_ROOT_NODE:
-                    if ("meta".equals(c.getPrefix())) { state = STATE_IN_META_NODE; meta = 0; return; }
+                    if ("ibex://meta".equals(c.getUri())) { state = STATE_IN_META_NODE; meta = 0; return; }
                     state = STATE_IN_TEMPLATE_NODE;
                     t = (t == null) ? new Template(ibex) : new Template(t, getLine());
                     break;
@@ -186,7 +196,7 @@ public class Template {
                     break;
             }
 
-            if (!(/* "ui".equals(c.getPrefix()) && */ "box".equals(c.getLocalName()))) {
+            if (!("ibex://ui".equals(c.getUri()) && "box".equals(c.getLocalName()))) {
                 String tagname = (c.getUri().equals("") ? "" : (c.getUri() + ".")) + c.getLocalName();
                 // GROSS hack
                 try {
index d3ed118..e148fb9 100644 (file)
@@ -832,7 +832,7 @@ public abstract class XML
         protected Element() { }
 
         /** Add (replace if exists in current element) a Namespace prefix/uri map. */
-        protected void addUri(String name, String value) {
+        public void addUri(String name, String value) {
             urimap.put(name, value);
         }