use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration in project webtools.sourceediting by eclipse.
the class TestBugs method testXSYearMonthDurationDivide1.
public void testXSYearMonthDurationDivide1() throws Exception {
// Bug 279376
bundle = Platform.getBundle("org.w3c.xqts.testsuite");
URL fileURL = bundle.getEntry("/TestSources/emptydoc.xml");
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
String xpath = "xs:yearMonthDuration('P2Y11M') div 1.5";
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
XSDuration result = (XSDuration) rs.first();
String actual = result.getStringValue();
assertEquals("P1Y11M", actual);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration in project webtools.sourceediting by eclipse.
the class FnSecondsFromDuration method seconds_from_duration.
/**
* Seconds-from-Duration operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:seconds-from-duration operation.
*/
public static ResultSequence seconds_from_duration(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return ResultBuffer.EMPTY;
}
XSDuration dtd = (XSDuration) arg1.first();
double res = dtd.seconds();
if (dtd.negative())
res *= -1;
return new XSDecimal(new BigDecimal(res));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration in project webtools.sourceediting by eclipse.
the class FnMinutesFromDuration method minutes_from_duration.
/**
* Minutes-from-Duration operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:minutes-from-duration operation.
*/
public static ResultSequence minutes_from_duration(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return ResultBuffer.EMPTY;
}
XSDuration dtd = (XSDuration) arg1.first();
int res = dtd.minutes();
if (dtd.negative())
res *= -1;
return new XSInteger(BigInteger.valueOf(res));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration in project webtools.sourceediting by eclipse.
the class FnMonthsFromDuration method months_from_duration.
/**
* Months-from-Duration operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:months-from-duration operation.
*/
public static ResultSequence months_from_duration(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return ResultBuffer.EMPTY;
}
XSDuration ymd = (XSDuration) arg1.first();
int res = ymd.month();
if (ymd.negative())
res *= -1;
return new XSInteger(BigInteger.valueOf(res));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration in project webtools.sourceediting by eclipse.
the class FnDaysFromDuration method days_from_duration.
/**
* Days-From-Duration operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:days-from-duration operation.
*/
public static ResultSequence days_from_duration(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return ResultBuffer.EMPTY;
}
XSDuration dtd = (XSDuration) arg1.first();
int res = dtd.days();
if (dtd.negative())
res *= -1;
return new XSInteger(BigInteger.valueOf(res));
}
Aggregations