private void ProcessTemplate(XmlNode n, Hashtable ff) {
if (ff == null)
ff = new Hashtable();
Hashtable ss = new Hashtable();
XmlNode n2 = n.FirstChild;
while (n2 != null) {
if (n2.NodeType == XmlNodeType.Element) {
String s = n2.LocalName;
if (s.Equals("subform")) {
XmlNode name = n2.Attributes.GetNamedItem("name");
String nn = "#subform";
bool annon = true;
if (name != null) {
nn = EscapeSom(name.Value);
annon = false;
}
int i;
if (annon) {
i = anform;
++anform;
}
else {
if (ss[nn] == null)
i = 0;
else
i = (int)ss[nn] + 1;
ss[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")) {
XmlNode name = n2.Attributes.GetNamedItem("name");
if (name != null) {
String nn = EscapeSom(name.Value);
int i;
if (ff[nn] == null)
i = 0;
else
i = (int)ff[nn] + 1;
ff[nn] = i;
stack.Push(nn + "[" + i.ToString() + "]");
String unstack = PrintStack();
order.Add(unstack);
InverseSearchAdd(unstack);
name2Node[unstack] = n2;
stack.Pop();
}
}
else if (!dynamicForm && templateLevel > 0 && s.Equals("occur")) {
int initial = 1;
int min = 1;
int max = 1;
XmlNode a = n2.Attributes.GetNamedItem("initial");
if (a != null)
try{initial = int.Parse(a.Value.Trim());}catch{};
a = n2.Attributes.GetNamedItem("min");
if (a != null)
try{min = int.Parse(a.Value.Trim());}catch{};
a = n2.Attributes.GetNamedItem("max");
if (a != null)
try{max = int.Parse(a.Value.Trim());}catch{};
if (initial != min || min != max)
dynamicForm = true;
}
}
n2 = n2.NextSibling;
}
}