Search in sources :

Example 21 with XSInteger

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;
}
Also used : SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) ArrayList(java.util.ArrayList)

Example 22 with XSInteger

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);
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) RangeResultSequence(org.eclipse.wst.xml.xpath2.processor.internal.RangeResultSequence) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) Iterator(java.util.Iterator) Collection(java.util.Collection) RangeResultSequence(org.eclipse.wst.xml.xpath2.processor.internal.RangeResultSequence)

Example 23 with XSInteger

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);
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) XSModel(org.apache.xerces.xs.XSModel) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) URL(java.net.URL)

Example 24 with XSInteger

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());
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Example 25 with XSInteger

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);
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) XSModel(org.apache.xerces.xs.XSModel) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) URL(java.net.URL)

Aggregations

XSInteger (org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger)34 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)32 Collection (java.util.Collection)20 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)12 Iterator (java.util.Iterator)8 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)8 XSDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration)6 URL (java.net.URL)5 XSModel (org.apache.xerces.xs.XSModel)5 Item (org.eclipse.wst.xml.xpath2.api.Item)5 XSDateTime (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime)5 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)4 BigInteger (java.math.BigInteger)3 XSBoolean (org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)3 XSDate (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate)3 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 SeqType (org.eclipse.wst.xml.xpath2.processor.internal.SeqType)2 AnyAtomicType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType)2 XSTime (org.eclipse.wst.xml.xpath2.processor.internal.types.XSTime)2