Search in sources :

Example 11 with XSAnyURI

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

the class SeqDocFuncTest method test_fn_doc_7.

// Evaluation of fn:doc (normal usage) and retrieve part of the resources.
public void test_fn_doc_7() throws Exception {
    String inputFile = "/TestSources/works-mod.xml";
    String xqFile = "/Queries/XQuery/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-7.xq";
    String resultFile = "/ExpectedTestResults/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-7.txt";
    String expectedResult = getExpectedResult(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    loadDOMDocument(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    setVariable("input-context", new XSAnyURI(inputFile));
    String xpath = extractXPathExpression(xqFile, inputFile);
    String actual = null;
    try {
        compileXPath(xpath);
        ResultSequence rs = evaluate(domDoc);
        actual = buildXMLResultString(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) XSAnyURI(org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI) 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 12 with XSAnyURI

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

the class SeqDocFuncTest method test_fn_doc_5.

// Evaluation of fn:doc as per example 1 from the Functions and Operators specs for the function (usage of "is" operator).
public void test_fn_doc_5() throws Exception {
    String inputFile = "/TestSources/works-mod.xml";
    String xqFile = "/Queries/XQuery/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-5.xq";
    String resultFile = "/ExpectedTestResults/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-5.txt";
    String expectedResult = getExpectedResult(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    loadDOMDocument(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    setVariable("input-context", new XSAnyURI(inputFile));
    String xpath = extractXPathExpression(xqFile, inputFile);
    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) XSAnyURI(org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI) 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 13 with XSAnyURI

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

the class SeqDocFuncTest method test_fn_doc_20.

// Evaluation of fn:doc used together with "is" operator and a the fn:false() function and the "and" operator.
public void test_fn_doc_20() throws Exception {
    String inputFile = "/TestSources/works-mod.xml";
    String xqFile = "/Queries/XQuery/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-20.xq";
    String resultFile = "/ExpectedTestResults/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-20.txt";
    String expectedResult = getExpectedResult(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    loadDOMDocument(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    setVariable("input-context", new XSAnyURI(inputFile));
    String xpath = extractXPathExpression(xqFile, inputFile);
    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) XSAnyURI(org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI) 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 14 with XSAnyURI

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

the class SeqDocFuncTest method test_fn_doc_19.

// Evaluation of fn:doc used together with "is" operator and a the fn:true() function and the "and" operator.
public void test_fn_doc_19() throws Exception {
    String inputFile = "/TestSources/works-mod.xml";
    String xqFile = "/Queries/XQuery/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-19.xq";
    String resultFile = "/ExpectedTestResults/Functions/NodeSeqFunc/SeqDocFunc/fn-doc-19.txt";
    String expectedResult = getExpectedResult(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    loadDOMDocument(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    setVariable("input-context", new XSAnyURI(inputFile));
    String xpath = extractXPathExpression(xqFile, inputFile);
    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) XSAnyURI(org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI) 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 15 with XSAnyURI

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

the class FnNamespaceUriFromQName method namespace.

/**
 * Namespace-uri-from-QName operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:namespace-uri-from-QName operation.
 */
public static ResultSequence namespace(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    // get arg
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty())
        return ResultBuffer.EMPTY;
    QName qname = (QName) arg1.first();
    String ns = qname.namespace();
    if (ns == null)
        ns = "";
    return new XSAnyURI(ns);
}
Also used : XSAnyURI(org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) Collection(java.util.Collection)

Aggregations

XSAnyURI (org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI)22 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)17 URL (java.net.URL)16 XSModel (org.apache.xerces.xs.XSModel)16 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)16 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)16 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)16 Collection (java.util.Collection)4 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)4 Item (org.eclipse.wst.xml.xpath2.api.Item)3 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)3 Iterator (java.util.Iterator)2 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)2 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)2 AnyAtomicType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType)1 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)1 DocType (org.eclipse.wst.xml.xpath2.processor.internal.types.DocType)1 NumericType (org.eclipse.wst.xml.xpath2.processor.internal.types.NumericType)1 XSDouble (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble)1 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)1