use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.
the class FnCount method count.
/**
* Count operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:count operation.
*/
public static ResultSequence count(Collection args) throws DynamicError {
assert args.size() == 1;
// get args
Iterator citer = args.iterator();
ResultSequence arg = (ResultSequence) citer.next();
return ResultSequenceFactory.create_new(new XSInteger(BigInteger.valueOf(arg.size())));
}
use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.
the class FnDayFromDate method day_from_date.
/**
* Day-From-Date operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:day-from-date operation.
*/
public static ResultSequence day_from_date(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return ResultBuffer.EMPTY;
}
XSDate dt = (XSDate) arg1.first();
int res = dt.day();
return new XSInteger(BigInteger.valueOf(res));
}
use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.
the class SeqExprCastableTest method test_CastableAs080.
// Try xs:untypedAtomic(http://www.example.com/~b%C3%A9b%C3%A9) castable as xs:anyURI.
public void test_CastableAs080() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/exprSeqTypes/SeqExprCastable/CastableAs080.xq";
String resultFile = "/ExpectedTestResults/Expressions/exprSeqTypes/SeqExprCastable/CastableAs080.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.processor.DynamicError in project webtools.sourceediting by eclipse.
the class SeqExprCastableTest method test_CastableAs342.
// Try xs:dayTimeDuration(P3DT10H30M) castable as xs:date.
public void test_CastableAs342() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/exprSeqTypes/SeqExprCastable/CastableAs342.xq";
String resultFile = "/ExpectedTestResults/Expressions/exprSeqTypes/SeqExprCastable/CastableAs342.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.processor.DynamicError in project webtools.sourceediting by eclipse.
the class SeqExprCastableTest method test_CastableAs104.
// Try xs:string(-0.0E0) castable as xs:integer.
public void test_CastableAs104() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/exprSeqTypes/SeqExprCastable/CastableAs104.xq";
String resultFile = "/ExpectedTestResults/Expressions/exprSeqTypes/SeqExprCastable/CastableAs104.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