}
public void invoke(ProcessContext context, Node node,
Result result) throws XSLException
{
NumberListFormat format = formatTemplate.instantiate(context, node);
Node root = node.getRoot();
Hashtable documentTable = (Hashtable)context.get(this);
if (documentTable == null) {
documentTable = new Hashtable();
context.put(this, documentTable);
}
Cache cache;
if (count != null) {
cache = (Cache)documentTable.get(root);
if (cache == null) {
cache = new Cache();
documentTable.put(root, cache);
int n = 0;
for (NodeIterator iter =
new DescendantsOrSelfNodeIterator(root);;) {
Node tem = iter.next();
if (tem == null) {
break;
}
if (from != null && from.matches(tem, context)) {
n = 0;
} else if (count.matches(tem, context)) {
cache.append(tem, n++);
}
}
}
}
else if (node.getType() == Node.ELEMENT) {
Hashtable elementTable = (Hashtable)documentTable.get(root);
if (elementTable == null) {
elementTable = new Hashtable();
documentTable.put(root, elementTable);
}
Name name = node.getName();
cache = (Cache)elementTable.get(name);
if (cache == null) {
cache = new Cache();
elementTable.put(name, cache);
int n = 0;
for (NodeIterator iter = new DescendantsOrSelfNodeIterator(root);;) {
Node tem = iter.next();
if (tem == null)
break;
if (from != null && from.matches(tem, context))
n = 0;
else if (name.equals(tem.getName()) && tem.getType() == Node.ELEMENT)
cache.append(tem, n++);
}
}
}
else
return;
result.characters(format.getPrefix(0));
result.characters(format.formatNumber(0, cache.getNumber(node)));
result.characters(format.getSuffix());
}