final String keySig = compileBuildKeys(classGen);
final int keyIdx = cpg.addMethodref(getClassName(),
"buildKeys", keySig);
il.append(classGen.loadTranslet()); // The 'this' pointer
il.append(classGen.loadTranslet());
il.append(new GETFIELD(domField)); // The DOM reference
il.append(transf.loadIterator()); // Not really used, but...
il.append(transf.loadHandler()); // The output handler
il.append(new PUSH(cpg, DOM.ROOTNODE)); // Start with the root node
il.append(new INVOKEVIRTUAL(keyIdx));
// Look for top-level elements that need handling
final Enumeration toplevel = elements();
if ((_globals.size() > 0) || (toplevel.hasMoreElements())) {
// Compile method for handling top-level elements
final String topLevelSig = compileTopLevel(classGen, toplevel);
// Get a reference to that method
final int topLevelIdx = cpg.addMethodref(getClassName(),
"topLevel",
topLevelSig);
// Push all parameters on the stack and call topLevel()
il.append(classGen.loadTranslet()); // The 'this' pointer
il.append(classGen.loadTranslet());
il.append(new GETFIELD(domField)); // The DOM reference
il.append(transf.loadIterator());
il.append(transf.loadHandler()); // The output handler
il.append(new INVOKEVIRTUAL(topLevelIdx));
}
// start document
il.append(transf.loadHandler());
il.append(transf.startDocument());
// push first arg for applyTemplates
il.append(classGen.loadTranslet());
// push translet for GETFIELD to get DOM arg
il.append(classGen.loadTranslet());
il.append(new GETFIELD(domField));
// push remaining 2 args
il.append(transf.loadIterator());
il.append(transf.loadHandler());
il.append(new INVOKEVIRTUAL(applyTemplates));
// endDocument