use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit context item expression.
*
* @param e
* is the context item expression.
* @return a result sequence
*/
public Object visit(CntxItemExpr e) {
ResultBuffer rs = new ResultBuffer();
AnyType contextItem = focus().context_item();
if (contextItem == null) {
report_error(DynamicError.contextUndefined());
}
rs.add(contextItem);
return rs.getSequence();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType 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.AnyType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit variable reference
*
* @param e
* is the variable reference.
* @return a result sequence
*/
public Object visit(VarRef e) {
ResultBuffer rs = new ResultBuffer();
Object var = getVariable(e.name());
assert var != null;
if (var instanceof AnyType) {
rs.add((AnyType) var);
} else if (var instanceof ResultSequence) {
rs.concat((ResultSequence) var);
}
return rs.getSequence();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.
the class LiteralsTest method test_Literals068.
// Test the escaping of the ' (apostrophe) and " (quotation) characters as part of an XML text node constructor.
public void test_Literals068() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
// String xqFile = "/Queries/XQuery/Expressions/PrimaryExpr/Literals/Literals068.xq";
String resultFile = "/ExpectedTestResults/Expressions/PrimaryExpr/Literals/Literals068-1.txt";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
String xpath = "'He said, \"I don''t like it.\"'";
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
AnyType result = rs.first();
actual = result.getStringValue();
} catch (XPathParserException ex) {
actual = ex.code();
} catch (StaticError ex) {
actual = ex.code();
}
assertEquals("XPath Result Error:", expectedResult, actual);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.
the class LiteralsTest method test_Literals056.
// Test for string literal containing the predefined entity reference '&'.
public void test_Literals056() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/PrimaryExpr/Literals/Literals056.xq";
String resultFile = "/ExpectedTestResults/Expressions/PrimaryExpr/Literals/Literals056.txt";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
String xpath = extractXPathExpression(xqFile, inputFile);
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
AnyType result = rs.first();
actual = result.getStringValue();
} catch (XPathParserException ex) {
actual = ex.code();
} catch (StaticError ex) {
actual = ex.code();
}
assertEquals("XPath Result Error:", expectedResult, actual);
}
Aggregations