X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2FTemplate.java;h=28ff21544571cd83d696483f0a84de2d7e0cf8fe;hb=c28ed126fbc51fb5794bb367f51a8755dc20140e;hp=aa190b3e6c5c147e2bcc8dfbac1ce61b6b692256;hpb=af7c6de3c876cab3eb237a0f40796ab0994f1003;p=org.ibex.core.git diff --git a/src/org/ibex/Template.java b/src/org/ibex/Template.java index aa190b3..28ff215 100644 --- a/src/org/ibex/Template.java +++ b/src/org/ibex/Template.java @@ -32,6 +32,7 @@ public class Template { private Vec children = new Vec(); ///< during XML parsing, this holds the list of currently-parsed children; null otherwise private JS script = null; ///< the script on this node Template prev; + Template prev2; JSScope staticScope = null; ///< the scope in which the static block is executed @@ -75,12 +76,14 @@ public class Template { private void apply(Box b, PerInstantiationScope parentPis) throws JSExn, IOException { if (prev != null) prev.apply(b, null); + if (prev2 != null) prev2.apply(b, null); // FIXME this dollar stuff is all wrong if (id != null) parentPis.putDollar(id, b); PerInstantiationScope pis = new PerInstantiationScope(b, ibex, parentPis, staticScope); for(int i=0; i", 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 || "".equals(c.getUri("ui"))) c.addUri("ui", "ibex://ui"); + if (c.getUri("meta") == null || "".equals(c.getUri("meta"))) c.addUri("meta", "ibex://meta"); + if (c.getUri("") == null || "".equals(c.getUri(""))) 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,12 +213,12 @@ 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 { - t.prev = (Template)t.ibex.resolveString(tagname, false).call(null, null, null, null, 9999); - if (t.prev == null) throw new JSExn("template " + tagname + " not found"); + // GROSSER hack + t.prev2 = (Template)t.ibex.resolveString(tagname, false).call(null, null, null, null, 9999); } catch (Exception e) { Log.error(Template.class, e); } @@ -205,8 +232,10 @@ public class Template { while(uriEnumeration.hasMoreElements()) { String key = (String)uriEnumeration.nextElement(); String val = (String)urimap.get(key); + if (val.equals("ibex://ui")) continue; + if (val.equals("ibex://meta")) continue; t.urikeys[ii] = key; - if (val.charAt(0) == '.') val = val.substring(1); + if (val.length() > 0 && val.charAt(0) == '.') val = val.substring(1); t.urivals[ii] = val; ii++; } @@ -268,7 +297,7 @@ public class Template { public void endElement(XML.Element c) throws XML.Exn, IOException { switch(state) { - case STATE_IN_META_NODE: if (meta-- < 0) state = STATE_IN_ROOT_NODE; return; + case STATE_IN_META_NODE: if (--meta < 0) state = STATE_IN_ROOT_NODE; return; case STATE_IN_ROOT_NODE: return; case STATE_IN_TEMPLATE_NODE: { if (t.content != null) { t.script = parseScript(t.content, t.content_start); t.content = null; }