Search in sources :

Example 26 with XSInteger

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger in project webtools.sourceediting by eclipse.

the class TestBugs method testTypedValueEnhancement_Bug323900_3.

public void testTypedValueEnhancement_Bug323900_3() throws Exception {
    // Bug 323900
    URL fileURL = bundle.getEntry("/bugTestFiles/bug323900_2.xml");
    URL schemaURL = bundle.getEntry("/bugTestFiles/bug323900_2.xsd");
    loadDOMDocument(fileURL, schemaURL);
    // Get XSModel object for the Schema
    XSModel schema = getGrammar(schemaURL);
    setupDynamicContext(schema);
    String xpath = "data(X)";
    compileXPath(xpath);
    ResultSequence rs = evaluate(domDoc);
    assertTrue(rs.get(0) instanceof XSInteger);
    assertEquals(BigInteger.ONE, ((XSInteger) rs.get(0)).int_value());
    assertTrue(rs.get(1) instanceof XSInteger);
    assertEquals(BigInteger.valueOf(2), ((XSInteger) rs.get(1)).int_value());
    assertTrue(rs.get(2) instanceof XSString);
    assertEquals("3.3", ((XSString) rs.get(2)).getStringValue());
}
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) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) URL(java.net.URL)

Example 27 with XSInteger

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger in project webtools.sourceediting by eclipse.

the class TestBugs method testTypedValueEnhancement_Bug323900_5.

public void testTypedValueEnhancement_Bug323900_5() throws Exception {
    // Bug 323900
    URL fileURL = bundle.getEntry("/bugTestFiles/bug323900_4.xml");
    URL schemaURL = bundle.getEntry("/bugTestFiles/bug323900_3.xsd");
    loadDOMDocument(fileURL, schemaURL);
    // Get XSModel object for the Schema
    XSModel schema = getGrammar(schemaURL);
    setupDynamicContext(schema);
    String xpath = "data(X)";
    compileXPath(xpath);
    ResultSequence rs = evaluate(domDoc);
    XSInteger result = (XSInteger) rs.get(0);
    assertEquals("10", result.getStringValue());
}
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 28 with XSInteger

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger in project webtools.sourceediting by eclipse.

the class TestBugs method testFunctionAtomization.

public void testFunctionAtomization() throws Exception {
    // Bug 318313
    URL fileURL = bundle.getEntry("/bugTestFiles/bug318313.xml");
    URL schemaURL = bundle.getEntry("/bugTestFiles/bug318313.xsd");
    loadDOMDocument(fileURL, schemaURL);
    // Get XSModel object for the Schema
    XSModel schema = getGrammar(schemaURL);
    setupDynamicContext(schema);
    String xpath = "abs(X)";
    compileXPath(xpath);
    ResultSequence rs = evaluate(domDoc);
    XSInteger result = (XSInteger) rs.first();
    String actual = result.getStringValue();
    assertEquals("100", 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 29 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_3.

public void testTypedValueEnhancement_BugUsingSeqIntoVariable_3() 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);
    String xpath = "count(data($value)) = 3";
    compileXPath(xpath);
    ResultSequence rsRes = evaluate(domDoc);
    XSBoolean 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 30 with XSInteger

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger in project webtools.sourceediting by eclipse.

the class FnMinutesFromTime method minutes_from_time.

/**
 * Minutes-from-Time operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:minutes-from-time operation.
 */
public static ResultSequence minutes_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();
    int res = dt.minute();
    return new XSInteger(BigInteger.valueOf(res));
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) Collection(java.util.Collection) XSTime(org.eclipse.wst.xml.xpath2.processor.internal.types.XSTime)

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