+ case STATE_FINISHED_TEMPLATE_NODE:
+ throw new XML.SchemaException("no elements may appear after the <template> node");
+ }
+ }
+
+ private void processBodyElement(XML.Element c) {
+ Hash h = new Hash(c.len * 2, 3);
+ for(int i=0; i<c.len; i++) {
+ if (c.keys[i] == null) continue;
+ if (c.keys[i].endsWith(":image")) {
+ String uri = (String)c.urimap.get(c.keys[i].substring(0, c.keys[i].indexOf(':')));
+ c.keys[i] = c.keys[i].substring(c.keys[i].lastIndexOf(':') + 1);
+ c.vals[i] = uri + "." + c.vals[i];
+ }
+ if ((c.keys[i].equals("preapply") || c.keys[i].endsWith(":preapply")) && c.localName.equals("template")) {
+ String uri = "";
+ if (c.keys[i].endsWith(":preapply")) {
+ uri = "." + c.urimap.get(c.keys[i].substring(0, c.keys[i].indexOf(':')));
+ c.keys[i] = c.keys[i].substring(c.keys[i].lastIndexOf(':') + 1);
+ }
+ StringTokenizer tok = new StringTokenizer(c.vals[i].toString(), " ");
+ while(tok.hasMoreTokens()) t.preapply.addElement(uri + tok.nextToken());
+ c.keys[i] = c.keys[c.keys.length - 1];
+ c.vals[i] = c.vals[c.vals.length - 1];
+ i--;
+ continue;
+ }
+ h.put(c.keys[i], c.vals[i]);
+ }
+ t.keys = new String[h.size()];
+ t.vals = new Object[h.size()];
+
+ Vec v = new Vec(h.size(), c.keys);
+ v.sort(new Vec.CompareFunc() { public int compare(Object a, Object b) { return ((String)a).compareTo((String)b); } });
+ for(int i=0; i<h.size(); i++) {
+ if (c.keys[i].equals("thisbox")) {
+ for(int j=i; j>0; j--) { t.keys[j] = t.keys[j - 1]; t.vals[j] = t.vals[j - 1]; }
+ t.keys[0] = (String)v.elementAt(i);
+ t.vals[0] = h.get(t.keys[0]);
+ } else {
+ t.keys[i] = (String)v.elementAt(i);
+ t.vals[i] = h.get(t.keys[i]);
+ }