if (loc instanceof XPathParser.NestedLocation) loc = ((XPathParser.NestedLocation)loc).getContainingLocation(); String instructionName = getInstructionName(loc); if (instructionName == null && e instanceof TerminationException) instructionName = "xsl:message"; while (ff.hasNext()) { ContextStackFrame f = ff.next(); instructionName = getInstructionName(f); if (instructionName != null) frames.add(XProcException.prettyLocator(f.getSystemId(), f.getLineNumber(), instructionName));
private static String getInstructionName(SourceLocator loc) { if (loc instanceof AttributeLocation) { return ((AttributeLocation)loc).getElementName().getDisplayName() + "/@" + ((AttributeLocation)loc).getAttributeName(); } else if (loc instanceof DOMLocator) { return ((DOMLocator)loc).getOriginatingNode().getNodeName(); } else if (loc instanceof NodeInfo) { return ((NodeInfo)loc).getDisplayName(); } else if (loc instanceof ValidationException && ((ValidationException)loc).getNode() != null) { return (((ValidationException)loc).getNode()).getDisplayName(); } else if (loc instanceof Instruction) { return StandardErrorListener.getInstructionName((Instruction)loc); } else if (loc instanceof Actor) { return getInstructionName((Actor)loc); } else { return null; } }
private static String getInstructionName(ContextStackFrame frame) { if (frame instanceof ContextStackFrame.FunctionCall) { StructuredQName name = ((ContextStackFrame.FunctionCall)frame).getFunctionName(); if (name != null) return name.getClarkName() + "()"; } else if (frame instanceof ContextStackFrame.ApplyTemplates) { String name = "xsl:apply-templates"; Item node = frame.getContextItem(); if (node instanceof NodeInfo) name += " processing " + Navigator.getPath((NodeInfo)node); return name; } else if (frame instanceof ContextStackFrame.CallTemplate) { return "xsl:call-template name=\"" + ((ContextStackFrame.CallTemplate)frame).getTemplateName().getDisplayName() + "\""; } else if (frame instanceof ContextStackFrame.VariableEvaluation) { Object container = frame.getContainer(); if (container instanceof Actor) { return getInstructionName((Actor)container); } else if (container instanceof TemplateRule) { return "xsl:template match=\"" + ((TemplateRule)container).getMatchPattern().toString() + "\""; } } return null; }