use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit instance of expression
*
* @param ioexp
* is the instance of expression.
* @return a new function
*/
public Object visit(InstOfExpr ioexp) {
// get the value
ResultSequence rs = (ResultSequence) ioexp.left().accept(this);
// get the sequence type
SequenceType seqt = (SequenceType) ioexp.right();
return ResultSequenceFactory.create_new(new XSBoolean(isInstanceOf(rs, seqt)));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit if expression
*
* @param ifex
* is the if expression.
* @return a ifex.then_clause().accept(this).
*/
public Object visit(IfExpr ifex) {
ResultSequence test_res = do_expr(ifex.iterator());
XSBoolean res = effective_boolean_value(test_res);
if (res.value())
return ifex.then_clause().accept(this);
else
return ifex.else_clause().accept(this);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit castable expression
*
* @param cexp
* is the castable expression.
* @return a new function
*/
public Object visit(CastableExpr cexp) {
boolean castable = false;
try {
CastExpr ce = new CastExpr((Expr) cexp.left(), (SingleType) cexp.right());
visit(ce);
castable = true;
} catch (Throwable t) {
castable = false;
}
return ResultSequenceFactory.create_new(new XSBoolean(castable));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method do_for_all.
// XXX ugly
// type: 0 = for [return == "correct"]
// 1 = for all [return false, return empty on true]
// 2 = there exists [return true, return empty on false]
private XSBoolean do_for_all(ListIterator iter, Expr finalexpr) {
// we have more vars to bind...
if (iter.hasNext()) {
VarExprPair ve = (VarExprPair) iter.next();
// evaluate binding sequence
ResultSequence rs = (ResultSequence) ve.expr().accept(this);
QName varname = ve.varname();
try {
for (Iterator i = rs.iterator(); i.hasNext(); ) {
AnyType item = (AnyType) i.next();
pushScope(varname, item);
XSBoolean effbool = do_for_all(iter, finalexpr);
popScope();
// out what to do with it
if (!effbool.value())
return XSBoolean.FALSE;
}
} finally {
iter.previous();
}
return XSBoolean.TRUE;
} else // we finally got to do the "last expression"
{
return effective_boolean_value((ResultSequence) finalexpr.accept(this));
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit schema element test.
*
* @param e
* is the schema element test.
* @return a result sequence
*/
public Object visit(SchemaElemTest e) {
// filter out all elements
ResultSequence rs = kind_test((ResultSequence) ((Pair) _param)._two, ElementType.class);
// match the name
// XXX substitution groups
QName name = e.name();
for (Iterator i = rs.iterator(); i.hasNext(); ) {
if (!name_test((ElementType) i.next(), name, "element"))
i.remove();
}
// check the type
TypeDefinition et = _sc.getTypeModel().lookupElementDeclaration(name.namespace(), name.local());
for (Iterator i = rs.iterator(); i.hasNext(); ) {
NodeType node = (NodeType) i.next();
if (!derivesFrom(node, et)) {
i.remove();
continue;
}
XSBoolean nilled = (XSBoolean) node.nilled().first();
// XXX or, in schema it is nillable
if (nilled.value())
i.remove();
}
return rs;
}
Aggregations