use of org.eclipse.wst.xml.xpath2.processor.ResultSequence in project webtools.sourceediting by eclipse.
the class FnSecondsFromTime method seconds_from_time.
/**
* Base-Uri operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:base-uri operation.
*/
public static ResultSequence seconds_from_time(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return ResultBuffer.EMPTY;
}
XSTime dt = (XSTime) arg1.first();
double res = dt.second();
return new XSDecimal(new BigDecimal(res));
}
use of org.eclipse.wst.xml.xpath2.processor.ResultSequence in project webtools.sourceediting by eclipse.
the class FnCollection method getCollection.
private static ResultSequence getCollection(String uri, EvaluationContext ec) {
ResultBuffer rs = new ResultBuffer();
Map /*<String, List<Document>>*/
collectionMap = ec.getDynamicContext().getCollections();
List /*<Document>*/
docList = (List) collectionMap.get(uri);
for (int i = 0; i < docList.size(); i++) {
Document doc = (Document) docList.get(i);
rs.add(new DocType(doc, ec.getStaticContext().getTypeModel()));
}
return rs.getSequence();
}
use of org.eclipse.wst.xml.xpath2.processor.ResultSequence 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.ResultSequence 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.ResultSequence 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);
}
Aggregations