- 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]);
- }
+ Vec keys = new Vec(c.getAttrLen());
+ Vec vals = new Vec(c.getAttrLen());
+
+ // process attributes into Vecs, dealing with any XML Namespaces in the process
+ ATTR: for (int i=0; i < c.getAttrLen(); i++) {
+ //#switch(c.getAttrKey(i))
+ case "id":
+ t.id = c.getAttrVal(i).toString().intern();
+ continue ATTR;
+ //#end
+
+ // treat value starting with '.' as resource reference
+ String uri = c.getAttrUri(i); if (!uri.equals("")) uri = '.' + uri;
+ keys.addElement(c.getAttrKey(i));
+ vals.addElement((c.getAttrVal(i).startsWith(".") ? uri : "") + c.getAttrVal(i));