use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger in project webtools.sourceediting by eclipse.
the class OpTo method expected_args.
/**
* Obtain a list of expected arguments.
*
* @return Result of operation.
*/
public static synchronized Collection expected_args() {
if (_expected_args == null) {
_expected_args = new ArrayList();
SeqType st = new SeqType(new XSInteger());
_expected_args.add(st);
_expected_args.add(st);
}
return _expected_args;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger in project webtools.sourceediting by eclipse.
the class OpTo method op_to.
/**
* Op-To operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of operation.
*/
public static ResultSequence op_to(Collection args) throws DynamicError {
// convert arguments
Collection cargs = Function.convert_arguments(args, expected_args());
// get arguments
Iterator iter = cargs.iterator();
ResultSequence r = (ResultSequence) iter.next();
int one = ((XSInteger) r.first()).int_value().intValue();
r = (ResultSequence) iter.next();
if (r.first() == null) {
return ResultBuffer.EMPTY;
}
int two = ((XSInteger) r.first()).int_value().intValue();
if (one > two)
return ResultBuffer.EMPTY;
// inclusive first and last
if (one == two) {
return new XSInteger(BigInteger.valueOf(one));
}
/*
* for(one++; one <= two; one++) { rs.add(new XSInteger(one)); }
*
* return rs;
*/
return new RangeResultSequence(one, two);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger in project webtools.sourceediting by eclipse.
the class TestBugs method testFnIndexOf_onQName.
public void testFnIndexOf_onQName() throws Exception {
// bug 338999
URL fileURL = bundle.getEntry("/bugTestFiles/bug338999.xml");
URL schemaURL = bundle.getEntry("/bugTestFiles/bug338999.xsd");
loadDOMDocument(fileURL, schemaURL);
// Get XSModel object for the Schema
XSModel schema = getGrammar(schemaURL);
setupDynamicContext(schema);
String xpath = "fn:index-of( for $e in X/* return fn:node-name($e), fn:node-name(X/b) )";
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
assertTrue(rs.size() > 0);
String actual = ((XSInteger) rs.first()).getStringValue();
assertEquals("2", actual);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger in project webtools.sourceediting by eclipse.
the class TestBugs method testTypedValueEnhancement_BugUsingSeqIntoVariable_2.
public void testTypedValueEnhancement_BugUsingSeqIntoVariable_2() throws Exception {
// Bug 325262
setupDynamicContext(null);
ResultSequence rs = ResultSequenceFactory.create_new();
rs.add(new XSInteger(BigInteger.valueOf(2)));
rs.add(new XSInteger(BigInteger.valueOf(4)));
rs.add(new XSInteger(BigInteger.valueOf(6)));
setVariable("value", rs);
// test a
String xpath = "$value instance of xs:integer+";
compileXPath(xpath);
ResultSequence rsRes = evaluate(domDoc);
XSBoolean result = (XSBoolean) rsRes.get(0);
assertEquals("true", result.getStringValue());
// test b
xpath = "deep-equal($value, (2, 4, 6))";
compileXPath(xpath);
rsRes = evaluate(domDoc);
result = (XSBoolean) rsRes.get(0);
assertEquals("true", result.getStringValue());
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger in project webtools.sourceediting by eclipse.
the class TestBugs method testFnIndexOf_onQName2.
public void testFnIndexOf_onQName2() throws Exception {
// bug 338999
URL fileURL = bundle.getEntry("/bugTestFiles/bug338999.xml");
URL schemaURL = bundle.getEntry("/bugTestFiles/bug338999.xsd");
loadDOMDocument(fileURL, schemaURL);
// Get XSModel object for the Schema
XSModel schema = getGrammar(schemaURL);
setupDynamicContext(schema);
String xpath = "fn:index-of( for $e in X/* return fn:node-name($e), fn:QName('','b') )";
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
assertTrue(rs.size() > 0);
String actual = ((XSInteger) rs.first()).getStringValue();
assertEquals("2", actual);
}
Aggregations