- Hash h = new Hash(c.len * 2, 3);
-
- // WARNING: c.keys.length != c.len; USE c.len
- for(int i=0; i<c.len; i++) {
- if (c.keys[i] == null) throw new RuntimeException("XML parser returned a null key position="+i);
- if (c.keys[i].equals("font") && c.uris[i] != null) c.vals[i] = c.uris[i] + "." + c.vals[i];
- if (c.keys[i].equals("preapply")) {
- // process preapply and 'remove' from array
- String uri = c.uris[i] == null ? "" : c.uris[i] + '.';
- StringTokenizer tok = new StringTokenizer(c.vals[i].toString(), " ");
- while(tok.hasMoreTokens()) t.preapply.addElement(uri + tok.nextToken());
-
- if (i < c.len - 1) { // not the last attribute
- c.keys[i] = c.keys[c.len - 1];
- c.vals[i] = c.vals[c.len - 1];
- c.uris[i] = c.uris[c.len - 1];
- }
- c.len--; 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));