use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class TestBugs method testAttrNode_Test7.
public void testAttrNode_Test7() throws Exception {
// Bug 298535
URL fileURL = bundle.getEntry("/bugTestFiles/attrNodeTest.xml");
URL schemaURL = bundle.getEntry("/bugTestFiles/attrNodeTest.xsd");
loadDOMDocument(fileURL, schemaURL);
// Get XSModel object for the Schema
XSModel schema = getGrammar(schemaURL);
setupDynamicContext(schema);
String xpath = "Example/x/@mesg instance of attribute(mesg, mesg_Type)*";
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
XSBoolean result = (XSBoolean) rs.first();
String actual = result.getStringValue();
assertEquals("true", actual);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class TestBugs method testFnNumber_Evaluation1.
public void testFnNumber_Evaluation1() throws Exception {
// Bug 298519
URL fileURL = bundle.getEntry("/bugTestFiles/fnNumberBug.xml");
URL schemaURL = bundle.getEntry("/bugTestFiles/fnNumberBug.xsd");
loadDOMDocument(fileURL, schemaURL);
// Get XSModel object for the Schema
XSModel schema = getGrammar(schemaURL);
setupDynamicContext(schema);
String xpath = "number(Example/x) ge 18";
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
XSBoolean result = (XSBoolean) rs.first();
String actual = result.getStringValue();
assertEquals("true", actual);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit element test.
*
* @param e
* is the element test.
* @return a result sequence
*/
public Object visit(ElementTest e) {
// filter out all elements
ResultSequence rs = kind_test((ResultSequence) ((Pair) _param)._two, ElementType.class);
// match the name if it's not a wild card
ResultBuffer rb = new ResultBuffer();
QName nameTest = e.name();
QName typeTest = e.type();
for (Iterator i = rs.iterator(); i.hasNext(); ) {
NodeType node = (NodeType) i.next();
if (nameTest != null && !e.wild()) {
// skip if there's a name test and the name does not match
if (!name_test((ElementType) node, nameTest, "element"))
continue;
}
if (typeTest != null) {
// check if element derives from
if (!derivesFrom(node, typeTest))
continue;
// nilled may be true or false
if (!e.qmark()) {
XSBoolean nilled = (XSBoolean) node.nilled().first();
if (nilled.value())
continue;
}
}
rb.add(node);
}
((Pair) _param)._two = rb.getSequence();
return ((Pair) _param)._two;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method do_exists.
private XSBoolean do_exists(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_exists(iter, finalexpr);
popScope();
// out what to do with it
if (effbool.value())
return XSBoolean.TRUE;
}
} finally {
iter.previous();
}
// since none in this sequence evaluated to true, return false
return XSBoolean.FALSE;
} 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 AbstractPsychoPathTest method assertXPathTrue.
protected void assertXPathTrue(String xpath, Document domDoc) {
XSBoolean result = evaluateBoolXPath(xpath, domDoc);
assertEquals(true, result.value());
}
Aggregations