Search in sources :

Example 56 with QName

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

the class AbstractPsychoPathWTPTest method setupVariables.

protected DynamicContext setupVariables(DynamicContext dc) {
    dc.add_variable(new QName("x"));
    dc.add_variable(new QName("var"));
    if (domDoc != null) {
        AnyType docType = new DocType(domDoc, dc.getTypeModel(domDoc));
        dc.set_variable(new QName("input-context1"), docType);
        dc.set_variable(new QName("input-context"), docType);
        if (domDoc2 == null) {
            dc.set_variable(new QName("input-context2"), docType);
        } else {
            dc.set_variable(new QName("input-context2"), (AnyType) new DocType(domDoc2, dc.getTypeModel(domDoc2)));
        }
    }
    return dc;
}
Also used : QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType) DocType(org.eclipse.wst.xml.xpath2.processor.internal.types.DocType)

Example 57 with QName

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

the class SeqExprCastSITest method test_qname_cast_4.

// Evaluates casting QName type to a QName derived type.
public void test_qname_cast_4() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/SchemaImport/SeqExprCastSI/qname-cast-4.xq";
    String resultFile = "/ExpectedTestResults/SchemaImport/SeqExprCastSI/value1.txt";
    String expectedResult = getExpectedResult(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    Schema jaxpSchema = loadSchema();
    loadDOMDocument(fileURL, jaxpSchema);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    addUserDefinedSimpleTypes(schema);
    String xpath = "xs:QName(\"value1\") cast as myType:QNameBased";
    String actual = null;
    try {
        compileXPath(xpath);
        ResultSequence rs = evaluate(domDoc);
        actual = buildResultString(rs);
    } catch (XPathParserException ex) {
        actual = ex.code();
    } catch (StaticError ex) {
        actual = ex.code();
    } catch (DynamicError ex) {
        actual = ex.code();
    }
    assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
Also used : XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) Schema(javax.xml.validation.Schema) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL)

Example 58 with QName

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

the class AbstractPsychoPathTest method setVariable.

protected void setVariable(String name, ResultSequence values) {
    if (useNewApi) {
        staticContextBuilder.withVariable(new javax.xml.namespace.QName(name), new SimpleAtomicItemTypeImpl(BuiltinTypeLibrary.XS_ANYATOMICTYPE, ItemType.OCCURRENCE_NONE_OR_MANY));
        dynamicContextBuilder.withVariable(new javax.xml.namespace.QName(name), values);
    } else {
        dynamicContext.set_variable(new QName(name), values);
    }
}
Also used : QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) SimpleAtomicItemTypeImpl(org.eclipse.wst.xml.xpath2.processor.internal.types.SimpleAtomicItemTypeImpl)

Example 59 with QName

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

the class ResolveQNameFuncTest method test_fn_resolve_qname_4.

public void test_fn_resolve_qname_4() throws Exception {
    String inputFile = "/TestSources/MixNS.xml";
    String xqFile = "/Queries/XQuery/Functions/URIFunc/ResolveURIFunc/fn-resolve-uri-1.xq";
    String expectedResult = "c";
    URL fileURL = bundle.getEntry(inputFile);
    loadDOMDocument(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    addNamespace("cm", "http://www.example.com");
    addNamespace("ed", "http://www.example.edu");
    String xpath = "fn:string(fn:local-name-from-QName(fn:resolve-QName(\"cm:c\", /a/b/cm:c)))";
    String actual = null;
    try {
        compileXPath(xpath);
        ResultSequence rs = evaluate(domDoc);
        actual = buildResultString(rs);
    } catch (XPathParserException ex) {
        actual = ex.code();
    } catch (StaticError ex) {
        actual = ex.code();
    } catch (DynamicError ex) {
        actual = ex.code();
    }
    assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
Also used : XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL)

Example 60 with QName

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

the class ResolveQNameFuncTest method test_fn_resolve_qname_9.

public void test_fn_resolve_qname_9() throws Exception {
    String inputFile = "/TestSources/examples.xml";
    String xqFile = "/Queries/XQuery/Functions/URIFunc/ResolveURIFunc/fn-resolve-uri-1.xq";
    String expectedResult = "http://www.w3.org/XQueryTest/someExamples";
    URL fileURL = bundle.getEntry(inputFile);
    loadDOMDocument(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    addNamespace(null, "http://www.w3.org/XQueryTest/someExamples");
    String xpath = "fn:string(fn:namespace-uri-from-QName(fn:resolve-QName(\"E6-Root\", /E6-Root)))";
    String actual = null;
    try {
        compileXPath(xpath);
        ResultSequence rs = evaluate(domDoc);
        actual = buildResultString(rs);
    } catch (XPathParserException ex) {
        actual = ex.code();
    } catch (StaticError ex) {
        actual = ex.code();
    } catch (DynamicError ex) {
        actual = ex.code();
    }
    assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
Also used : XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL)

Aggregations

DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)77 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)77 URL (java.net.URL)76 XSModel (org.apache.xerces.xs.XSModel)76 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)76 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)76 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)42 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)21 Iterator (java.util.Iterator)18 Collection (java.util.Collection)17 ArrayList (java.util.ArrayList)13 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)11 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)10 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)10 ListIterator (java.util.ListIterator)9 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)9 XPathExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr)6 TypeDefinition (org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition)5 SeqType (org.eclipse.wst.xml.xpath2.processor.internal.SeqType)5 Schema (javax.xml.validation.Schema)4