Search in sources :

Example 46 with XSBoolean

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

the class AbstractPsychoPathWTPTest method assertXPathTrue.

protected void assertXPathTrue(String xpath, DynamicContext dc, Document domDoc) {
    XSBoolean result = evaluateBoolXPath(xpath, dc, domDoc);
    assertEquals(true, result.value());
}
Also used : XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)

Example 47 with XSBoolean

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

the class TestBugs method testDocumentUriBug.

public void testDocumentUriBug() throws Exception {
    // Bug 274731
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = dbf.newDocumentBuilder();
    InputSource inputSource = getTestSource("http://resolved-locally/xml/note.xml");
    domDoc = docBuilder.parse(inputSource);
    setupDynamicContext(null);
    String xpath = "document-uri(/) eq xs:anyURI('http://resolved-locally/xml/note.xml')";
    compileXPath(xpath);
    ResultSequence rs = evaluate(domDoc);
    XSBoolean result = (XSBoolean) rs.first();
    String actual = "false";
    if (result != null) {
        actual = result.getStringValue();
    }
    assertEquals("true", actual);
}
Also used : InputSource(org.xml.sax.InputSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Example 48 with XSBoolean

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

the class TestBugs method evaluateBoolean.

// I can't stand to see so much duplicated code!!!
private boolean evaluateBoolean(String xpath) throws Exception {
    compileXPath(xpath);
    ResultSequence rs = evaluate(domDoc);
    XSBoolean result = (XSBoolean) rs.first();
    return result.value();
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)

Example 49 with XSBoolean

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

the class TestBugs method testBug334842.

public void testBug334842() throws Exception {
    // Bug 334842
    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);
    // test a)
    String xpath = "xs:Name('x:abc') eq xs:Name('x:abc')";
    compileXPath(xpath);
    ResultSequence rsRes = evaluate(domDoc);
    XSBoolean result = (XSBoolean) rsRes.get(0);
    assertEquals("true", result.getStringValue());
    // test b)
    xpath = "xs:NCName('x:abc') eq xs:NCName('x:abc')";
    compileXPath(xpath);
    try {
        rsRes = evaluate(domDoc);
        assertTrue(false);
    } catch (DynamicError ex) {
        // a 'DynamicError' exception indicates, that this test is a success
        assertTrue(true);
    }
    // test c)
    xpath = "xs:NCName('abc') eq xs:NCName('abc')";
    compileXPath(xpath);
    rsRes = evaluate(domDoc);
    result = (XSBoolean) rsRes.get(0);
    assertEquals("true", result.getStringValue());
    // test d)
    xpath = "xs:ID('x:abc') eq xs:ID('x:abc')";
    compileXPath(xpath);
    try {
        rsRes = evaluate(domDoc);
        assertTrue(false);
    } catch (DynamicError ex) {
        // a 'DynamicError' exception indicates, that this test is a success
        assertTrue(true);
    }
    // test e)
    xpath = "xs:ID('abc') eq xs:ID('abc')";
    compileXPath(xpath);
    rsRes = evaluate(domDoc);
    result = (XSBoolean) rsRes.get(0);
    assertEquals("true", result.getStringValue());
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) XSModel(org.apache.xerces.xs.XSModel) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL)

Example 50 with XSBoolean

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

the class TestBugs method testXSPositiveInteger.

public void testXSPositiveInteger() throws Exception {
    // Bug 277632
    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);
    // min value of xs:positiveInteger is 1
    // max value of xs:positiveInteger is INF
    String xpath = "xs:positiveInteger('1') eq 1";
    compileXPath(xpath);
    ResultSequence rs = evaluate(domDoc);
    XSBoolean result = (XSBoolean) rs.first();
    String actual = result.getStringValue();
    assertEquals("true", actual);
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) XSModel(org.apache.xerces.xs.XSModel) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) URL(java.net.URL)

Aggregations

XSBoolean (org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)87 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)69 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)65 URL (java.net.URL)62 XSModel (org.apache.xerces.xs.XSModel)61 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)15 Iterator (java.util.Iterator)10 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)5 Collection (java.util.Collection)4 ListIterator (java.util.ListIterator)4 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)4 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)4 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)3 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)3 XSInteger (org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 Schema (javax.xml.validation.Schema)2 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)2 ElementType (org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType)2