/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new ErrorExpression(exception); }
/** * Iterate over the expression. This always throws the exception registered when the expression * was first parsed. */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { evaluateItem(context); return null; // to fool the compiler }
@Override public Expression copy(RebindingMap rebindings) { if (exception != null) { ErrorExpression e2 = new ErrorExpression(exception); e2.setOriginalExpression(original); ExpressionTool.copyLocationInfo(this, e2); return e2; } else { ErrorExpression e2 = new ErrorExpression(message, errorCode, isTypeError); e2.setOriginalExpression(original); ExpressionTool.copyLocationInfo(this, e2); return e2; } }
/** * Compile an XPath expression in the context of this stylesheet element * @param expression the source text of the XPath expression * @return the compiled expression tree for the XPath expression */ public Expression makeExpression(String expression) throws XPathException { try { return ExpressionTool.make(expression, staticContext, 0, Token.EOF, getLineNumber(), getPreparedStylesheet().isCompileWithTracing()); } catch (XPathException err) { err.setLocator(this); compileError(err); ErrorExpression erexp = new ErrorExpression(err); erexp.setLocationId(allocateLocationId(getSystemId(), getLineNumber())); erexp.setContainer(this); return erexp; } }
/** * Compile an XPath expression in the context of this stylesheet element * * @param expression the source text of the XPath expression * @param attIndex the index position of the attribute containing the XPath expression, or * -1 if the expression is in a text node * @return the compiled expression tree for the XPath expression. In the case of an error, * returns an ErrorExpression that will fail at run-time if executed. */ public Expression makeExpression(String expression, int attIndex) { try { StaticContext env = staticContext; if (attIndex >= 0) { StructuredQName attName = getAttributeList().getNodeName(attIndex).getStructuredQName(); env = getStaticContext(attName); } return ExpressionTool.make(expression, env, 0, Token.EOF, getCompilation().getCompilerInfo().getCodeInjector()); } catch (XPathException err) { err.maybeSetLocation(allocateLocation()); if (err.isReportableStatically()) { compileError(err); } ErrorExpression erexp = new ErrorExpression(err); erexp.setRetainedStaticContext(makeRetainedStaticContext()); erexp.setLocation(allocateLocation()); return erexp; } }
throw err; } else { ErrorExpression ee = new ErrorExpression(err); ExpressionTool.copyLocationInfo(actionOps[i].getChildExpression(), ee); setAction(i, ee); ((ErrorExpression)getAction(i)).isTypeError() && !Literal.isConstantBoolean(getCondition(i), false) && !Literal.isConstantBoolean(getCondition(i), true)) { + ((ErrorExpression) getAction(i)).getMessage(), getAction(i).getLocation());
return exp; } else { ErrorExpression erexp = new ErrorExpression(err); erexp.setLocation(allocateLocation()); return erexp;
return exp; } else { ErrorExpression erexp = new ErrorExpression(err); erexp.setLocationId(allocateLocationId(getSystemId(), getLineNumber())); return erexp;
/** * Evaluate the expression. This always throws the exception registered when the expression * was first parsed. */ public Item evaluateItem(XPathContext context) throws XPathException { if (exception != null) { // copy the exception for thread-safety, because we want to add context information XPathException err = new XPathException(exception); err.setLocation(exception.getLocator()); err.maybeSetLocation(getLocation()); err.setErrorCodeQName(exception.getErrorCodeQName()); err.setXPathContext(exception.getXPathContext()); err.maybeSetContext(context); err.setIsTypeError(exception.isTypeError()); err.setIsStaticError(exception.isStaticError()); err.setIsGlobalError(exception.isGlobalError()); throw err; } else { XPathException err = new XPathException(message); err.setLocation(getLocation()); err.setErrorCode(errorCode); err.setXPathContext(context); err.setIsTypeError(isTypeError); throw err; } }
/** * Compile an XPath expression in the context of this stylesheet element * @param expression the source text of the XPath expression * @return the compiled expression tree for the XPath expression */ public Expression makeExpression(String expression) throws XPathException { try { return ExpressionTool.make(expression, staticContext, 0, Token.EOF, getLineNumber(), getPreparedStylesheet().isCompileWithTracing()); } catch (XPathException err) { err.setLocator(this); compileError(err); ErrorExpression erexp = new ErrorExpression(err); erexp.setLocationId(allocateLocationId(getSystemId(), getLineNumber())); erexp.setContainer(this); return erexp; } }
/** * Compile an XPath expression in the context of this stylesheet element * * @param expression the source text of the XPath expression * @param attIndex the index position of the attribute containing the XPath expression, or * -1 if the expression is in a text node * @return the compiled expression tree for the XPath expression. In the case of an error, * returns an ErrorExpression that will fail at run-time if executed. */ public Expression makeExpression(String expression, int attIndex) { try { StaticContext env = staticContext; if (attIndex >= 0) { StructuredQName attName = getAttributeList().getNodeName(attIndex).getStructuredQName(); env = getStaticContext(attName); } return ExpressionTool.make(expression, env, 0, Token.EOF, getCompilation().getCompilerInfo().getCodeInjector()); } catch (XPathException err) { err.maybeSetLocation(allocateLocation()); if (err.isReportableStatically()) { compileError(err); } ErrorExpression erexp = new ErrorExpression(err); erexp.setRetainedStaticContext(makeRetainedStaticContext()); erexp.setLocation(allocateLocation()); return erexp; } }
throw err; } else { ErrorExpression ee = new ErrorExpression(err); ExpressionTool.copyLocationInfo(actionOps[i].getChildExpression(), ee); setAction(i, ee); ((ErrorExpression)getAction(i)).isTypeError() && !Literal.isConstantBoolean(getCondition(i), false) && !Literal.isConstantBoolean(getCondition(i), true)) { + ((ErrorExpression) getAction(i)).getMessage(), getAction(i).getLocation());
return exp; } else { ErrorExpression erexp = new ErrorExpression(err); erexp.setLocation(allocateLocation()); return erexp;
return exp; } else { ErrorExpression erexp = new ErrorExpression(err); erexp.setLocationId(allocateLocationId(getSystemId(), getLineNumber())); return erexp;
/** * Evaluate the expression. This always throws the exception registered when the expression * was first parsed. */ public Item evaluateItem(XPathContext context) throws XPathException { if (exception != null) { // copy the exception for thread-safety, because we want to add context information XPathException err = new XPathException(exception); err.setLocation(exception.getLocator()); err.maybeSetLocation(getLocation()); err.setErrorCodeQName(exception.getErrorCodeQName()); err.setXPathContext(exception.getXPathContext()); err.maybeSetContext(context); err.setIsTypeError(exception.isTypeError()); err.setIsStaticError(exception.isStaticError()); err.setIsGlobalError(exception.isGlobalError()); throw err; } else { XPathException err = new XPathException(message); err.setLocation(getLocation()); err.setErrorCode(errorCode); err.setXPathContext(context); err.setIsTypeError(isTypeError); throw err; } }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new ErrorExpression(exception); }
@Override public Expression copy(RebindingMap rebindings) { if (exception != null) { ErrorExpression e2 = new ErrorExpression(exception); e2.setOriginalExpression(original); ExpressionTool.copyLocationInfo(this, e2); return e2; } else { ErrorExpression e2 = new ErrorExpression(message, errorCode, isTypeError); e2.setOriginalExpression(original); ExpressionTool.copyLocationInfo(this, e2); return e2; } }
/** * Iterate over the expression. This always throws the exception registered when the expression * was first parsed. */ public SequenceIterator iterate(XPathContext context) throws XPathException { evaluateItem(context); return null; // to fool the compiler }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new ErrorExpression(exception); }
/** * Type-check the expression. */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, /*@Nullable*/ ContextItemStaticInfo contextInfo) throws XPathException { if (contextInfo.getItemType() == ErrorType.getInstance()) { visitor.issueWarning("Evaluation will always fail: there is no context item", getLocation()); ErrorExpression ee = new ErrorExpression("There is no context item", getErrorCodeForUndefinedContext(), true); ee.setOriginalExpression(this); ExpressionTool.copyLocationInfo(this, ee); return ee; } else { staticInfo = contextInfo; } return this; }