use of org.eclipse.wst.xml.xpath2.api.Function in project webtools.sourceediting by eclipse.
the class FunctionLibraryImpl method resolveFunction.
public org.eclipse.wst.xml.xpath2.api.Function resolveFunction(String localName, int arity) {
Function f = (Function) _functions.get(signature(localName, arity));
if (f != null || arity == -1)
return f;
// see if we got a varg one
f = (Function) _functions.get(signature(localName, -1));
// nope
if (f == null)
return null;
if (f.canMatchArity(arity))
return f;
return null;
}
use of org.eclipse.wst.xml.xpath2.api.Function in project webtools.sourceediting by eclipse.
the class XQueryCommentTest method test_XQueryComment012.
// Comments that looks like a function call.
public void test_XQueryComment012() throws Exception {
String inputFile = "/TestSources/TreeEmpty.xml";
String xqFile = "/Queries/XQuery/Expressions/XQueryComment/XQueryComment012.xq";
String resultFile = "/ExpectedTestResults/Expressions/XQueryComment/XQueryComment012.xml";
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 = "$input-context/south(: comment :)";
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
actual = buildXMLResultString(rs);
} catch (XPathParserException ex) {
actual = ex.code();
} catch (StaticError ex) {
actual = ex.code();
} catch (DynamicError ex) {
actual = ex.code();
}
assertXMLEqual("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
use of org.eclipse.wst.xml.xpath2.api.Function in project webtools.sourceediting by eclipse.
the class DateAddYMDTest method test_op_add_yearMonthDuration_to_date_7.
// Evaluates the "op:add-yearMonthDuration-to-date" operator as an argument to the "fn:string" function.
public void test_op_add_yearMonthDuration_to_date_7() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-7.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-7.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);
actual = buildResultString(rs);
} catch (XPathParserException ex) {
actual = ex.code();
} catch (StaticError ex) {
actual = ex.code();
} catch (DynamicError ex) {
actual = ex.code();
}
assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
use of org.eclipse.wst.xml.xpath2.api.Function in project webtools.sourceediting by eclipse.
the class DateAddYMDTest method test_op_add_yearMonthDuration_to_date_5.
// Evaluates the "op:add-yearMonthDuration-to-date" operator as an argument to the "fn:boolean" function.
public void test_op_add_yearMonthDuration_to_date_5() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-5.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-5.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);
actual = buildResultString(rs);
} catch (XPathParserException ex) {
actual = ex.code();
} catch (StaticError ex) {
actual = ex.code();
} catch (DynamicError ex) {
actual = ex.code();
}
assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
use of org.eclipse.wst.xml.xpath2.api.Function in project webtools.sourceediting by eclipse.
the class DateAddYMDTest method test_op_add_yearMonthDuration_to_date_4.
// Evaluates the "op:add-yearMonthDuration-to-date" operator used in conjunction with the "fn:not" function.
public void test_op_add_yearMonthDuration_to_date_4() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-4.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-4.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);
actual = buildResultString(rs);
} catch (XPathParserException ex) {
actual = ex.code();
} catch (StaticError ex) {
actual = ex.code();
} catch (DynamicError ex) {
actual = ex.code();
}
assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
Aggregations