int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
il.append(new NEW(cpg.addClass(DOM_IMPL)));
il.append(DUP);
il.append(DUP);
il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
il.append(new INVOKESPECIAL(index));
// Overwrite old handler with DOM handler
index = cpg.addMethodref(DOM_IMPL,
"getOutputDomBuilder",
"()" + TRANSLET_OUTPUT_SIG);
il.append(new INVOKEVIRTUAL(index));
il.append(DUP);
il.append(methodGen.storeHandler());
// Call startDocument on the new handler
il.append(methodGen.startDocument());
// Instantiate result tree fragment
translateContents(classGen, methodGen);
// Call endDocument on the new handler
il.append(methodGen.loadHandler());
il.append(methodGen.endDocument());
// Check if we need to wrap the DOMImpl object in a DOMAdapter object
if (!DOM_CLASS.equals(DOM_IMPL_CLASS)) {
// new org.apache.xalan.xsltc.dom.DOMAdapter(DOMImpl,String[]);
index = cpg.addMethodref(DOM_ADAPTER_CLASS,
"<init>",
"("+DOM_IMPL_SIG+
"["+STRING_SIG+
"["+STRING_SIG+")V");
il.append(new NEW(cpg.addClass(DOM_ADAPTER_CLASS)));
il.append(new DUP_X1());
il.append(SWAP);
/*
* Give the DOM adapter an empty type mapping if the nodeset
* extension function is never called.
*/
if (!stylesheet.callsNodeset()) {
il.append(new ICONST(0));
il.append(new ANEWARRAY(cpg.addClass(STRING)));
il.append(DUP);
il.append(new INVOKESPECIAL(index));
}
else {
// Push name arrays on the stack
il.append(ALOAD_0);
il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
NAMES_INDEX,
NAMES_INDEX_SIG)));
il.append(ALOAD_0);
il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
NAMESPACE_INDEX,
NAMESPACE_INDEX_SIG)));
// Initialized DOM adapter
il.append(new INVOKESPECIAL(index));
// Add DOM adapter to MultiDOM class by calling addDOMAdapter()
il.append(DUP);
il.append(methodGen.loadDOM());
il.append(new CHECKCAST(cpg.addClass(classGen.getDOMClass())));