private void processTemplate(Node n, HashMap ff) {
if (ff == null)
ff = new HashMap();
HashMap ss = new HashMap();
Node n2 = n.getFirstChild();
while (n2 != null) {
if (n2.getNodeType() == Node.ELEMENT_NODE) {
String s = n2.getLocalName();
if (s.equals("subform")) {
Node name = n2.getAttributes().getNamedItem("name");
String nn = "#subform";
boolean annon = true;
if (name != null) {
nn = escapeSom(name.getNodeValue());
annon = false;
}
Integer i;
if (annon) {
i = new Integer(anform);
++anform;
}
else {
i = (Integer)ss.get(nn);
if (i == null)
i = new Integer(0);
else
i = new Integer(i.intValue() + 1);
ss.put(nn, i);
}
stack.push(nn + "[" + i.toString() + "]");
++templateLevel;
if (annon)
processTemplate(n2, ff);
else
processTemplate(n2, null);
--templateLevel;
stack.pop();
}
else if (s.equals("field") || s.equals("exclGroup")) {
Node name = n2.getAttributes().getNamedItem("name");
if (name != null) {
String nn = escapeSom(name.getNodeValue());
Integer i = (Integer)ff.get(nn);
if (i == null)
i = new Integer(0);
else
i = new Integer(i.intValue() + 1);
ff.put(nn, i);
stack.push(nn + "[" + i.toString() + "]");
String unstack = printStack();
order.add(unstack);
inverseSearchAdd(unstack);
name2Node.put(unstack, n2);
stack.pop();
}
}
else if (!dynamicForm && templateLevel > 0 && s.equals("occur")) {
int initial = 1;
int min = 1;
int max = 1;
Node a = n2.getAttributes().getNamedItem("initial");
if (a != null)
try{initial = Integer.parseInt(a.getNodeValue().trim());}catch(Exception e){}
a = n2.getAttributes().getNamedItem("min");
if (a != null)
try{min = Integer.parseInt(a.getNodeValue().trim());}catch(Exception e){}
a = n2.getAttributes().getNamedItem("max");
if (a != null)
try{max = Integer.parseInt(a.getNodeValue().trim());}catch(Exception e){}
if (initial != min || min != max)
dynamicForm = true;
}
}
n2 = n2.getNextSibling();