+ TRANSLET_OUTPUT_SIG
+ ")" + STRING_SIG);
il.append(new INVOKEINTERFACE(cpy, 3));
il.append(DUP);
name.setStart(il.append(new ASTORE(name.getIndex())));
final BranchHandle ifBlock1 = il.append(new IFNULL(null));
// Get the length of the node name and save for later
il.append(new ALOAD(name.getIndex()));
final int lengthMethod = cpg.addMethodref(STRING_CLASS,"length","()I");
il.append(new INVOKEVIRTUAL(lengthMethod));
il.append(DUP);
length.setStart(il.append(new ISTORE(length.getIndex())));
// Ignore attribute sets if current node is ROOT. DOM.shallowCopy()
// returns "" for ROOT, so skip attribute sets if length == 0
final BranchHandle ifBlock4 = il.append(new IFEQ(null));
// Copy in attribute sets if specified
if (_useSets != null) {
// If the parent of this element will result in an element being
// output then we know that it is safe to copy out the attributes
final SyntaxTreeNode parent = getParent();
if ((parent instanceof LiteralElement) ||
(parent instanceof LiteralElement)) {
_useSets.translate(classGen, methodGen);
}
// If not we have to check to see if the copy will result in an
// element being output.
else {
// check if element; if not skip to translate body
il.append(new ILOAD(length.getIndex()));
final BranchHandle ifBlock2 = il.append(new IFEQ(null));
// length != 0 -> element -> do attribute sets
_useSets.translate(classGen, methodGen);
// not an element; root
ifBlock2.setTarget(il.append(NOP));
}
}
// Instantiate body of xsl:copy
ifBlock4.setTarget(il.append(NOP));
translateContents(classGen, methodGen);
// Call the output handler's endElement() if we copied an element
// (The DOM.shallowCopy() method calls startElement().)
length.setEnd(il.append(new ILOAD(length.getIndex())));
final BranchHandle ifBlock3 = il.append(new IFEQ(null));
il.append(methodGen.loadHandler());
name.setEnd(il.append(new ALOAD(name.getIndex())));
il.append(methodGen.endElement());
final InstructionHandle end = il.append(NOP);
ifBlock1.setTarget(end);
ifBlock3.setTarget(end);
methodGen.removeLocalVariable(name);
methodGen.removeLocalVariable(length);
}