if (_testSeq[DOM.PROCESSING_INSTRUCTION] != null)
if (_testSeq[DOM.PROCESSING_INSTRUCTION] != null) {
    public void compileApplyImports(ClassGenerator classGen, int min, int max) {	final XSLTC xsltc = classGen.getParser().getXSLTC();	final ConstantPoolGen cpg = classGen.getConstantPool();	final Vector names      = xsltc.getNamesIndex();	// Clear some datastructures	_namedTemplates = new Hashtable();	_neededTemplates = new Hashtable();	_templateIHs = new Hashtable();	_templateILs = new Hashtable();	_patternGroups = new Vector[32];	_rootPattern = null;	// IMPORTANT: Save orignal & complete set of templates!!!!	Vector oldTemplates = _templates;	// Gather templates that are within the scope of this import	_templates = new Vector();	final Enumeration templates = oldTemplates.elements();	while (templates.hasMoreElements()) {	    final Template template = (Template)templates.nextElement();	    final int prec = template.getImportPrecedence();	    if ((prec >= min) && (prec < max)) addTemplate(template);	}	// Process all patterns from those templates	processPatterns(_keys);	// (*) Create the applyTemplates() method	final org.apache.bcel.generic.Type[] argTypes =	    new org.apache.bcel.generic.Type[3];	argTypes[0] = Util.getJCRefType(DOM_INTF_SIG);	argTypes[1] = Util.getJCRefType(NODE_ITERATOR_SIG);	argTypes[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);	final String[] argNames = new String[3];	argNames[0] = DOCUMENT_PNAME;	argNames[1] = ITERATOR_PNAME;	argNames[2] = TRANSLET_OUTPUT_PNAME;	final InstructionList mainIL = new InstructionList();	final MethodGenerator methodGen =	    new MethodGenerator(ACC_PUBLIC | ACC_FINAL, 				org.apache.bcel.generic.Type.VOID,				argTypes, argNames, functionName()+'_'+max,				getClassName(), mainIL,				classGen.getConstantPool());	methodGen.addException("org.apache.xalan.xsltc.TransletException");	// No templates? Then just stuff in a single 'return' instruction	if (_neededTemplates.size() == 0) {	    mainIL.append(new RETURN());	    methodGen.stripAttributes(true);	    methodGen.setMaxLocals();	    methodGen.setMaxStack();	    methodGen.removeNOPs();	    classGen.addMethod(methodGen.getMethod());	    // Restore original/complete set of templates for the transformation	    _templates = oldTemplates;	    return;	}	// (*) Create the local variablea	final LocalVariableGen current;	current = methodGen.addLocalVariable2("current",					      org.apache.bcel.generic.Type.INT,					      mainIL.getEnd());	_currentIndex = current.getIndex();	// (*) Create the "body" instruction list that will eventually hold the	//     code for the entire method (other ILs will be appended).	final InstructionList body = new InstructionList();	body.append(NOP);	// (*) Create an instruction list that contains the default next-node	//     iteration	final InstructionList ilLoop = new InstructionList();	ilLoop.append(methodGen.loadIterator());	ilLoop.append(methodGen.nextNode());	ilLoop.append(DUP);	ilLoop.append(new ISTORE(_currentIndex));	// The body of this code can get very large - large than can be handled	// by a single IFNE(body.getStart()) instruction - need workaround:        final BranchHandle ifeq = ilLoop.append(new IFEQ(null));	final BranchHandle loop = ilLoop.append(new GOTO_W(null));	ifeq.setTarget(ilLoop.append(RETURN)); // applyTemplates() ends here!	final InstructionHandle ihLoop = ilLoop.getStart();	// Distinguish attribute/element/namespace tests for further processing	final int[] types = new int[DOM.NTYPES + names.size()];	for (int i = 0; i < types.length; i++) types[i] = i;	final boolean[] isAttribute = new boolean[types.length];	final boolean[] isNamespace = new boolean[types.length];	for (int i = 0; i < names.size(); i++) {	    final String name = (String)names.elementAt(i);	    isAttribute[i+DOM.NTYPES] = isAttributeName(name);	    isNamespace[i+DOM.NTYPES] = isNamespaceName(name);	}	// (*) Compile all templates - regardless of pattern type	compileTemplateCalls(classGen, methodGen, ihLoop, min, max);	// (*) Handle template with explicit "*" pattern	final TestSeq elemTest = _testSeq[DOM.ELEMENT];	InstructionHandle ihElem = ihLoop;	if (elemTest != null)	    ihElem = elemTest.compile(classGen, methodGen, ihLoop);	// (*) Handle template with explicit "@*" pattern	final TestSeq attrTest = _testSeq[DOM.ATTRIBUTE];	InstructionHandle ihAttr = ihLoop;	if (attrTest != null)	    ihAttr = attrTest.compile(classGen, methodGen, ihAttr);	// Do tests for id() and key() patterns first	InstructionList ilKey = null;	if (_idxTestSeq != null) {	    loop.setTarget(_idxTestSeq.compile(classGen, methodGen, body.getStart()));	    ilKey = _idxTestSeq.getInstructionList();	}	else {	    loop.setTarget(body.getStart());	}	// (*) If there is a match on node() we need to replace ihElem	//     and ihText (default behaviour for elements & text).	InstructionHandle ihText = ihLoop;	if (_nodeTestSeq != null) {	    double nodePrio = -0.5; //_nodeTestSeq.getPriority();	    int    nodePos  = _nodeTestSeq.getPosition();	    double elemPrio = (0 - Double.MAX_VALUE);	    int    elemPos  = Integer.MIN_VALUE;	    if (elemTest != null) {		elemPrio = elemTest.getPriority();		elemPos  = elemTest.getPosition();	    }	    if ((elemPrio == Double.NaN) || (elemPrio < nodePrio) ||		((elemPrio == nodePrio) && (elemPos < nodePos))) {		ihElem = _nodeTestSeq.compile(classGen, methodGen, ihLoop);		ihText = ihElem;	    }	}	// (*) Handle templates with "ns:*" pattern	InstructionHandle elemNamespaceHandle = ihElem;	InstructionList nsElem = compileNamespaces(classGen, methodGen,						   isNamespace, isAttribute,						   false, ihElem);	if (nsElem != null) elemNamespaceHandle = nsElem.getStart();	// (*) Handle templates with "ns:@*" pattern	InstructionList nsAttr = compileNamespaces(classGen, methodGen,						   isNamespace, isAttribute,						   true, ihAttr);	InstructionHandle attrNamespaceHandle = ihAttr;	if (nsAttr != null) attrNamespaceHandle = nsAttr.getStart();	// (*) Handle templates with "ns:elem" or "ns:@attr" pattern	final InstructionHandle[] targets = new InstructionHandle[types.length];	for (int i = DOM.NTYPES; i < targets.length; i++) {	    final TestSeq testSeq = _testSeq[i];	    // Jump straight to namespace tests ?	    if (isNamespace[i]) {		if (isAttribute[i])		    targets[i] = attrNamespaceHandle;		else		    targets[i] = elemNamespaceHandle;	    }	    // Test first, then jump to namespace tests	    else if (testSeq != null) {		if (isAttribute[i])		    targets[i] = testSeq.compile(classGen, methodGen,						 attrNamespaceHandle);		else		    targets[i] = testSeq.compile(classGen, methodGen,						 elemNamespaceHandle);	    }	    else {		targets[i] = ihLoop;	    }	}	// Handle pattern with match on root node - default: loop	targets[DOM.ROOT] = _rootPattern != null	    ? getTemplateInstructionHandle(_rootPattern.getTemplate())	    : ihLoop;		// Handle any pattern with match on text nodes - default: loop	targets[DOM.TEXT] = _testSeq[DOM.TEXT] != null	    ? _testSeq[DOM.TEXT].compile(classGen, methodGen, ihText)	    : ihText;	// This DOM-type is not in use - default: process next node	targets[DOM.NAMESPACE] = ihLoop;	// Match unknown element in DOM - default: check for namespace match	targets[DOM.ELEMENT] = elemNamespaceHandle;	// Match unknown attribute in DOM - default: check for namespace match	targets[DOM.ATTRIBUTE] = attrNamespaceHandle;	// Match on processing instruction - default: loop	InstructionHandle ihPI = ihLoop;	if (_nodeTestSeq != null) ihPI = ihElem;	if (_testSeq[DOM.PROCESSING_INSTRUCTION] != null)	    targets[DOM.PROCESSING_INSTRUCTION] =		_testSeq[DOM.PROCESSING_INSTRUCTION].		compile(classGen, methodGen, ihPI);	else	    targets[DOM.PROCESSING_INSTRUCTION] = ihPI;		// Match on comments - default: process next node	InstructionHandle ihComment = ihLoop;	if (_nodeTestSeq != null) ihComment = ihElem;	targets[DOM.COMMENT] = _testSeq[DOM.COMMENT] != null	    ? _testSeq[DOM.COMMENT].compile(classGen, methodGen, ihComment)	    : ihComment;	// Now compile test sequences for various match patterns:	for (int i = DOM.NTYPES; i < targets.length; i++) {	    final TestSeq testSeq = _testSeq[i];	    // Jump straight to namespace tests ?	    if ((testSeq == null) || (isNamespace[i])) {		if (isAttribute[i])		    targets[i] = attrNamespaceHandle;		else		    targets[i] = elemNamespaceHandle;	    }	    // Match on node type	    else {		if (isAttribute[i])		    targets[i] = testSeq.compile(classGen, methodGen,						 attrNamespaceHandle);		else		    targets[i] = testSeq.compile(classGen, methodGen,						 elemNamespaceHandle);	    }	}	if (ilKey != null) body.insert(ilKey);	// Append first code in applyTemplates() - get type of current node	final int getType = cpg.addInterfaceMethodref(DOM_INTF,						      "getType", "(I)I");	body.append(methodGen.loadDOM());	body.append(new ILOAD(_currentIndex));	body.append(new INVOKEINTERFACE(getType, 2));	// Append switch() statement - main dispatch loop in applyTemplates()	InstructionHandle disp = body.append(new SWITCH(types,targets,ihLoop));	// Append all the "case:" statements	appendTestSequences(body);	// Append the actual template code	appendTemplateCode(body);	// Append NS:* node tests (if any)	if (nsElem != null) body.append(nsElem);	// Append NS:@* node tests (if any)	if (nsAttr != null) body.append(nsAttr);	// putting together constituent instruction lists	mainIL.append(new GOTO_W(ihLoop));	mainIL.append(body);	// fall through to ilLoop	mainIL.append(ilLoop);	peepHoleOptimization(methodGen);	methodGen.stripAttributes(true);		methodGen.setMaxLocals();	methodGen.setMaxStack();	methodGen.removeNOPs();	classGen.addMethod(methodGen.getMethod());	// Restore original (complete) set of templates for this transformation	_templates = oldTemplates;    }