use of org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest in project webtools.sourceediting by eclipse.
the class NodeTestTest method test_NodeTest009_1.
// comment() gets no descendant comment nodes.
public void test_NodeTest009_1() throws Exception {
String inputFile = "/TestSources/Tree1Child.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest009.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest009-1.xml";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
String xpath = "fn:count($input-context//center/comment())";
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
actual = "<out>" + buildResultString(rs) + "</out>";
} 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);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest in project webtools.sourceediting by eclipse.
the class NodeTestTest method test_NodeTest008_1.
// text() gets no descendant text nodes.
public void test_NodeTest008_1() throws Exception {
String inputFile = "/TestSources/Tree1Child.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest008.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest008-1.xml";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
String xpath = "fn:count($input-context//center/text())";
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
actual = "<out>" + buildResultString(rs) + "</out>";
} 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);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest in project webtools.sourceediting by eclipse.
the class NodeTestTest method test_NodeTest006.
// Simple test for node type text().
public void test_NodeTest006() throws Exception {
String inputFile = "/TestSources/bib.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest006.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest006.xml";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
// String xpath = extractXPathExpression(xqFile, inputFile);
String xpath = "$input-context/bib/book/editor/affiliation/text()";
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
actual = "<result>" + buildXMLResultString(rs) + "</result>";
} 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);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest in project webtools.sourceediting by eclipse.
the class NodeTestTest method test_NodeTest008_2.
// text() gets text nodes.
public void test_NodeTest008_2() throws Exception {
String inputFile = "/TestSources/TreeCompass.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest008.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest008-2.xml";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
String xpath = "fn:count($input-context//center/text())";
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
actual = "<out>" + buildResultString(rs) + "</out>";
} 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);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest in project webtools.sourceediting by eclipse.
the class NodeTestTest method test_NodeTesthc_5.
// Simple test involving Element node types and a boolean expression (or fn:false()).
public void test_NodeTesthc_5() throws Exception {
String inputFile = "/TestSources/works-mod.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTesthc-5.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTesthc-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);
String xpath = "$input-context1//overtime/node() or fn:false()";
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
actual = "<result>" + buildResultString(rs) + "</result>";
} 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);
}
Aggregations